summaryrefslogtreecommitdiff
path: root/sample/test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'sample/test.rb')
-rw-r--r--sample/test.rb77
1 files changed, 41 insertions, 36 deletions
diff --git a/sample/test.rb b/sample/test.rb
index 6bbe9ecba0..f8edd3a44a 100644
--- a/sample/test.rb
+++ b/sample/test.rb
@@ -56,27 +56,27 @@ a = *nil; test_ok(a == nil)
a = *1; test_ok(a == 1)
a = *[]; test_ok(a == nil)
a = *[1]; test_ok(a == 1)
-a = *[nil]; test_ok(a == [nil])
-a = *[[]]; test_ok(a == [[]])
+a = *[nil]; test_ok(a == nil)
+a = *[[]]; test_ok(a == [])
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 = 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 = [*[]]; test_ok(a == [])
-*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 = [*[]]; test_ok(a == [[]])
+*a = [*[1]]; test_ok(a == [[1]])
*a = [*[1,2]]; test_ok(a == [1,2])
*a = *nil; test_ok(a == [])
*a = *1; test_ok(a == [1])
*a = *[]; test_ok(a == [])
*a = *[1]; test_ok(a == [1])
-*a = *[nil]; test_ok(a == [nil])
+*a = *[nil]; test_ok(a == [])
*a = *[[]]; test_ok(a == [[]])
*a = *[*[]]; test_ok(a == [])
*a = *[*[1]]; test_ok(a == [1])
@@ -84,12 +84,12 @@ 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 = []; test_ok([a,b,c] == [[], 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, []])
+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, []])
@@ -116,27 +116,27 @@ 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 == nil)}
def f; yield *[1]; end; f {|a| test_ok(a == 1)}
-def f; yield *[nil]; end; f {|a| test_ok(a == [nil])}
-def f; yield *[[]]; 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 == 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 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 == [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 []; 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 == [[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| test_ok(a == [])}
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 == [nil])}
+def f; yield *[nil]; end; f {|*a| test_ok(a == [])}
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])}
@@ -144,12 +144,12 @@ 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 []; end; f {|a,b,*c| test_ok([a,b,c] == [[], 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, []])}
+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, []])}
@@ -637,14 +637,19 @@ class IterTest
def each6; @body.each { |*x| yield(x) } end
def each7; @body.each { |x| yield(*x) } end
def each8; @body.each { |x| yield(x) } end
+
+ def f(a)
+ test_ok(a == [1])
+ end
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]); p $x
+test_ok($x == [2])
IterTest.new([3]).each3 { |x| $x = x }
test_ok($x == 3)
IterTest.new([4]).each4 { |x| $x = x }
@@ -661,17 +666,17 @@ 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)
+test_ok($x == [1])
IterTest.new([[2]]).each2 { |x| $x = x }
-test_ok($x == [2]); p $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]); p $x
+test_ok($x == [4])
IterTest.new([[5]]).each5 { |x| $x = x }
-test_ok($x == 5)
+test_ok($x == [5])
IterTest.new([[6]]).each6 { |x| $x = x }
-test_ok($x == [6])
+test_ok($x == [[6]])
IterTest.new([[7]]).each7 { |x| $x = x }
test_ok($x == 7)
IterTest.new([[8]]).each8 { |x| $x = x }