summaryrefslogtreecommitdiff
path: root/test/ruby/test_variable.rb
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-06-03 20:53:35 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-06-03 20:53:35 +0000
commit152d36a79eacce66c65e154a9df28422f69d7f29 (patch)
treebc76f18f880c2ec5774edce66d092a17f68d2374 /test/ruby/test_variable.rb
parent4ef6a68235fb8790d9b937569ba4deb2148b4c49 (diff)
variable.c: remove generic ivar support for special constants
Special constants are all frozen since [Feature #8923] and cannot support ivars. Remove some unused code we had for supporting them. * variable.c (special_generic_ivar): remove flag (givar_i, rb_mark_generic_ivar_tbl): remove functions (rb_free_generic_ivar, rb_ivar_lookup, rb_ivar_delete, generic_ivar_set, rb_ivar_set, rb_ivar_defined, rb_copy_generic_ivar, rb_ivar_foreach, rb_ivar_count, rb_obj_remove_instance_variable): adjust for lack of ivar support in special constants * test/ruby/test_variable.rb: test ivars for special consts * internal.h: remove rb_mark_generic_ivar_tbl decl * gc.c (gc_mark_roots): remove rb_mark_generic_ivar_tbl call git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50758 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_variable.rb')
-rw-r--r--test/ruby/test_variable.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/ruby/test_variable.rb b/test/ruby/test_variable.rb
index 8f5329bb1c..f04e358e62 100644
--- a/test/ruby/test_variable.rb
+++ b/test/ruby/test_variable.rb
@@ -118,4 +118,22 @@ class TestVariable < Test::Unit::TestCase
}
}
end
+
+ def test_special_constant_ivars
+ [ true, false, :symbol, "dsym#{rand(9999)}".to_sym, 1, 1.0 ].each do |v|
+ assert_empty v.instance_variables
+ msg = "can't modify frozen #{v.class}"
+
+ assert_raise_with_message(RuntimeError, msg) do
+ v.instance_variable_set(:@foo, :bar)
+ end
+
+ assert_nil v.instance_variable_get(:@foo)
+ refute v.instance_variable_defined?(:@foo)
+
+ assert_raise_with_message(RuntimeError, msg) do
+ v.remove_instance_variable(:@foo)
+ end
+ end
+ end
end