summaryrefslogtreecommitdiff
path: root/sample/test.rb
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-06-22 09:12:24 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-06-22 09:12:24 +0000
commitdef42c9a0cd274202da56531c19e0a4bee3364e3 (patch)
treeb100f68b08e5f1ae5338055ae798320a4a339e01 /sample/test.rb
parentef8e0b4dffaec6789a1582d841ddb563cac2115d (diff)
* eval.c (rb_yield_0): no mvalue_to_svalue conversion here.
* eval.c (massign): takes svalue, convert it to mvalue inside. * eval.c (rb_eval): parameters for yield/return are always svalues now. * eval.c (svalue_to_mvalue): more strict conversion. * eval.c (mvalue_to_svalue): ditto. * st.c (new_size): prime hash size enabled. * ext/socket/socket.c (Init_socket): SO_* constants added. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1535 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
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 }