summaryrefslogtreecommitdiff
path: root/sample/test.rb
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-06-08 14:20:58 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-06-08 14:20:58 +0000
commit46e8ae110469cc8da8d1aad01dec7cd0a83eaae1 (patch)
treeb226bf0b6becd50f95c027133059e7bf07376bdb /sample/test.rb
parent1b6b6ef2d645e99b66e775c9a5ee97e201e141a1 (diff)
* gc.c (Init_stack): avoid __builtin_frame_address(2) to retrieve
stack bottom line. * st.c (numhash): should shuffle bits by dividing by prime number. * eval.c (rb_eval): multiple assignment behavior fixed, which results "*a = nil" makes "a == []" now. * eval.c (rb_f_require): should set SCOPE_PUBLIC before calling dln_load(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1516 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'sample/test.rb')
-rw-r--r--sample/test.rb122
1 files changed, 121 insertions, 1 deletions
diff --git a/sample/test.rb b/sample/test.rb
index 10ae5e5..ed2ebcf 100644
--- a/sample/test.rb
+++ b/sample/test.rb
@@ -42,6 +42,126 @@ cc = 5
cc &&=44
test_ok(cc == 44)
+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 = [*[]]; test_ok(a == [])
+a = [*[1]]; test_ok(a == [1])
+a = [*[1,2]]; test_ok(a == [1,2])
+
+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 = *[*[]]; 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 = [*[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 == [])
+*a = *[[]]; test_ok(a == [])
+*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, []])
+
+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 == [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 == 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 *[*[]]; 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 [*[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 == [])}
+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, []])}
+
test_check "condition"
$x = '0';
@@ -768,7 +888,7 @@ test_ok(a == [1, 2, 3])
test_ok(a == [4])
*a = nil
-test_ok(a == [nil])
+test_ok(a == [])
test_check "call"
def aaa(a, b=100, *rest)