diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2013-04-10 01:43:00 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2013-04-10 01:43:00 +0900 |
| commit | ac005ea9391015dc049cc0b9061e879007786ac7 (patch) | |
| tree | e69a8206c43cafe99f0795368dd3321a5bb873b0 /test | |
| parent | 84acf4e3f38d01c72ae077db1234c880658c10aa (diff) | |
| parent | 87cd4c5ecc69208018c4d9deea63d566974561dd (diff) | |
| download | mruby-ac005ea9391015dc049cc0b9061e879007786ac7.tar.gz mruby-ac005ea9391015dc049cc0b9061e879007786ac7.zip | |
Merge branch 'master' of github.com:mruby/mruby
Diffstat (limited to 'test')
| -rw-r--r-- | test/t/comparable.rb | 15 | ||||
| -rw-r--r-- | test/t/kernel.rb | 25 | ||||
| -rw-r--r-- | test/t/module.rb | 23 |
3 files changed, 62 insertions, 1 deletions
diff --git a/test/t/comparable.rb b/test/t/comparable.rb index c95134246..ab81fa3ed 100644 --- a/test/t/comparable.rb +++ b/test/t/comparable.rb @@ -54,3 +54,18 @@ assert('Comparable#>=', '15.3.3.2.5') do (Foo.new >= Foo.new) == true end +assert('Comparable#between?', '15.3.3.2.6') do + class Foo + include Comparable + def <=>(x) + x + end + end + + c = Foo.new + c.between?(-1, 1) == false && + c.between?(-1, -1) == false && + c.between?( 1, 1) == false && + c.between?( 1, -1) == true && + c.between?(0, 0) == true +end diff --git a/test/t/kernel.rb b/test/t/kernel.rb index 835834359..abc8f260b 100644 --- a/test/t/kernel.rb +++ b/test/t/kernel.rb @@ -155,6 +155,16 @@ assert('Kernel#clone', '15.3.1.3.8') do a.set(2) c = a.clone + immutables = [ 1, :foo, true, false, nil ] + error_count = 0 + immutables.each do |i| + begin + i.clone + rescue TypeError + error_count += 1 + end + end + a.get == 2 and b.get == 1 and c.get == 2 && a.respond_to?(:test) == true and b.respond_to?(:test) == false and @@ -185,7 +195,18 @@ assert('Kernel#dup', '15.3.1.3.9') do a.set(2) c = a.dup - a.get == 2 and b.get == 1 and c.get == 2 and + immutables = [ 1, :foo, true, false, nil ] + error_count = 0 + immutables.each do |i| + begin + i.dup + rescue TypeError + error_count += 1 + end + end + + error_count == immutables.size and + a.get == 2 and b.get == 1 and c.get == 2 and a.respond_to?(:test) == true and b.respond_to?(:test) == false and c.respond_to?(:test) == false @@ -330,6 +351,8 @@ assert('Kernel#raise', '15.3.1.3.40') do e_list[1].class == RuntimeError end +# Kernel#require is defined in mruby-require. '15.3.1.3.42' + assert('Kernel#respond_to?', '15.3.1.3.43') do class Test4RespondTo def test_method; end diff --git a/test/t/module.rb b/test/t/module.rb index 1ff9d3aea..4b689ea5b 100644 --- a/test/t/module.rb +++ b/test/t/module.rb @@ -297,6 +297,29 @@ assert('Module#remove_method', '15.2.2.4.41') do not Test4RemoveMethod::Child.instance_methods(false).include? :hello end +assert('Module.undef_method', '15.2.2.4.42') do + module Test4UndefMethod + class Parent + def hello + end + end + + class Child < Parent + def hello + end + end + + class GrandChild < Child + end + end + + Test4UndefMethod::Child.class_eval{ undef_method :hello } + + Test4UndefMethod::Parent.new.respond_to?(:hello) and + not Test4UndefMethod::Child.new.respond_to?(:hello) and + not Test4UndefMethod::GrandChild.new.respond_to?(:hello) +end + # Not ISO specified |
