summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorCarson McDonald <[email protected]>2013-12-31 14:53:44 -0500
committerCarson McDonald <[email protected]>2013-12-31 14:53:44 -0500
commit60cd1c341b5f26fc03669d2d3978dab21ba9452b (patch)
treebfef3728fa6ec4d70095566a3387e30acdf644c6 /test
parent9cd71916221fdbbd9cff6c00607edee9a53ee635 (diff)
downloadmruby-60cd1c341b5f26fc03669d2d3978dab21ba9452b.tar.gz
mruby-60cd1c341b5f26fc03669d2d3978dab21ba9452b.zip
Method missing and inspect tests
Diffstat (limited to 'test')
-rw-r--r--test/t/kernel.rb51
1 files changed, 51 insertions, 0 deletions
diff --git a/test/t/kernel.rb b/test/t/kernel.rb
index 9cbf1867b..96783a5d4 100644
--- a/test/t/kernel.rb
+++ b/test/t/kernel.rb
@@ -325,6 +325,57 @@ assert('Kernel#loop', '15.3.1.3.29') do
assert_equal i, 100
end
+assert('Kernel#method_missing', '15.3.1.3.30') do
+ class MMTestClass
+ def method_missing(sym)
+ "A call to #{sym}"
+ end
+ end
+ mm_test = MMTestClass.new
+ assert_equal 'A call to no_method_named_this', mm_test.no_method_named_this
+
+ a = String.new
+ begin
+ a.no_method_named_this
+ rescue NoMethodError => e
+ assert_equal "undefined method 'no_method_named_this' for \"\"", e.message
+ end
+
+ class ShortInspectClass
+ def inspect
+ 'An inspect string'
+ end
+ end
+ b = ShortInspectClass.new
+ begin
+ b.no_method_named_this
+ rescue NoMethodError => e
+ assert_equal "undefined method 'no_method_named_this' for An inspect string", e.message
+ end
+
+ class LongInspectClass
+ def inspect
+ "A" * 70
+ end
+ end
+ c = LongInspectClass.new
+ begin
+ c.no_method_named_this
+ rescue NoMethodError => e
+ assert_equal "undefined method 'no_method_named_this' for #{c.to_s}", e.message
+ end
+
+ class NoInspectClass
+ undef inspect
+ end
+ d = NoInspectClass.new
+ begin
+ d.no_method_named_this
+ rescue NoMethodError => e
+ assert_equal "undefined method 'no_method_named_this' for #{d.to_s}", e.message
+ end
+end
+
assert('Kernel#methods', '15.3.1.3.31') do
assert_equal Array, methods.class
end