diff options
| author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-03-26 07:01:14 +0000 |
|---|---|---|
| committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-03-26 07:01:14 +0000 |
| commit | 5e9a18ee5bb25078e11076f9dba96c9b3b0a06e6 (patch) | |
| tree | 9229296296e4a89f45b3d416b30559ee75768d44 /sample | |
| parent | 0a2587fa909c7db8974e0c39e1ee4d7ab544b9c9 (diff) | |
| download | ruby-5e9a18ee5bb25078e11076f9dba96c9b3b0a06e6.tar.gz ruby-5e9a18ee5bb25078e11076f9dba96c9b3b0a06e6.tar.xz ruby-5e9a18ee5bb25078e11076f9dba96c9b3b0a06e6.zip | |
* 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: http://svn.ruby-lang.org/repos/ruby/trunk@3616 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'sample')
| -rw-r--r-- | sample/test.rb | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/sample/test.rb b/sample/test.rb index fb7c0f675..5c263090d 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)} |
