summaryrefslogtreecommitdiff
path: root/sample
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-03-26 07:01:14 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-03-26 07:01:14 +0000
commite9b5878c4168ec6b5ed5129d897ee9be7636ca71 (patch)
tree9229296296e4a89f45b3d416b30559ee75768d44 /sample
parent8478ba513fd23c72b99790144be4fa17ebef3b35 (diff)
* eval.c (avalue_splat): new function to do unary * (splat)
operator. * eval.c (avalue_to_svalue,svalue_to_avalue,svalue_to_mrhs): do not use implicit "to_ary" conversion. * ext/curses/curses.c (GetWINDOW,GetMOUSE): add taint check. * ext/curses/curses.c (curses_init_screen): ditto. * ext/curses/curses.c (window_initialize): ditto. * gc.c (os_each_obj): prohibit ObjectSpace#each_object in safe mode ($SAFE >= 4). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3616 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'sample')
-rw-r--r--sample/test.rb34
1 files changed, 28 insertions, 6 deletions
diff --git a/sample/test.rb b/sample/test.rb
index fb7c0f6..5c26309 100644
--- a/sample/test.rb
+++ b/sample/test.rb
@@ -248,13 +248,33 @@ f = lambda {|r,*l| test_ok([] == r); test_ok([1] == l)}
f.call([], *[1])
f.yield([], *[1])
-a = [42,55]
-lambda{|x| test_ok([42,55] == x)}.call(a)
-lambda{|x,| test_ok([42,55] == x)}.call(a)
-lambda{|*x| test_ok([[42,55]] == x)}.call(a)
+
+f = lambda{|x| x}
+test_ok(f.call(42) == 42)
+test_ok(f.call([42]) == [42])
+test_ok(f.call([[42]]) == [[42]])
+test_ok(f.call([42,55]) == [42,55])
+test_ok(f.call(42,55) == [42,55])
+
+f = lambda{|x,| x}
+test_ok(f.call(42) == 42)
+test_ok(f.call([42]) == [42])
+test_ok(f.call([[42]]) == [[42]])
+test_ok(f.call([42,55]) == [42,55])
+
+f = lambda{|*x| x}
+test_ok(f.call(42) == [42])
+test_ok(f.call([42]) == [[42]])
+test_ok(f.call([[42]]) == [[[42]]])
+test_ok(f.call([42,55]) == [[42,55]])
+test_ok(f.call(42,55) == [42,55])
a,=*[1]
test_ok(a == 1)
+a,=*[[1]]
+test_ok(a == 1)
+a,=*[[[1]]]
+test_ok(a == [1])
a = loop do break; end; test_ok(a == nil)
a = loop do break nil; end; test_ok(a == nil)
@@ -905,10 +925,12 @@ class IterTest
def each8; @body.each {|x| yield(x) } end
def f(a)
- test_ok(a == [1])
+ a
end
end
-IterTest.new(nil).method(:f).to_proc.call([1])
+test_ok(IterTest.new(nil).method(:f).to_proc.call([1]) == [1])
+m = /\w+/.match("abc")
+test_ok(IterTest.new(nil).method(:f).to_proc.call([m]) == [m])
IterTest.new([0]).each0 {|x| test_ok(x == 0)}
IterTest.new([1]).each1 {|x| test_ok(x == 1)}