summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2013-01-20 14:32:40 -0800
committerYukihiro "Matz" Matsumoto <[email protected]>2013-01-20 14:32:40 -0800
commitcc16bd7c0d70b326ddcf8de8a511116dae9fc30d (patch)
treeaad0bb92b5b983815527db305d2616244d6d71a1 /test
parentaaf5f3a0f556626bd401519846cca58d31c99716 (diff)
parentd16659c7a5c532d9313f3e501743f322a0055dc4 (diff)
downloadmruby-cc16bd7c0d70b326ddcf8de8a511116dae9fc30d.tar.gz
mruby-cc16bd7c0d70b326ddcf8de8a511116dae9fc30d.zip
Merge pull request #754 from masamitsu-murase/modify_undef_node
Modify handling of NODE_UNDEF.
Diffstat (limited to 'test')
-rw-r--r--test/t/class.rb75
1 files changed, 75 insertions, 0 deletions
diff --git a/test/t/class.rb b/test/t/class.rb
index d6c4715dd..1c50853dc 100644
--- a/test/t/class.rb
+++ b/test/t/class.rb
@@ -209,3 +209,78 @@ end
assert('Class Dup 2') do
module M; end; M.dup.class == Module
end
+
+assert('Class Alias 1') do
+ class A
+ def test; 1; end
+
+ alias test2 test
+ alias :test3 :test
+ end
+
+ A.new.test2 == 1 and A.new.test3 == 1
+end
+
+assert('Class Alias 2') do
+ class A
+ def test; 1; end
+
+ alias test2 test
+
+ def test; 2; end
+ end
+
+ A.new.test == 2 and A.new.test2 == 1
+end
+
+assert('Class Undef 1') do
+ class A
+ def test1; 1; end
+ def test2; 2; end
+
+ undef test1
+ undef :test2
+ end
+
+ result1 = false
+ begin
+ A.new.test1
+ rescue NoMethodError
+ result1 = true
+ end
+
+ result2 = false
+ begin
+ A.new.test2
+ rescue NoMethodError
+ result2 = true
+ end
+
+ result1 == true and result2 == true
+end
+
+assert('Class Undef 2') do
+ class A
+ def test1; 1; end
+ def test2; 2; end
+
+ undef test1, test2
+ end
+
+ result1 = false
+ begin
+ A.new.test1
+ rescue NoMethodError
+ result1 = true
+ end
+
+ result2 = false
+ begin
+ A.new.test2
+ rescue NoMethodError
+ result2 = true
+ end
+
+ result1 == true and result2 == true
+end
+