summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2019-04-25 07:17:10 +0900
committerGitHub <[email protected]>2019-04-25 07:17:10 +0900
commite5799b5d40a5c25beab5db881f8d6315720b987c (patch)
tree535584bbc083956801dd6c8c702c8dfe8c4c44d9 /test
parent163a6d01e035f16b15d3b08c0dfddd2caec09f9b (diff)
parent4720648137f2698cceb635c251475dec645cd598 (diff)
downloadmruby-e5799b5d40a5c25beab5db881f8d6315720b987c.tar.gz
mruby-e5799b5d40a5c25beab5db881f8d6315720b987c.zip
Merge pull request #4402 from shuujii/fix-modiying-class-variable-to-frozen-class
Fix modiying class variable to frozen class/module
Diffstat (limited to 'test')
-rw-r--r--test/t/class.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/t/class.rb b/test/t/class.rb
index 290ecf74a..0c95677fc 100644
--- a/test/t/class.rb
+++ b/test/t/class.rb
@@ -433,6 +433,25 @@ assert('overriding class variable with a module (#3235)') do
end
end
+assert('class variable for frozen class/module') do
+ module CVarForFrozenModule
+ freeze
+ assert_raise(FrozenError) { @@cv = 1 }
+ end
+
+ class CVarForFrozenClassA
+ @@a = nil
+ freeze
+ end
+ class CVarForFrozenClassB < CVarForFrozenClassA
+ def a=(v)
+ @@a = v
+ end
+ end
+ b = CVarForFrozenClassB.new
+ assert_raise(FrozenError) { b.a = 1 }
+end
+
assert('class with non-class/module outer raises TypeError') do
assert_raise(TypeError) { class 0::C1; end }
assert_raise(TypeError) { class []::C2; end }