diff options
author | shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-12-20 08:13:53 +0000 |
---|---|---|
committer | shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-12-20 08:13:53 +0000 |
commit | ea01ffa56951724708858b982d7aa64504cc412c (patch) | |
tree | 8196c9203f6fe953f5bba9ccc81be26e179b5ab5 /test | |
parent | a1580347899f1fb6fd85d82828db3f372e5ec86d (diff) | |
download | ruby-ea01ffa56951724708858b982d7aa64504cc412c.tar.gz |
* vm_core.h (rb_vm_defineclass_type_t),
compile.c (iseq_compile_each), insns.def (defineclass): change the
meaning of the third operand of defineclass as follows:
lower 3bits: the type of the defineclass
0 = class, 1 = singleton class, 2 = module
4th bit: a flag represents whether the defineclass is scoped
0 = not scoped (e.g., class Foo)
1 = scoped (e.g., class Bar::Baz)
5th bit: a flag represents whether the superclass is specified
0 = not specified (e.g., class Foo)
1 = specified (e.g., class Bar < Foo)
If the superclass is specified and is not a class, a TypeError
should be raised. [ruby-dev:46747] [Bug #7572]
* test/ruby/test_class.rb: related test.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38495 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_class.rb | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/test/ruby/test_class.rb b/test/ruby/test_class.rb index 0ac29b3cf4..fa50d2f3e7 100644 --- a/test/ruby/test_class.rb +++ b/test/ruby/test_class.rb @@ -299,4 +299,41 @@ class TestClass < Test::Unit::TestCase assert_equal 1, m::C assert_equal 1, m.m end + + def test_invalid_superclass + assert_raise(TypeError) do + eval <<-EOF + class C < nil + end + EOF + end + + assert_raise(TypeError) do + eval <<-EOF + class C < false + end + EOF + end + + assert_raise(TypeError) do + eval <<-EOF + class C < true + end + EOF + end + + assert_raise(TypeError) do + eval <<-EOF + class C < 0 + end + EOF + end + + assert_raise(TypeError) do + eval <<-EOF + class C < "" + end + EOF + end + end end |