ruby-changes:41468
From: naruse <ko1@a...>
Date: Fri, 15 Jan 2016 20:05:25 +0900 (JST)
Subject: [ruby-changes:41468] naruse:r53542 (trunk): Revert "* common.mk: test-sample was changed to test-basic."
naruse 2016-01-15 20:05:51 +0900 (Fri, 15 Jan 2016) New Revision: 53542 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=53542 Log: Revert "* common.mk: test-sample was changed to test-basic." This reverts r53537. Fix chkbuild first. Added files: trunk/sample/test.rb trunk/tool/rubytest.rb Removed files: trunk/basictest/runner.rb trunk/basictest/test.rb Modified files: trunk/ChangeLog trunk/common.mk Index: common.mk =================================================================== --- common.mk (revision 53541) +++ common.mk (revision 53542) @@ -581,10 +581,10 @@ no-btest-ruby: PHONY https://github.com/ruby/ruby/blob/trunk/common.mk#L581 yes-btest-ruby: prog PHONY $(Q)$(exec) $(RUNRUBY) "$(srcdir)/bootstraptest/runner.rb" --ruby="$(PROGRAM) -I$(srcdir)/lib $(RUN_OPTS)" -q $(OPTS) $(TESTOPTS) -test-basic: $(TEST_RUNNABLE)-test-basic -no-test-basic: PHONY -yes-test-basic: prog PHONY - $(Q)$(exec) $(RUNRUBY) "$(srcdir)/basictest/runner.rb" --run-opt=$(RUN_OPTS) $(OPTS) $(TESTOPTS) +test-sample: $(TEST_RUNNABLE)-test-sample +no-test-sample: PHONY +yes-test-sample: prog PHONY + $(Q)$(exec) $(RUNRUBY) "$(srcdir)/tool/rubytest.rb" --run-opt=$(RUN_OPTS) $(OPTS) $(TESTOPTS) test-knownbugs: test-knownbug test-knownbug: $(TEST_RUNNABLE)-test-knownbug @@ -597,7 +597,7 @@ yes-test-testframework: prog PHONY https://github.com/ruby/ruby/blob/trunk/common.mk#L597 $(Q)$(exec) $(RUNRUBY) "$(srcdir)/test/runner.rb" --ruby="$(RUNRUBY)" $(TESTOPTS) testunit minitest no-test-testframework: PHONY -test: btest-ruby test-knownbug test-basic +test: test-sample btest-ruby test-knownbug # $ make test-all TESTOPTS="--help" displays more detail # for example, make test-all TESTOPTS="-j2 -v -n test-name -- test-file-name" @@ -663,7 +663,7 @@ $(ENC_MK): $(srcdir)/enc/make_encmake.rb https://github.com/ruby/ruby/blob/trunk/common.mk#L663 .PHONY: clean clean-ext clean-local clean-enc clean-golf clean-rdoc clean-html clean-extout .PHONY: distclean distclean-ext distclean-local distclean-enc distclean-golf distclean-extout .PHONY: realclean realclean-ext realclean-local realclean-enc realclean-golf realclean-extout -.PHONY: check test test-all btest btest-ruby test-basic test-knownbug +.PHONY: check test test-all btest btest-ruby test-sample test-knownbug .PHONY: run runruby parse benchmark benchmark-each tbench gdb gdb-ruby .PHONY: update-mspec update-rubyspec test-rubyspec Index: sample/test.rb =================================================================== --- sample/test.rb (revision 0) +++ sample/test.rb (revision 53542) @@ -0,0 +1,2369 @@ https://github.com/ruby/ruby/blob/trunk/sample/test.rb#L1 +#! /usr/bin/env ruby +# -*- coding: us-ascii -*- + +$testnum=0 +$ntest=0 +$failed = 0 +class Progress + def initialize + @color = nil + @tty = nil + @quiet = nil + @verbose = nil + ARGV.each do |arg| + case arg + when /\A--color(?:=(?:always|(auto)|(never)|(.*)))?\z/ + warn "unknown --color argument: #$3" if $3 + @color = $1 ? nil : !$2 + when /\A--tty(=(?:yes|(no)|(.*)))?\z/ + warn "unknown --tty argument: #$3" if $3 + @tty = !$1 || !$2 + true + when /\A-(q|-quiet)\z/ + @quiet = true + when /\A-(v|-verbose)\z/ + @verbose = true + end + end + @tty = STDERR.tty? && !STDOUT.tty? && /dumb/ !~ ENV["TERM"] if @tty.nil? + @eol = @tty && !@verbose ? "\r\e[K\r" : "\n" + case @color + when nil + @color = @tty + end + if @color + # dircolors-like style + colors = (colors = ENV['TEST_COLORS']) ? Hash[colors.scan(/(\w+)=([^:\n]*)/)] : {} + begin + File.read(File.join(__dir__, "../test/colors")).scan(/(\w+)=([^:\n]*)/) do |n, c| + colors[n] ||= c + end + rescue + end + @passed = "\e[;#{colors["pass"] || "32"}m" + @failed = "\e[;#{colors["fail"] || "31"}m" + @reset = "\e[m" + else + @passed = @failed = @reset = "" + end + extend(Rotator) if @tty + end + + def passed_string + "." + end + def failed_string + "#{@failed}F#{@reset}" + end + def init_string + end + def finish_string + if @quiet + @eol + else + "#{@passed}#{@ok ? 'OK' : ''} #{$testnum}#{@reset}#{@eol}" + end + end + def pass + STDERR.print passed_string + end + def fail + @ok = false + STDERR.print failed_string + end + def init + @ok = true + STDERR.print init_string + end + def finish + STDERR.print finish_string + end + + module Rotator + ROTATOR = %w[- \\ | /] + BS = "\b" * ROTATOR[0].size + def passed_string + "#{BS}#{ROTATOR[(@count += 1) % ROTATOR.size]}" + end + def failed_string + "#{BS}#{super}#{ROTATOR[@count % ROTATOR.size]}" + end + def init_string + @count = 0 + " " + end + def finish_string + s = "#{BS}#{' ' * BS.size}#{BS}#{super}" + s.gsub!(/\n/, "\r\e[2K\r") if @quiet + s + end + end +end +PROGRESS = Progress.new + +def test_check(what) + unless $ntest.zero? + PROGRESS.finish + end + STDERR.print "basictest/test.rb:#{what} " + PROGRESS.init + $what = what + $testnum = 0 +end + +def test_ok(cond,n=1) + $testnum+=1 + $ntest+=1 + where = (st = caller(n)) ? st[0] : "caller error! (n=#{n}, trace=#{caller(0).join(', ')}" + if cond + PROGRESS.pass + printf "ok %d (%s)\n", $testnum, where + else + PROGRESS.fail + printf "not ok %s %d -- %s\n", $what, $testnum, where + $failed+=1 + end + STDOUT.flush + STDERR.flush +end + +# make sure conditional operators work + +test_check "assignment" + +a=[]; a[0] ||= "bar"; +test_ok(a[0] == "bar") +h={}; h["foo"] ||= "bar"; +test_ok(h["foo"] == "bar") + +aa = 5 +aa ||= 25 +test_ok(aa == 5) +bb ||= 25 +test_ok(bb == 25) +cc &&=33 +test_ok(cc == nil) +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 = [1,2]; test_ok(a == [1,2]) +a = [*[]]; test_ok(a == []) +a = [*[1]]; test_ok(a == [1]) +a = [*[1,2]]; test_ok(a == [1,2]) + +a = *[]; test_ok(a == []) +a = *[1]; test_ok(a == [1]) +a = *[nil]; test_ok(a == [nil]) +a = *[[]]; test_ok(a == [[]]) +a = *[1,2]; test_ok(a == [1,2]) +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, = 1,2; test_ok(a == 1) +a, = [1,2]; test_ok(a == 1) +a, = [*[]]; test_ok(a == nil) +a, = [*[1]]; test_ok(a == 1) +a, = *[1,2]; test_ok(a == 1) +a, = [*[1,2]]; 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, = *[1,2]; test_ok(a == 1) +a, = *[*[]]; test_ok(a == nil) +a, = *[*[1]]; test_ok(a == 1) +a, = *[*[1,2]]; test_ok(a == 1) + +*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 = [1,2]; test_ok(a == [1,2]) +*a = [*[]]; test_ok(a == []) +*a = [*[1]]; test_ok(a == [1]) +*a = [*[1,2]]; test_ok(a == [1,2]) + +*a = *[]; test_ok(a == []) +*a = *[1]; test_ok(a == [1]) +*a = *[nil]; test_ok(a == [nil]) +*a = *[[]]; test_ok(a == [[]]) +*a = *[1,2]; test_ok(a == [1,2]) +*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 = [1,2]; test_ok([a,b,c] == [1,2,[]]) +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 = *[]; 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 = *[1,2]; test_ok([a,b,c] == [1,2,[]]) +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 *[]; 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)} + +def f; yield; end; f {|a,| test_ok(a == nil)} +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)} + +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 == nil)} +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)} + +def f; yield; end; f {|*a| test_ok(a == [])} +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 [1,2]; end; f {|*a| test_ok(a == [[1,2]])} +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 *[]; 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; end; f {|a,b,*c| test_ok([a,b,c] == [nil,nil,[]])} +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 *[]; 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,[]])} + +def r; return; end; a = r(); test_ok(a == nil) +def r; return nil; end; a = r(); test_ok(a == nil) +def r; return 1; end; a = r(); test_ok(a == 1) +def r; return []; end; a = r(); test_ok(a == []) +def r; return [1]; end; a = r(); test_ok(a == [1]) +def r; return [nil]; end; a = r(); test_ok(a == [nil]) +def r; return [[]]; end; a = r(); test_ok(a == [[]]) +def r; return [*[]]; end; a = r(); test_ok(a == []) +def r; return [*[1]]; end; a = r(); test_ok(a == [1]) +def r; return [*[1,2]]; end; a = r(); test_ok(a == [1,2]) + +def r; return *[]; end; a = r(); test_ok(a == []) +def r; return *[1]; end; a = r(); test_ok(a == [1]) +def r; return *[nil]; end; a = r(); test_ok(a == [nil]) +def r; return *[[]]; end; a = r(); test_ok(a == [[]]) +def r; return *[*[]]; end; a = r(); test_ok(a == []) +def r; return *[*[1]]; end; a = r(); test_ok(a == [1]) +def r; return *[*[1,2]]; end; a = r(); test_ok(a == [1,2]) + +def r; return *[[]]; end; a = *r(); test_ok(a == [[]]) +def r; return *[*[1,2]]; end; a = *r(); test_ok(a == [1,2]) + +def r; return; end; *a = r(); test_ok(a == [nil]) +def r; return nil; end; *a = r(); test_ok(a == [nil]) +def r; return 1; end; *a = r(); test_ok(a == [1]) +def r; return []; end; *a = r(); test_ok(a == []) +def r; return [1]; end; *a = r(); test_ok(a == [1]) +def r; return [nil]; end; *a = r(); test_ok(a == [nil]) +def r; return [[]]; end; *a = r(); test_ok(a == [[]]) +def r; return [1,2]; end; *a = r(); test_ok(a == [1,2]) +def r; return [*[]]; end; *a = r(); test_ok(a == []) +def r; return [*[1]]; end; *a = r(); test_ok(a == [1]) +def r; return [*[1,2]]; end; *a = r(); test_ok(a == [1,2]) + +def r; return *[]; end; *a = r(); test_ok(a == []) +def r; return *[1]; end; *a = r(); test_ok(a == [1]) +def r; return *[nil]; end; *a = r(); test_ok(a == [nil]) +def r; return *[[]]; end; *a = r(); test_ok(a == [[]]) +def r; return *[1,2]; end; *a = r(); test_ok(a == [1,2]) +def r; return *[*[]]; end; *a = r(); test_ok(a == []) +def r; return *[*[1]]; end; *a = r(); test_ok(a == [1]) +def r; return *[*[1,2]]; end; *a = r(); test_ok(a == [1,2]) + +def r; return *[[]]; end; *a = *r(); test_ok(a == [[]]) +def r; return *[1,2]; end; *a = *r(); test_ok(a == [1,2]) +def r; return *[*[1,2]]; end; *a = *r(); test_ok(a == [1,2]) + +def r; return; end; a,b,*c = r(); test_ok([a,b,c] == [nil,nil,[]]) +def r; return nil; end; a,b,*c = r(); test_ok([a,b,c] == [nil,nil,[]]) +def r; return 1; end; a,b,*c = r(); test_ok([a,b,c] == [1,nil,[]]) +def r; return []; end; a,b,*c = r(); test_ok([a,b,c] == [nil,nil,[]]) +def r; return [1]; end; a,b,*c = r(); test_ok([a,b,c] == [1,nil,[]]) +def r; return [nil]; end; a,b,*c = r(); test_ok([a,b,c] == [nil,nil,[]]) +def r; return [[]]; end; a,b,*c = r(); test_ok([a,b,c] == [[],nil,[]]) +def r; return [1,2]; end; a,b,*c = r(); test_ok([a,b,c] == [1,2,[]]) +def r; return [*[]]; end; a,b,*c = r(); test_ok([a,b,c] == [nil,nil,[]]) +def r; return [*[1]]; end; a,b,*c = r(); test_ok([a,b,c] == [1,nil,[]]) +def r; return [*[1,2]]; end; a,b,*c = r(); test_ok([a,b,c] == [1,2,[]]) + +def r; return *[]; end; a,b,*c = r(); test_ok([a,b,c] == [nil,nil,[]]) +def r; return *[1]; end; a,b,*c = r(); test_ok([a,b,c] == [1,nil,[]]) +def r; return *[nil]; end; a,b,*c = r(); test_ok([a,b,c] == [nil,nil,[]]) +def r; return *[[]]; end; a,b,*c = r(); test_ok([a,b,c] == [[],nil,[]]) +def r; return *[1,2]; end; a,b,*c = r(); test_ok([a,b,c] == [1,2,[]]) +def r; return *[*[]]; end; a,b,*c = r(); test_ok([a,b,c] == [nil,nil,[]]) +def r; return *[*[1]]; end; a,b,*c = r(); test_ok([a,b,c] == [1,nil,[]]) +def r; return *[*[1,2]]; end; a,b,*c = r(); test_ok([a,b,c] == [1,2,[]]) + +f = lambda {|r,| test_ok([] == r)} +f.call([], *[]) + +f = lambda {|r,*l| test_ok([] == r); test_ok([1] == l)} +f.call([], *[1]) + +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]) + +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 { |a, b=42, *c| [a,b,c] } +test_ok(f.call(1 ) == [1,42,[ ]] ) +test_ok(f.call(1,43 ) == [1,43,[ ]] ) +test_ok(f.call(1,43,44) == [1,43,[44]] ) + +f = lambda { |a, b=(a|16), *c, &block| [a,b,c,block&&block[]] } +test_ok(f.call(8 ) == [8,24,[ ],nil] ) +test_ok(f.call(8,43 ) == [8,43,[ ],nil] ) +test_ok(f.call(8,43,44) == [8,43,[44],nil] ) +test_ok(f.call(8 ){45} == [8,24,[ ],45 ] ) +test_ok(f.call(8,43 ){45} == [8,43,[ ],45 ] ) +test_ok(f.call(8,43,44){45} == [8,43,[44],45 ] ) + +f = lambda { |a, b=42, *c, d| [a,b,c,d] } +test_ok(f.call(1 ,99) == [1,42,[ ],99] ) +test_ok(f.call(1,43 ,99) == [1,43,[ ],99] ) +test_ok(f.call(1,43,44,99) == [1,43,[44],99] ) + +f = lambda { |a, b=(a|16), &block| [a,b,block&&block[]] } +test_ok(f.call(8 ) == [8,24,nil] ) +test_ok(f.call(8,43) == [8,43,nil] ) +test_ok(f.call(8,43) == [8,43,nil] ) +test_ok(f.call(8 ){45} == [8,24,45 ] ) +test_ok(f.call(8,43){45} == [8,43,45 ] ) +test_ok(f.call(8,43){45} == [8,43,45 ] ) + +f = lambda { |a, b=42, d| [a,b,d] } +test_ok(f.call(1 ,99) == [1,42,99] ) +test_ok(f.call(1,43,99) == [1,43,99] ) +test_ok(f.call(1,43,99) == [1,43,99] ) + +f = lambda { |b=42, *c, &block| [b,c,block&&block[]] } +test_ok(f.call( ) == [42,[ ],nil] ) +test_ok(f.call(43 ) == [43,[ ],nil] ) +test_ok(f.call(43,44) == [43,[44],nil] ) +test_ok(f.call( ){45} == [42,[ ],45 ] ) +test_ok(f.call(43 ){45} == [43,[ ],45 ] ) +test_ok(f.call(43,44){45} == [43,[44],45 ] ) + +f = lambda { |b=42, *c, d| [b,c,d] } +test_ok(f.call( 99) == [42,[ ],99] ) +test_ok(f.call(43 ,99) == [43,[ ],99] ) +test_ok(f.call(43,44,99) == [43,[44],99] ) + +f = lambda { |b=42, &block| [b,block&&block[]] } +test_ok(f.call( ) == [42,nil] ) +test_ok(f.call(43) == [43,nil] ) +test_ok(f.call(43) == [43,nil] ) +test_ok(f.call( ){45} == [42,45 ] ) +test_ok(f.call(43){45} == [43,45 ] ) +test_ok(f.call(43){45} == [43,45 ] ) + +f = lambda { |b=42, d| [b,d] } +test_ok(f.call( 99) == [42,99] ) +test_ok(f.call(43,99) == [43,99] ) +test_ok(f.call(43,99) == [43,99] ) + + +a,=*[1] +test_ok(a == 1) +a,=*[[1]] +test_ok(a == [1]) +a,=*[[[1]]] +test_ok(a == [[1]]) + +x, (y, z) = 1, 2, 3 +test_ok([1,2,nil] == [x,y,z]) +x, (y, z) = 1, [2,3] +test_ok([1,2,3] == [x,y,z]) +x, (y, z) = 1, [2] +test_ok([1,2,nil] == [x,y,z]) + +a = loop do break; end; test_ok(a == nil) +a = loop do break nil; end; test_ok(a == nil) +a = loop do break 1; end; test_ok(a == 1) +a = loop do break []; end; test_ok(a == []) +a = loop do break [1]; end; test_ok(a == [1]) +a = loop do break [nil]; end; test_ok(a == [nil]) +a = loop do break [[]]; end; test_ok(a == [[]]) +a = loop do break [*[]]; end; test_ok(a == []) +a = loop do break [*[1]]; end; test_ok(a == [1]) +a = loop do break [*[1,2]]; end; test_ok(a == [1,2]) + +a = loop do break *[]; end; test_ok(a == []) +a = loop do break *[1]; end; test_ok(a == [1]) +a = loop do break *[nil]; end; test_ok(a == [nil]) +a = loop do break *[[]]; end; test_ok(a == [[]]) +a = loop do break *[*[]]; end; test_ok(a == []) +a = loop do break *[*[1]]; end; test_ok(a == [1]) +a = loop do break *[*[1,2]]; end; test_ok(a == [1,2]) + +*a = loop do break; end; test_ok(a == [nil]) +*a = loop do break nil; end; test_ok(a == [nil]) +*a = loop do break 1; end; test_ok(a == [1]) +*a = loop do break []; end; test_ok(a == []) +*a = loop do break [1]; end; test_ok(a == [1]) +*a = loop do break [nil]; end; test_ok(a == [nil]) +*a = loop do break [[]]; end; test_ok(a == [[]]) +*a = loop do break [1,2]; end; test_ok(a == [1,2]) +*a = loop do break [*[]]; end; test_ok(a == []) +*a = loop do break [*[1]]; end; test_ok(a == [1]) +*a = loop do break [*[1,2]]; end; test_ok(a == [1,2]) + +*a = loop do break *[]; end; test_ok(a == []) +*a = loop do break *[1 (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/