summaryrefslogtreecommitdiffhomepage
path: root/test/t/nomethoderror.rb
diff options
context:
space:
mode:
authorFelix Jones <[email protected]>2017-02-16 13:33:46 +0000
committerFelix Jones <[email protected]>2017-02-16 13:33:46 +0000
commitd83aad8d570e4bbffa3bd3ce64e210f78afa425f (patch)
tree5389a87c135b1bdf3e23a1ba02e02400b7cf80fc /test/t/nomethoderror.rb
parent70aa6dc38d75dd6b1e2c76f290bc576e36e36ea3 (diff)
parentb165708c8deba00685f9a27926c554aaa7f3b0fb (diff)
downloadmruby-d83aad8d570e4bbffa3bd3ce64e210f78afa425f.tar.gz
mruby-d83aad8d570e4bbffa3bd3ce64e210f78afa425f.zip
Merge branch 'master' into android.rake-ndk-clang
Diffstat (limited to 'test/t/nomethoderror.rb')
-rw-r--r--test/t/nomethoderror.rb49
1 files changed, 49 insertions, 0 deletions
diff --git a/test/t/nomethoderror.rb b/test/t/nomethoderror.rb
index 5fed79689..35cbdaee9 100644
--- a/test/t/nomethoderror.rb
+++ b/test/t/nomethoderror.rb
@@ -20,3 +20,52 @@ assert('NoMethodError#args', '15.2.32.2.1') do
end
end
end
+
+assert('Can still raise when Kernel#method_missing is removed') do
+ assert_raise(NoMethodError) do
+ begin
+ Kernel.alias_method(:old_method_missing, :method_missing)
+ Kernel.remove_method(:method_missing)
+ 1.__send__(:foo)
+ ensure
+ Kernel.alias_method(:method_missing, :old_method_missing)
+ Kernel.remove_method(:old_method_missing)
+ end
+ end
+end
+
+assert('Can still call super when Kernel#method_missing is removed') do
+ assert_raise(NoMethodError) do
+ class A
+ def foo
+ super
+ end
+ end
+ begin
+ Kernel.alias_method(:old_method_missing, :method_missing)
+ Kernel.remove_method(:method_missing)
+ A.new.foo
+ ensure
+ Kernel.alias_method(:method_missing, :old_method_missing)
+ Kernel.remove_method(:old_method_missing)
+ end
+ end
+end
+
+assert("NoMethodError#new does not return an exception") do
+ begin
+ class << NoMethodError
+ def new(*)
+ nil
+ end
+ end
+
+ assert_raise(TypeError) do
+ Object.q
+ end
+ ensure
+ class << NoMethodError
+ remove_method :new
+ end
+ end
+end