summaryrefslogtreecommitdiff
path: root/sample
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-01-01 03:24:29 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-01-01 03:24:29 +0000
commit0082edfd3d4c0288cf8464fac54d7655db5a29ca (patch)
tree34a346b3f856bb042d524cc0e8b943f87d55f105 /sample
parent2a54402839534bff1bebbf0feb2e53298819aee9 (diff)
* eval.c (massign): removed awkward conversion between yvalue,
mvalue, etc. * eval.c (rb_yield_0): new parameter added to tell whether val is an array value or not. * parse.y (yield_args): restructuring: new nodes: NODE_RESTARY2, NODE_SVALUE; removed node: NODE_RESTARGS. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3269 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'sample')
-rw-r--r--sample/test.rb165
1 files changed, 77 insertions, 88 deletions
diff --git a/sample/test.rb b/sample/test.rb
index b16d777..f8a3eb4 100644
--- a/sample/test.rb
+++ b/sample/test.rb
@@ -48,6 +48,7 @@ a = []; test_ok(a == [])
a = [1]; test_ok(a == [1])
a = [nil]; test_ok(a == [nil])
a = [[]]; test_ok(a == [[]])
+a = [1,2]; test_ok(a == [1,2])
a = [*[]]; test_ok(a == [])
a = [*[1]]; test_ok(a == [1])
a = [*[1,2]]; test_ok(a == [1,2])
@@ -58,50 +59,56 @@ a = *[]; test_ok(a == nil)
a = *[1]; test_ok(a == 1)
a = *[nil]; test_ok(a == nil)
a = *[[]]; test_ok(a == [])
+a = *[1,2]; test_ok(a == [1,2])
a = *[*[]]; test_ok(a == nil)
a = *[*[1]]; test_ok(a == 1)
a = *[*[1,2]]; test_ok(a == [1,2])
-*a = nil; test_ok(a == [])
+*a = nil; test_ok(a == [nil])
*a = 1; test_ok(a == [1])
*a = []; test_ok(a == [])
*a = [1]; test_ok(a == [1])
*a = [nil]; test_ok(a == [nil])
*a = [[]]; test_ok(a == [[]])
+*a = [1,2]; test_ok(a == [1,2])
*a = [*[]]; test_ok(a == [])
*a = [*[1]]; test_ok(a == [1])
*a = [*[1,2]]; test_ok(a == [1,2])
-*a = *nil; test_ok(a == [])
+*a = *nil; test_ok(a == [nil])
*a = *1; test_ok(a == [1])
*a = *[]; test_ok(a == [])
*a = *[1]; test_ok(a == [1])
-*a = *[nil]; test_ok(a == [])
+*a = *[nil]; test_ok(a == [nil])
*a = *[[]]; test_ok(a == [])
+*a = *[1,2]; test_ok(a == [1,2])
*a = *[*[]]; test_ok(a == [])
*a = *[*[1]]; test_ok(a == [1])
*a = *[*[1,2]]; test_ok(a == [1,2])
-a,b,*c = nil; test_ok([a,b,c] == [nil, nil, []])
-a,b,*c = 1; test_ok([a,b,c] == [1, nil, []])
-a,b,*c = []; test_ok([a,b,c] == [nil, nil, []])
-a,b,*c = [1]; test_ok([a,b,c] == [1, nil, []])
-a,b,*c = [nil]; test_ok([a,b,c] == [nil, nil, []])
-a,b,*c = [[]]; test_ok([a,b,c] == [[], nil, []])
-a,b,*c = [*[]]; test_ok([a,b,c] == [nil, nil, []])
-a,b,*c = [*[1]]; test_ok([a,b,c] == [1, nil, []])
-a,b,*c = [*[1,2]]; test_ok([a,b,c] == [1, 2, []])
-
-a,b,*c = *nil; test_ok([a,b,c] == [nil, nil, []])
-a,b,*c = *1; test_ok([a,b,c] == [1, nil, []])
-a,b,*c = *[]; test_ok([a,b,c] == [nil, nil, []])
-a,b,*c = *[1]; test_ok([a,b,c] == [1, nil, []])
-a,b,*c = *[nil]; test_ok([a,b,c] == [nil, nil, []])
-a,b,*c = *[[]]; test_ok([a,b,c] == [nil, nil, []])
-a,b,*c = *[*[]]; test_ok([a,b,c] == [nil, nil, []])
-a,b,*c = *[*[1]]; test_ok([a,b,c] == [1, nil, []])
-a,b,*c = *[*[1,2]]; test_ok([a,b,c] == [1, 2, []])
-
+a,b,*c = nil; test_ok([a,b,c] == [nil,nil,[]])
+a,b,*c = 1; test_ok([a,b,c] == [1,nil,[]])
+a,b,*c = []; test_ok([a,b,c] == [nil,nil,[]])
+a,b,*c = [1]; test_ok([a,b,c] == [1,nil,[]])
+a,b,*c = [nil]; test_ok([a,b,c] == [nil,nil,[]])
+a,b,*c = [[]]; test_ok([a,b,c] == [[],nil,[]])
+a,b,*c = [1,2]; test_ok([a,b,c] == [1,2,[]])
+a,b,*c = [*[]]; test_ok([a,b,c] == [nil,nil,[]])
+a,b,*c = [*[1]]; test_ok([a,b,c] == [1,nil,[]])
+a,b,*c = [*[1,2]]; test_ok([a,b,c] == [1,2,[]])
+
+a,b,*c = *nil; test_ok([a,b,c] == [nil,nil,[]])
+a,b,*c = *1; test_ok([a,b,c] == [1,nil,[]])
+a,b,*c = *[]; test_ok([a,b,c] == [nil,nil,[]])
+a,b,*c = *[1]; test_ok([a,b,c] == [1,nil,[]])
+a,b,*c = *[nil]; test_ok([a,b,c] == [nil,nil,[]])
+a,b,*c = *[[]]; test_ok([a,b,c] == [nil,nil,[]])
+a,b,*c = *[1,2]; test_ok([a,b,c] == [1,2,[]])
+a,b,*c = *[*[]]; test_ok([a,b,c] == [nil,nil,[]])
+a,b,*c = *[*[1]]; test_ok([a,b,c] == [1,nil,[]])
+a,b,*c = *[*[1,2]]; test_ok([a,b,c] == [1,2,[]])
+
+def f; yield; end; f {|a| test_ok(a == nil)}
def f; yield nil; end; f {|a| test_ok(a == nil)}
def f; yield 1; end; f {|a| test_ok(a == 1)}
def f; yield []; end; f {|a| test_ok(a == [])}
@@ -122,7 +129,8 @@ def f; yield *[*[]]; end; f {|a| test_ok(a == nil)}
def f; yield *[*[1]]; end; f {|a| test_ok(a == 1)}
def f; yield *[*[1,2]]; end; f {|a| test_ok(a == [1,2])}
-def f; yield nil; end; f {|*a| test_ok(a == [])}
+def f; yield; end; f {|*a| test_ok(a == [])}
+def f; yield nil; end; f {|*a| test_ok(a == [nil])}
def f; yield 1; end; f {|*a| test_ok(a == [1])}
def f; yield []; end; f {|*a| test_ok(a == [])}
def f; yield [1]; end; f {|*a| test_ok(a == [1])}
@@ -132,35 +140,36 @@ def f; yield [*[]]; end; f {|*a| test_ok(a == [])}
def f; yield [*[1]]; end; f {|*a| test_ok(a == [1])}
def f; yield [*[1,2]]; end; f {|*a| test_ok(a == [1,2])}
-def f; yield *nil; end; f {|*a| test_ok(a == [])}
+def f; yield *nil; end; f {|*a| test_ok(a == [nil])}
def f; yield *1; end; f {|*a| test_ok(a == [1])}
def f; yield *[]; end; f {|*a| test_ok(a == [])}
def f; yield *[1]; end; f {|*a| test_ok(a == [1])}
-def f; yield *[nil]; end; f {|*a| test_ok(a == [])}
+def f; yield *[nil]; end; f {|*a| test_ok(a == [nil])}
def f; yield *[[]]; end; f {|*a| test_ok(a == [])}
def f; yield *[*[]]; end; f {|*a| test_ok(a == [])}
def f; yield *[*[1]]; end; f {|*a| test_ok(a == [1])}
def f; yield *[*[1,2]]; end; f {|*a| test_ok(a == [1,2])}
-def f; yield nil; end; f {|a,b,*c| test_ok([a,b,c] == [nil, nil, []])}
-def f; yield 1; end; f {|a,b,*c| test_ok([a,b,c] == [1, nil, []])}
-def f; yield []; end; f {|a,b,*c| test_ok([a,b,c] == [nil, nil, []])}
-def f; yield [1]; end; f {|a,b,*c| test_ok([a,b,c] == [1, nil, []])}
-def f; yield [nil]; end; f {|a,b,*c| test_ok([a,b,c] == [nil, nil, []])}
-def f; yield [[]]; end; f {|a,b,*c| test_ok([a,b,c] == [[], nil, []])}
-def f; yield [*[]]; end; f {|a,b,*c| test_ok([a,b,c] == [nil, nil, []])}
-def f; yield [*[1]]; end; f {|a,b,*c| test_ok([a,b,c] == [1, nil, []])}
-def f; yield [*[1,2]]; end; f {|a,b,*c| test_ok([a,b,c] == [1, 2, []])}
-
-def f; yield *nil; end; f {|a,b,*c| test_ok([a,b,c] == [nil, nil, []])}
-def f; yield *1; end; f {|a,b,*c| test_ok([a,b,c] == [1, nil, []])}
-def f; yield *[]; end; f {|a,b,*c| test_ok([a,b,c] == [nil, nil, []])}
-def f; yield *[1]; end; f {|a,b,*c| test_ok([a,b,c] == [1, nil, []])}
-def f; yield *[nil]; end; f {|a,b,*c| test_ok([a,b,c] == [nil, nil, []])}
-def f; yield *[[]]; end; f {|a,b,*c| test_ok([a,b,c] == [nil, nil, []])}
-def f; yield *[*[]]; end; f {|a,b,*c| test_ok([a,b,c] == [nil, nil, []])}
-def f; yield *[*[1]]; end; f {|a,b,*c| test_ok([a,b,c] == [1, nil, []])}
-def f; yield *[*[1,2]]; end; f {|a,b,*c| test_ok([a,b,c] == [1, 2, []])}
+def f; yield; end; f {|a,b,*c| test_ok([a,b,c] == [nil,nil,[]])}
+def f; yield nil; end; f {|a,b,*c| test_ok([a,b,c] == [nil,nil,[]])}
+def f; yield 1; end; f {|a,b,*c| test_ok([a,b,c] == [1,nil,[]])}
+def f; yield []; end; f {|a,b,*c| test_ok([a,b,c] == [nil,nil,[]])}
+def f; yield [1]; end; f {|a,b,*c| test_ok([a,b,c] == [1,nil,[]])}
+def f; yield [nil]; end; f {|a,b,*c| test_ok([a,b,c] == [nil,nil,[]])}
+def f; yield [[]]; end; f {|a,b,*c| test_ok([a,b,c] == [[],nil,[]])}
+def f; yield [*[]]; end; f {|a,b,*c| test_ok([a,b,c] == [nil,nil,[]])}
+def f; yield [*[1]]; end; f {|a,b,*c| test_ok([a,b,c] == [1,nil,[]])}
+def f; yield [*[1,2]]; end; f {|a,b,*c| test_ok([a,b,c] == [1,2,[]])}
+
+def f; yield *nil; end; f {|a,b,*c| test_ok([a,b,c] == [nil,nil,[]])}
+def f; yield *1; end; f {|a,b,*c| test_ok([a,b,c] == [1,nil,[]])}
+def f; yield *[]; end; f {|a,b,*c| test_ok([a,b,c] == [nil,nil,[]])}
+def f; yield *[1]; end; f {|a,b,*c| test_ok([a,b,c] == [1,nil,[]])}
+def f; yield *[nil]; end; f {|a,b,*c| test_ok([a,b,c] == [nil,nil,[]])}
+def f; yield *[[]]; end; f {|a,b,*c| test_ok([a,b,c] == [nil,nil,[]])}
+def f; yield *[*[]]; end; f {|a,b,*c| test_ok([a,b,c] == [nil,nil,[]])}
+def f; yield *[*[1]]; end; f {|a,b,*c| test_ok([a,b,c] == [1,nil,[]])}
+def f; yield *[*[1,2]]; end; f {|a,b,*c| test_ok([a,b,c] == [1,2,[]])}
test_check "condition"
@@ -679,48 +688,28 @@ class IterTest
end
IterTest.new(nil).method(:f).to_proc.call([1])
-IterTest.new([0]).each0 { |x| $x = x }
-test_ok($x == 0)
-IterTest.new([1]).each1 { |x| $x = x }
-test_ok($x == 1)
-IterTest.new([2]).each2 { |x| $x = x }
-test_ok($x == [2])
-IterTest.new([3]).each3 { |x| $x = x }
-test_ok($x == 3)
-IterTest.new([4]).each4 { |x| $x = x }
-test_ok($x == 4)
-IterTest.new([5]).each5 { |x| $x = x }
-test_ok($x == 5)
-IterTest.new([6]).each6 { |x| $x = x }
-test_ok($x == [6])
-IterTest.new([7]).each7 { |x| $x = x }
-test_ok($x == 7)
-IterTest.new([8]).each8 { |x| $x = x }
-test_ok($x == 8)
-
-IterTest.new([[0]]).each0 { |x| $x = x }
-test_ok($x == [0])
-IterTest.new([[1]]).each1 { |x| $x = x }
-test_ok($x == 1)
-IterTest.new([[2]]).each2 { |x| $x = x }
-test_ok($x == [2])
-IterTest.new([[3]]).each3 { |x| $x = x }
-test_ok($x == 3)
-IterTest.new([[4]]).each4 { |x| $x = x }
-test_ok($x == [4])
-IterTest.new([[5]]).each5 { |x| $x = x }
-test_ok($x == 5)
-IterTest.new([[6]]).each6 { |x| $x = x }
-test_ok($x == [6])
-IterTest.new([[7]]).each7 { |x| $x = x }
-test_ok($x == 7)
-IterTest.new([[8]]).each8 { |x| $x = x }
-test_ok($x == [8])
-
-IterTest.new([[0,0]]).each0 { |x| $x = x }
-test_ok($x == [0,0])
-IterTest.new([[8,8]]).each8 { |x| $x = x }
-test_ok($x == [8,8])
+IterTest.new([0]).each0 { |x| test_ok(x == 0)}
+IterTest.new([1]).each1 { |x| test_ok(x == 1)}
+IterTest.new([2]).each2 { |x| test_ok(x == [2])}
+IterTest.new([3]).each3 { |x| test_ok(x == 3)}
+IterTest.new([4]).each4 { |x| test_ok(x == 4)}
+IterTest.new([5]).each5 { |x| test_ok(x == 5)}
+IterTest.new([6]).each6 { |x| test_ok(x == [6])}
+IterTest.new([7]).each7 { |x| test_ok(x == 7)}
+IterTest.new([8]).each8 { |x| test_ok(x == 8)}
+
+IterTest.new([[0]]).each0 { |x| test_ok(x == [0])}
+IterTest.new([[1]]).each1 { |x| test_ok(x == 1)}
+IterTest.new([[2]]).each2 { |x| test_ok(x == [2])}
+IterTest.new([[3]]).each3 { |x| test_ok(x == 3)}
+IterTest.new([[4]]).each4 { |x| test_ok(x == [4])}
+IterTest.new([[5]]).each5 { |x| test_ok(x == 5)}
+IterTest.new([[6]]).each6 { |x| test_ok(x == [6])}
+IterTest.new([[7]]).each7 { |x| test_ok(x == 7)}
+IterTest.new([[8]]).each8 { |x| test_ok(x == [8])}
+
+IterTest.new([[0,0]]).each0 { |x| test_ok(x == [0,0])}
+IterTest.new([[8,8]]).each8 { |x| test_ok(x == [8,8])}
test_check "float"
test_ok(2.6.floor == 2)
@@ -948,7 +937,7 @@ test_ok(a == [1, 2, 3])
test_ok(a == [4])
*a = nil
-test_ok(a == [])
+test_ok(a == [nil])
test_check "call"
def aaa(a, b=100, *rest)