diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2016-11-25 09:15:57 +0900 |
|---|---|---|
| committer | GitHub <[email protected]> | 2016-11-25 09:15:57 +0900 |
| commit | 1e892c0ffa33e6e1548bde5fa182872ae7381ac8 (patch) | |
| tree | 7f0e36fef87652657cce0750fb167ef99e9fc5d2 /mrbgems/mruby-struct/test/struct.rb | |
| parent | b4d501750cc5c98ed0a04f56d5eb95fb178bcca3 (diff) | |
| parent | 82731d9ee0964b0131a9ae25e81dbec583d3af28 (diff) | |
| download | mruby-1e892c0ffa33e6e1548bde5fa182872ae7381ac8.tar.gz mruby-1e892c0ffa33e6e1548bde5fa182872ae7381ac8.zip | |
Merge pull request #3280 from bouk/struct-redefine
Remove constant when a struct is redefined.
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 02ecf69e4..bbfe18cb2 100644 --- a/mrbgems/mruby-struct/test/struct.rb +++ b/mrbgems/mruby-struct/test/struct.rb @@ -158,3 +158,24 @@ assert("Struct#dig") do assert_equal 1, a.dig(:purple, :red) 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 |
