diff options
author | nahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-08-07 14:57:19 +0000 |
---|---|---|
committer | nahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-08-07 14:57:19 +0000 |
commit | 873f007ad3e992809694ad73c98d1bb87e7b362d (patch) | |
tree | 9379fc73172e21abe89a3ee5361792a113c80a12 | |
parent | 0c36fe42a25799eed5a7591c42b03ee48aabee50 (diff) | |
download | ruby-873f007ad3e992809694ad73c98d1bb87e7b362d.tar.gz |
* test/ruby/test_super.rb: added optional arg tests. [ruby-dev:26743]
the tests expects 1.8 behavior at this time.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8941 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | test/ruby/test_super.rb | 29 |
2 files changed, 34 insertions, 0 deletions
@@ -1,3 +1,8 @@ +Sun Aug 7 23:52:39 2005 NAKAMURA, Hiroshi <nakahiro@sarion.co.jp> + + * test/ruby/test_super.rb: added optional arg tests. [ruby-dev:26743] + the tests expects 1.8 behavior at this time. + Sat Aug 6 12:35:24 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp> * ext/tk/lib/{tk.rb,tk/itemconfig.rb}: configure creates diff --git a/test/ruby/test_super.rb b/test/ruby/test_super.rb index df229a8f1a..cf2e241fdd 100644 --- a/test/ruby/test_super.rb +++ b/test/ruby/test_super.rb @@ -5,6 +5,7 @@ class TestSuper < Test::Unit::TestCase def single(a) a end def double(a, b) [a,b] end def array(*a) a end + def optional(a = 0) a end end class Single1 < Base def single(*) super end @@ -33,6 +34,15 @@ class TestSuper < Test::Unit::TestCase class Array4 < Base def array(a,b,c,*) super end end + class Optional1 < Base + def optional(a = 1) super end + end + class Optional2 < Base + def optional(a, b = 1) super end + end + class Optional3 < Base + def single(a = 1) super end + end def test_single1 assert_equal(1, Single1.new.single(1)) @@ -65,6 +75,25 @@ class TestSuper < Test::Unit::TestCase assert_equal([1,2,3], Array4.new.array(1, 2, 3)) assert_equal([1,2,3,4], Array4.new.array(1, 2, 3, 4)) end + def test_optional1 + assert_equal(9, Optional1.new.optional(9)) + assert_equal(1, Optional1.new.optional) + end + def test_optional2 + assert_raise(ArgumentError) do + # call Base#optional with 2 arguments; the 2nd arg is supplied + assert_equal(9, Optional2.new.optional(9)) + end + assert_raise(ArgumentError) do + # call Base#optional with 2 arguments + assert_equal(9, Optional2.new.optional(9, 2)) + end + end + def test_optional3 + assert_equal(9, Optional3.new.single(9)) + # call Base#single with 1 argument; the arg is supplied + assert_equal(1, Optional3.new.single) + end class A def tt(aa) |