diff options
Diffstat (limited to 'mrbgems/mruby-struct/test/struct.rb')
| -rw-r--r-- | mrbgems/mruby-struct/test/struct.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/mrbgems/mruby-struct/test/struct.rb b/mrbgems/mruby-struct/test/struct.rb index c5ca576e5..3e5d00d1f 100644 --- a/mrbgems/mruby-struct/test/struct.rb +++ b/mrbgems/mruby-struct/test/struct.rb @@ -159,6 +159,27 @@ assert("Struct#dig") do assert_equal 1, a.dig(1, 0) end +assert("Struct.new removes existing constant") do + begin + assert_not_equal Struct.new("Test", :a), Struct.new("Test", :a, :b) + ensure + Struct.remove_const :Test + end +end + +assert("Struct#initialize_copy requires struct to be the same type") do + begin + Struct.new("Test", :a) + a = Struct::Test.new("a") + Struct.new("Test", :a, :b) + assert_raise(TypeError) do + a.initialize_copy(Struct::Test.new("a", "b")) + end + ensure + Struct.remove_const :Test + end +end + assert("Struct.new does not allow array") do assert_raise(TypeError) do Struct.new("Test", [:a]) |
