From caa535286d7442ddcbc1caf9fb2778efd435c56d Mon Sep 17 00:00:00 2001 From: ko1 Date: Wed, 27 Jun 2007 16:26:31 +0000 Subject: * bootstraptest/runner.rb: fix to show file name. * bootstraptest/test_*.rb: add bootstarp tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12639 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- bootstraptest/runner.rb | 2 + bootstraptest/test_block.rb | 337 ++++++++++++++++++++++++++ bootstraptest/test_eval.rb | 190 +++++++++++++++ bootstraptest/test_exception.rb | 370 ++++++++++++++++++++++++++++ bootstraptest/test_flow.rb | 491 +++++++++++++++++++++++++++++++++++++ bootstraptest/test_jump.rb | 232 ++++++++++++++++++ bootstraptest/test_proc.rb | 255 +++++++++++++++++++ bootstraptest/test_syntax.rb | 525 ++++++++++++++++++++++++++++++++++++++++ bootstraptest/test_thread.rb | 171 +++++++++++++ 9 files changed, 2573 insertions(+) create mode 100644 bootstraptest/test_block.rb create mode 100644 bootstraptest/test_eval.rb create mode 100644 bootstraptest/test_exception.rb create mode 100644 bootstraptest/test_flow.rb create mode 100644 bootstraptest/test_jump.rb create mode 100644 bootstraptest/test_proc.rb create mode 100644 bootstraptest/test_syntax.rb create mode 100644 bootstraptest/test_thread.rb (limited to 'bootstraptest') diff --git a/bootstraptest/runner.rb b/bootstraptest/runner.rb index 2858aa9ac3..b7db34ecd5 100644 --- a/bootstraptest/runner.rb +++ b/bootstraptest/runner.rb @@ -66,6 +66,8 @@ def exec_test(pathes) @errbuf = [] @location = nil pathes.each do |path| + puts + puts File.basename(path) load File.expand_path(path) end $stderr.puts diff --git a/bootstraptest/test_block.rb b/bootstraptest/test_block.rb new file mode 100644 index 0000000000..e20f5937d7 --- /dev/null +++ b/bootstraptest/test_block.rb @@ -0,0 +1,337 @@ +assert_equal %q{1}, %q{ + 1.times{ + begin + a = 1 + ensure + foo = nil + end + } +} +assert_equal %q{2}, %q{ + [1,2,3].find{|x| x == 2} +} +assert_equal %q{2}, %q{ + class E + include Enumerable + def each(&block) + [1, 2, 3].each(&block) + end + end + E.new.find {|x| x == 2 } +} +assert_equal %q{6}, %q{ + sum = 0 + for x in [1, 2, 3] + sum += x + end + sum +} +assert_equal %q{15}, %q{ + sum = 0 + for x in (1..5) + sum += x + end + sum +} +assert_equal %q{0}, %q{ + sum = 0 + for x in [] + sum += x + end + sum +} +assert_equal %q{1}, %q{ + ans = [] + 1.times{ + for n in 1..3 + a = n + ans << a + end + } +} +assert_equal %q{1..3}, %q{ + ans = [] + for m in 1..3 + for n in 1..3 + a = [m, n] + ans << a + end + end +} +assert_equal %q{[1, 2, 3]}, %q{ + (1..3).to_a +} +assert_equal %q{[4, 8, 12]}, %q{ + (1..3).map{|e| + e * 4 + } +} +assert_equal %q{[1, 2, 3]}, %q{ + class C + include Enumerable + def each + [1,2,3].each{|e| + yield e + } + end + end + + C.new.to_a +} +assert_equal %q{[4, 5, 6]}, %q{ + class C + include Enumerable + def each + [1,2,3].each{|e| + yield e + } + end + end + + C.new.map{|e| + e + 3 + } +} +assert_equal %q{100}, %q{ + def m + yield + end + def n + yield + end + + m{ + n{ + 100 + } + } +} +assert_equal %q{20}, %q{ + def m + yield 1 + end + + m{|ib| + m{|jb| + i = 20 + } + } +} +assert_equal %q{2}, %q{ + def m + yield 1 + end + + m{|ib| + m{|jb| + ib = 20 + kb = 2 + } + } +} +assert_equal %q{3}, %q{ + def iter1 + iter2{ + yield + } + end + + def iter2 + yield + end + + iter1{ + jb = 2 + iter1{ + jb = 3 + } + jb + } +} +assert_equal %q{2}, %q{ + def iter1 + iter2{ + yield + } + end + + def iter2 + yield + end + + iter1{ + jb = 2 + iter1{ + jb + } + jb + } +} +assert_equal %q{2}, %q{ + def m + yield 1 + end + m{|ib| + ib*2 + } +} +assert_equal %q{92580}, %q{ + def m + yield 12345, 67890 + end + m{|ib,jb| + ib*2+jb + } +} +assert_equal %q{[10, nil]}, %q{ + def iter + yield 10 + end + + a = nil + [iter{|a| + a + }, a] +} +assert_equal %q{21}, %q{ + def iter + yield 10 + end + + iter{|a| + iter{|a| + a + 1 + } + a + } +} +assert_equal %q{[10, 20, 30, 40, nil, nil, nil, nil]}, %q{ + def iter + yield 10, 20, 30, 40 + end + + a = b = c = d = nil + iter{|a, b, c, d| + [a, b, c, d] + } + [a, b, c, d] +} +assert_equal %q{[10, 20, 30, 40, nil, nil]}, %q{ + def iter + yield 10, 20, 30, 40 + end + + a = b = nil + iter{|a, b, c, d| + [a, b, c, d] + } + [a, b] +} +assert_equal %q{[1]}, %q{ + $a = [] + + def iter + yield 1 + end + + def m + x = iter{|x| + $a << x + y = 0 + } + end + m + $a +} +assert_equal %q{[1, [2]]}, %q{ + def iter + yield 1, 2 + end + + iter{|a, *b| + [a, b] + } +} +assert_equal %q{[[1, 2]]}, %q{ + def iter + yield 1, 2 + end + + iter{|*a| + [a] + } +} +assert_equal %q{[1, 2, []]}, %q{ + def iter + yield 1, 2 + end + + iter{|a, b, *c| + [a, b, c] + } +} +assert_equal %q{[1, 2, nil, []]}, %q{ + def iter + yield 1, 2 + end + + iter{|a, b, c, *d| + [a, b, c, d] + } +} +assert_equal %q{1}, %q{ + def m + yield + end + m{ + 1 + } +} +assert_equal %q{15129}, %q{ + def m + yield 123 + end + m{|ib| + m{|jb| + ib*jb + } + } +} +assert_equal %q{2}, %q{ + def m a + yield a + end + m(1){|ib| + m(2){|jb| + ib*jb + } + } +} +assert_equal %q{9}, %q{ + sum = 0 + 3.times{|ib| + 2.times{|jb| + sum += ib + jb + }} + sum +} +assert_equal %q{10}, %q{ + 3.times{|bl| + break 10 + } +} +assert_equal %q{[1, 2]}, %q{ + def iter + yield 1,2,3 + end + + iter{|i, j| + [i, j] + } +} +assert_equal %q{[1, nil]}, %q{ + def iter + yield 1 + end + + iter{|i, j| + [i, j] + } +} diff --git a/bootstraptest/test_eval.rb b/bootstraptest/test_eval.rb new file mode 100644 index 0000000000..5de4f4ef8c --- /dev/null +++ b/bootstraptest/test_eval.rb @@ -0,0 +1,190 @@ +assert_equal %q{ok}, %q{ + def m + a = :ok + $b = binding + end + m + eval('a', $b) +} +assert_equal %q{[:ok, :ok2]}, %q{ + def m + a = :ok + $b = binding + end + m + eval('b = :ok2', $b) + eval('[a, b]', $b) +} +assert_equal %q{[nil, 1]}, %q{ + $ans = [] + def m + $b = binding + end + m + $ans << eval(%q{ + $ans << eval(%q{ + a + }, $b) + a = 1 + }, $b) + $ans +} +assert_equal %q{C}, %q{ + Const = :top + class C + Const = :C + def m + binding + end + end + eval('Const', C.new.m) +} +assert_equal %q{top}, %q{ + Const = :top + a = 1 + class C + Const = :C + def m + eval('Const', TOPLEVEL_BINDING) + end + end + C.new.m +} +assert_equal %q{:ok +ok}, %q{ + class C + $b = binding + end + eval %q{ + def m + :ok + end + }, $b + p C.new.m +} +assert_equal %q{ok}, %q{ + b = proc{ + a = :ok + binding + }.call + a = :ng + eval("a", b) +} +assert_equal %q{C}, %q{ + class C + def foo + binding + end + end + C.new.foo.eval("self.class.to_s") +} +assert_equal %q{1}, %q{ + eval('1') +} +assert_equal %q{1}, %q{ + eval('a=1; a') +} +assert_equal %q{1}, %q{ + a = 1 + eval('a') +} +assert_equal %q{ok}, %q{ + __send! :eval, %{ + :ok + } +} +assert_equal %q{ok}, %q{ + 1.__send! :instance_eval, %{ + :ok + } +} +assert_equal %q{1}, %q{ + 1.instance_eval{ + self + } +} +assert_equal %q{foo}, %q{ + 'foo'.instance_eval{ + self + } +} +assert_equal %q{1}, %q{ + class Fixnum + Const = 1 + end + 1.instance_eval %{ + Const + } +} +assert_equal %q{C}, %q{ + Const = :top + class C + Const = :C + end + C.module_eval{ + Const + } +} +assert_equal %q{C}, %q{ + Const = :top + class C + Const = :C + end + C.class_eval %{ + def m + Const + end + } + C.new.m +} +assert_equal %q{C}, %q{ + Const = :top + class C + Const = :C + end + C.class_eval{ + def m + Const + end + } + C.new.m +} +assert_equal %q{[:top, :C, :top, :C]}, %q{ + Const = :top + class C + Const = :C + end + $nest = false + $ans = [] + def m + $ans << Const + C.module_eval %{ + $ans << Const + Boo = false unless defined? Boo + unless $nest + $nest = true + m + end + } + end + m + $ans +} +assert_equal %q{[10, main]}, %q{ + $nested = false + $ans = [] + $pr = proc{ + $ans << self + unless $nested + $nested = true + $pr.call + end + } + class C + def initialize &b + 10.instance_eval(&b) + end + end + C.new(&$pr) + $ans +} diff --git a/bootstraptest/test_exception.rb b/bootstraptest/test_exception.rb new file mode 100644 index 0000000000..79d7388b24 --- /dev/null +++ b/bootstraptest/test_exception.rb @@ -0,0 +1,370 @@ +assert_equal %q{2}, %q{ + begin + 1+1 + ensure + 2+2 + end +} +assert_equal %q{4}, %q{ + begin + 1+1 + begin + 2+2 + ensure + 3+3 + end + ensure + 4+4 + end +} +assert_equal %q{4}, %q{ + begin + 1+1 + begin + 2+2 + ensure + 3+3 + end + ensure + 4+4 + begin + 5+5 + ensure + 6+6 + end + end +} +assert_equal %q{NilClass}, %q{ + a = nil + 1.times{|e| + begin + rescue => err + end + a = err.class + } + a +} +assert_equal %q{RuntimeError}, %q{ + a = nil + 1.times{|e| + begin + raise + rescue => err + end + a = err.class + } + a +} +assert_equal %q{}, %q{ + $! +} +assert_equal %q{FOO}, %q{ + begin + raise "FOO" + rescue + $! + end +} +assert_equal %q{FOO}, %q{ + def m + $! + end + begin + raise "FOO" + rescue + m() + end +} +assert_equal %q{[#, #]}, %q{ + $ans = [] + def m + $! + end + begin + raise "FOO" + rescue + begin + raise "BAR" + rescue + $ans << m() + end + $ans << m() + end + $ans +} +assert_equal %q{[#, #]}, %q{ + $ans = [] + def m + $! + end + + begin + begin + raise "FOO" + ensure + $ans << m() + end + rescue + $ans << m() + end +} +assert_equal %q{[nil]}, %q{ + $ans = [] + def m + $! + end + def m2 + 1.times{ + begin + return + ensure + $ans << m + end + } + end + m2 + $ans +} +assert_equal %q{ok}, %q{ + begin + raise + rescue + :ok + end +} +assert_equal %q{ok}, %q{ + begin + raise + rescue + :ok + ensure + :ng + end +} +assert_equal %q{RuntimeError}, %q{ + begin + raise + rescue => e + e.class + end +} +assert_equal %q{ng}, %q{ + begin + raise + rescue StandardError + :ng + rescue Exception + :ok + end +} +assert_equal %q{c}, %q{ + begin + begin + raise "a" + rescue + raise "b" + ensure + raise "c" + end + rescue => e + e.message + end +} +assert_equal %q{33}, %q{ + def m a, b + a + b + end + m(1, begin + raise + rescue + 2 + end) + + m(10, begin + raise + rescue + 20 + ensure + 30 + end) +} +assert_equal %q{3}, %q{ + def m a, b + a + b + end + m(begin + raise + rescue + 1 + end, + begin + raise + rescue + 2 + end) +} +assert_equal %q{ok3}, %q{ + class E1 < Exception + end + + def m + yield + end + + begin + begin + begin + m{ + raise + } + rescue E1 + :ok2 + ensure + end + rescue + :ok3 + ensure + end + rescue E1 + :ok + ensure + end +} +assert_equal %q{7}, %q{ + $i = 0 + def m + iter{ + begin + $i += 1 + begin + $i += 2 + break + ensure + + end + ensure + $i += 4 + end + $i = 0 + } + end + + def iter + yield + end + m + $i +} +assert_equal %q{10}, %q{ + $i = 0 + def m + begin + $i += 1 + begin + $i += 2 + return + ensure + $i += 3 + end + ensure + $i += 4 + end + p :end + end + m + $i +} +assert_equal %q{1}, %q{ + begin + 1 + rescue + 2 + end +} +assert_equal %q{4}, %q{ + begin + 1 + begin + 2 + rescue + 3 + end + 4 + rescue + 5 + end +} +assert_equal %q{3}, %q{ + begin + 1 + rescue + 2 + else + 3 + end +} +assert_equal %q{2}, %q{ + begin + 1+1 + rescue + 2+2 + ensure + 3+3 + end + } +assert_equal %q{2}, %q{ + begin + 1+1 + rescue + 2+2 + ensure + 3+3 + end + } +assert_equal %q{6}, %q{ + begin + 1+1 + rescue + 2+2 + else + 3+3 + ensure + 4+4 + end + } +assert_equal %q{12}, %q{ + begin + 1+1 + begin + 2+2 + rescue + 3+3 + else + 4+4 + end + rescue + 5+5 + else + 6+6 + ensure + 7+7 + end + } +assert_equal %q{ok}, %q{ # + proc{ + begin + raise + break + rescue + :ok + end + }.call +} +assert_equal %q{}, %q{ + proc do + begin + raise StandardError + redo + rescue StandardError + end + end.call +} diff --git a/bootstraptest/test_flow.rb b/bootstraptest/test_flow.rb new file mode 100644 index 0000000000..9964dfb2ed --- /dev/null +++ b/bootstraptest/test_flow.rb @@ -0,0 +1,491 @@ +assert_equal %q{[1, 2, 4, 5, 6, 7, 8]}, %q{$a = []; begin; ; $a << 1 + [1,2].each{; $a << 2 + break; $a << 3 + }; $a << 4 + begin; $a << 5 + ensure; $a << 6 + end; $a << 7 +; $a << 8 +; rescue Exception; $a << 99; end; $a} +assert_equal %q{[1, 2, 3, 5, 6, 7, 8]}, %q{$a = []; begin; ; $a << 1 + begin; $a << 2 + [1,2].each do; $a << 3 + break; $a << 4 + end; $a << 5 + ensure; $a << 6 + end; $a << 7 +; $a << 8 +; rescue Exception; $a << 99; end; $a} +assert_equal %q{ok}, %q{ + ["a"].inject("ng"){|x,y| + break :ok + } +} +assert_equal %q{ok}, %q{ + unless ''.respond_to? :lines + class String + def lines + self + end + end + end + + ('a').lines.map{|e| + break :ok + } +} +assert_equal %q{[1, 2, 4, 5]}, %q{$a = []; begin; ; $a << 1 + ["a"].inject("ng"){|x,y|; $a << 2 + break :ok; $a << 3 + }; $a << 4 +; $a << 5 +; rescue Exception; $a << 99; end; $a} +assert_equal %q{[1, 2, 4, 5]}, %q{$a = []; begin; ; $a << 1 + ('a'..'b').map{|e|; $a << 2 + break :ok; $a << 3 + }; $a << 4 +; $a << 5 +; rescue Exception; $a << 99; end; $a} +assert_equal %q{[1, 2, 3, 5, 7, 8]}, %q{$a = []; begin; ; $a << 1 + [1,2].each do; $a << 2 + begin; $a << 3 + break; $a << 4 + ensure; $a << 5 + end; $a << 6 + end; $a << 7 +; $a << 8 +; rescue Exception; $a << 99; end; $a} +assert_equal %q{[1, 2, 3, 4, 5, 6, 9, 10]}, %q{$a = []; begin; ; $a << 1 + i=0; $a << 2 + while i<3; $a << 3 + i+=1; $a << 4 + begin; $a << 5 + ensure; $a << 6 + break; $a << 7 + end; $a << 8 + end; $a << 9 +; $a << 10 +; rescue Exception; $a << 99; end; $a} +assert_equal %q{[1, 2, 3, 4, 5, 7, 10, 11]}, %q{$a = []; begin; ; $a << 1 + i=0; $a << 2 + while i<3; $a << 3 + i+=1; $a << 4 + begin; $a << 5 + raise; $a << 6 + ensure; $a << 7 + break; $a << 8 + end; $a << 9 + end; $a << 10 +; $a << 11 +; rescue Exception; $a << 99; end; $a} +assert_equal %q{[1, 2, 3, 4, 5, 7, 10, 11]}, %q{$a = []; begin; ; $a << 1 + i=0; $a << 2 + while i<3; $a << 3 + i+=1; $a << 4 + begin; $a << 5 + raise; $a << 6 + rescue; $a << 7 + break; $a << 8 + end; $a << 9 + end; $a << 10 +; $a << 11 +; rescue Exception; $a << 99; end; $a} +assert_equal %q{[1, 2, 3, 5, 8, 9]}, %q{$a = []; begin; ; $a << 1 + [1,2].each do; $a << 2 + begin; $a << 3 + raise StandardError; $a << 4 + ensure; $a << 5 + break; $a << 6 + end; $a << 7 + end; $a << 8 +; $a << 9 +; rescue Exception; $a << 99; end; $a} +assert_equal %q{[1, 2, 3, 5, 8, 9]}, %q{$a = []; begin; ; $a << 1 + [1,2].each do; $a << 2 + begin; $a << 3 + raise StandardError; $a << 4 + rescue; $a << 5 + break; $a << 6 + end; $a << 7 + end; $a << 8 +; $a << 9 +; rescue Exception; $a << 99; end; $a} +assert_equal %q{[1, 2, 3, 4, 6, 8, 10, 11]}, %q{$a = []; begin; ; $a << 1 + [1,2].each do; $a << 2 + begin; $a << 3 + begin; $a << 4 + break; $a << 5 + ensure; $a << 6 + end; $a << 7 + ensure; $a << 8 + end; $a << 9 + end; $a << 10 +; $a << 11 +; rescue Exception; $a << 99; end; $a} +assert_equal %q{[1, 2, 3, 4, 5, 6, 7, 8, 10, 13, 3, 4, 5, 6, 7, 8, 10, 13, 3, 4, 5, 6, 7, 8, 10, 13, 14, 15]}, %q{$a = []; begin; ; $a << 1 + i = 0; $a << 2 + while i<3; $a << 3 + i+=1; $a << 4 + j = 0; $a << 5 + while j<3; $a << 6 + j+=1; $a << 7 + begin; $a << 8 + raise; $a << 9 + rescue; $a << 10 + break; $a << 11 + end; $a << 12 + end; $a << 13 + end; $a << 14 +; $a << 15 +; rescue Exception; $a << 99; end; $a} +assert_equal %q{[1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 14, 6, 7, 8, 9, 11, 14, 6, 7, 8, 9, 11, 14, 15, 3, 4, 5, 6, 7, 8, 9, 11, 14, 6, 7, 8, 9, 11, 14, 6, 7, 8, 9, 11, 14, 15, 3, 4, 5, 6, 7, 8, 9, 11, 14, 6, 7, 8, 9, 11, 14, 6, 7, 8, 9, 11, 14, 15, 16, 17]}, %q{$a = []; begin; ; $a << 1 + i = 0; $a << 2 + while i<3; $a << 3 + i+=1; $a << 4 + j = 0; $a << 5 + while j<3; $a << 6 + j+=1; $a << 7 + 1.times{; $a << 8 + begin; $a << 9 + raise; $a << 10 + rescue; $a << 11 + break; $a << 12 + end; $a << 13 + }; $a << 14 + end; $a << 15 + end; $a << 16 +; $a << 17 +; rescue Exception; $a << 99; end; $a} +assert_equal %q{[1, 2, 3, 4, 5, 6, 7, 8, 10, 13, 3, 4, 5, 6, 7, 8, 10, 13, 3, 4, 5, 6, 7, 8, 10, 13, 14, 15]}, %q{$a = []; begin; ; $a << 1 + i = 0; $a << 2 + while i<3; $a << 3 + i+=1; $a << 4 + j = 0; $a << 5 + while j<3; $a << 6 + j+=1; $a << 7 + begin; $a << 8 + raise; $a << 9 + ensure; $a << 10 + break; $a << 11 + end; $a << 12 + end; $a << 13 + end; $a << 14 +; $a << 15 +; rescue Exception; $a << 99; end; $a} +assert_equal %q{[1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 14, 6, 7, 8, 9, 11, 14, 6, 7, 8, 9, 11, 14, 15, 3, 4, 5, 6, 7, 8, 9, 11, 14, 6, 7, 8, 9, 11, 14, 6, 7, 8, 9, 11, 14, 15, 3, 4, 5, 6, 7, 8, 9, 11, 14, 6, 7, 8, 9, 11, 14, 6, 7, 8, 9, 11, 14, 15, 16, 17]}, %q{$a = []; begin; ; $a << 1 + i = 0; $a << 2 + while i<3; $a << 3 + i+=1; $a << 4 + j = 0; $a << 5 + while j<3; $a << 6 + j+=1; $a << 7 + 1.times{; $a << 8 + begin; $a << 9 + raise; $a << 10 + ensure; $a << 11 + break; $a << 12 + end; $a << 13 + }; $a << 14 + end; $a << 15 + end; $a << 16 +; $a << 17 +; rescue Exception; $a << 99; end; $a} +assert_equal %q{[1, 2, 3, 5, 8, 9]}, %q{$a = []; begin; ; $a << 1 + while true; $a << 2 + begin; $a << 3 + break; $a << 4 + ensure; $a << 5 + break; $a << 6 + end; $a << 7 + end; $a << 8 +; $a << 9 +; rescue Exception; $a << 99; end; $a} +assert_equal %q{[1, 2, 3, 5, 99]}, %q{$a = []; begin; ; $a << 1 + while true; $a << 2 + begin; $a << 3 + break; $a << 4 + ensure; $a << 5 + raise; $a << 6 + end; $a << 7 + end; $a << 8 +; $a << 9 +; rescue Exception; $a << 99; end; $a} +assert_equal %q{[1, 2, 3, 4, 6, 8, 9, 10, 11]}, %q{$a = []; begin; ; $a << 1 + begin; $a << 2 + [1,2].each do; $a << 3 + begin; $a << 4 + break; $a << 5 + ensure; $a << 6 + end; $a << 7 + end; $a << 8 + ensure; $a << 9 + end; $a << 10 +; $a << 11 +; rescue Exception; $a << 99; end; $a} +assert_equal %q{[1, 2, 4, 99]}, %q{$a = []; begin; ; $a << 1 + begin; $a << 2 + raise StandardError; $a << 3 + ensure; $a << 4 + end; $a << 5 +; $a << 6 +; rescue Exception; $a << 99; end; $a} +assert_equal %q{[1, 2, 3, 4]}, %q{$a = []; begin; ; $a << 1 + begin; $a << 2 + ensure; $a << 3 + end ; $a << 4 +; rescue Exception; $a << 99; end; $a} +assert_equal %q{[1, 2, 3, 5, 99]}, %q{$a = []; begin; ; $a << 1 + [1,2].each do; $a << 2 + begin; $a << 3 + break; $a << 4 + ensure; $a << 5 + raise StandardError; $a << 6 + end; $a << 7 + end; $a << 8 +; $a << 9 +; rescue Exception; $a << 99; end; $a} +assert_equal %q{3}, %q{ + def m a, b + a + b + end + m(1, + while true + break 2 + end + ) +} +assert_equal %q{4}, %q{ + def m a, b + a + b + end + m(1, + (i=0; while i<2 + i+=1 + class C + next 2 + end + end; 3) + ) +} +assert_equal %q{34}, %q{ + def m a, b + a+b + end + m(1, 1.times{break 3}) + + m(10, (1.times{next 3}; 20)) +} +assert_equal %q{[1, 2, 3, 6, 7]}, %q{$a = []; begin; ; $a << 1 + 3.times{; $a << 2 + class C; $a << 3 + break; $a << 4 + end; $a << 5 + }; $a << 6 +; $a << 7 +; rescue Exception; $a << 99; end; $a} +assert_equal %q{[1, 2, 3, 4, 8, 9]}, %q{$a = []; begin; ; $a << 1 + 3.times{; $a << 2 + class A; $a << 3 + class B; $a << 4 + break; $a << 5 + end; $a << 6 + end; $a << 7 + }; $a << 8 +; $a << 9 +; rescue Exception; $a << 99; end; $a} +assert_equal %q{[1, 2, 3, 2, 3, 2, 3, 6, 7]}, %q{$a = []; begin; ; $a << 1 + 3.times{; $a << 2 + class C; $a << 3 + next; $a << 4 + end; $a << 5 + }; $a << 6 +; $a << 7 +; rescue Exception; $a << 99; end; $a} +assert_equal %q{[1, 2, 3, 4, 2, 3, 4, 2, 3, 4, 8, 9]}, %q{$a = []; begin; ; $a << 1 + 3.times{; $a << 2 + class C; $a << 3 + class D; $a << 4 + next; $a << 5 + end; $a << 6 + end; $a << 7 + }; $a << 8 +; $a << 9 +; rescue Exception; $a << 99; end; $a} +assert_equal %q{[1, 2, 3, 6, 7]}, %q{$a = []; begin; ; $a << 1 + while true; $a << 2 + class C; $a << 3 + break; $a << 4 + end; $a << 5 + end; $a << 6 +; $a << 7 +; rescue Exception; $a << 99; end; $a} +assert_equal %q{[1, 2, 3, 4, 8, 9]}, %q{$a = []; begin; ; $a << 1 + while true; $a << 2 + class C; $a << 3 + class D; $a << 4 + break; $a << 5 + end; $a << 6 + end; $a << 7 + end; $a << 8 +; $a << 9 +; rescue Exception; $a << 99; end; $a} +assert_equal %q{[1, 2, 3, 4, 5, 3, 4, 5, 3, 4, 5, 8, 9]}, %q{$a = []; begin; ; $a << 1 + i=0; $a << 2 + while i<3; $a << 3 + i+=1; $a << 4 + class C; $a << 5 + next 10; $a << 6 + end; $a << 7 + end; $a << 8 +; $a << 9 +; rescue Exception; $a << 99; end; $a} +assert_equal %q{1}, %q{ + 1.times{ + while true + class C + begin + break + ensure + break + end + end + end + } +} +assert_equal %q{[1, 2, 3, 5, 2, 3, 5, 7, 8]}, %q{$a = []; begin; ; $a << 1 + [1,2].each do; $a << 2 + begin; $a << 3 + next; $a << 4 + ensure; $a << 5 + end; $a << 6 + end; $a << 7 +; $a << 8 +; rescue Exception; $a << 99; end; $a} +assert_equal %q{[1, 2, 6, 3, 5, 7, 8]}, %q{$a = []; begin; ; $a << 1 + o = "test"; $a << 2 + def o.test(a); $a << 3 + return a; $a << 4 + ensure; $a << 5 + end; $a << 6 + o.test(123); $a << 7 +; $a << 8 +; rescue Exception; $a << 99; end; $a} +assert_equal %q{[1, 4, 7, 5, 8, 9]}, %q{$a = []; begin; ; $a << 1 + def m1 *args; $a << 2 + ; $a << 3 + end; $a << 4 + def m2; $a << 5 + m1(:a, :b, (return 1; :c)); $a << 6 + end; $a << 7 + m2; $a << 8 +; $a << 9 +; rescue Exception; $a << 99; end; $a} +assert_equal %q{[1, 8, 2, 3, 4, 5, 9, 10]}, %q{$a = []; begin; ; $a << 1 + def m(); $a << 2 + begin; $a << 3 + 2; $a << 4 + ensure; $a << 5 + return 3; $a << 6 + end; $a << 7 + end; $a << 8 + m; $a << 9 +; $a << 10 +; rescue Exception; $a << 99; end; $a} +assert_equal %q{[1, 3, 11, 4, 5, 6, 7, 12, 13]}, %q{$a = []; begin; ; $a << 1 + def m2; $a << 2 + end; $a << 3 + def m(); $a << 4 + m2(begin; $a << 5 + 2; $a << 6 + ensure; $a << 7 + return 3; $a << 8 + end); $a << 9 + 4; $a << 10 + end; $a << 11 + m(); $a << 12 +; $a << 13 +; rescue Exception; $a << 99; end; $a} +assert_equal %q{[1, 16, 2, 3, 4, 5, 6, 7, 10, 11, 17, 18]}, %q{$a = []; begin; ; $a << 1 + def m; $a << 2 + 1; $a << 3 + 1.times{; $a << 4 + 2; $a << 5 + begin; $a << 6 + 3; $a << 7 + return; $a << 8 + 4; $a << 9 + ensure; $a << 10 + 5; $a << 11 + end; $a << 12 + 6; $a << 13 + }; $a << 14 + 7; $a << 15 + end; $a << 16 + m(); $a << 17 +; $a << 18 +; rescue Exception; $a << 99; end; $a} +assert_equal %q{[:ok, :ok2, :last]}, %q{ + a = [] + i = 0 + begin + while i < 1 + i+=1 + begin + begin + next + ensure + a << :ok + end + ensure + a << :ok2 + end + end + ensure + a << :last + end + a +} +assert_equal %q{[:ok, :ok2, :last]}, %q{ + a = [] + i = 0 + begin + while i < 1 + i+=1 + begin + begin + break + ensure + a << :ok + end + ensure + a << :ok2 + end + end + ensure + a << :last + end + a +} +assert_equal %q{[:ok, :ok2, :last]}, %q{ + a = [] + i = 0 + begin + while i < 1 + if i>0 + break + end + i+=1 + begin + begin + redo + ensure + a << :ok + end + ensure + a << :ok2 + end + end + ensure + a << :last + end + a + } diff --git a/bootstraptest/test_jump.rb b/bootstraptest/test_jump.rb new file mode 100644 index 0000000000..a83b6f0eab --- /dev/null +++ b/bootstraptest/test_jump.rb @@ -0,0 +1,232 @@ +assert_equal %q{ok}, %q{ + def m + :ng1 + mm{ + yield + } + :ng2 + end + + def mm + :ng3 + yield + :ng4 + end + + m{ + break :ok + } +} +assert_equal %q{ok}, %q{ + 3.times{ + break :ok + } +} +assert_equal %q{}, %q{ + catch(:foo){ + throw :foo + } +} +assert_equal %q{false}, %q{ + catch(:foo){ + throw :foo, false + } +} +assert_equal %q{}, %q{ + catch(:foo){ + throw :foo, nil + } +} +assert_equal %q{ok}, %q{ + catch(:foo){ + throw :foo, :ok + } +} +assert_equal %q{}, %q{ + catch(:foo){ + 1.times{ + throw :foo + } + } +} +assert_equal %q{ok}, %q{ + catch(:foo){ + 1.times{ + throw :foo, :ok + } + } +} +assert_equal %q{ok}, %q{ + catch(:foo){ + catch(:bar){ + throw :foo, :ok + } + :ng + } +} +assert_equal %q{ok}, %q{ + catch(:foo){ + catch(:bar){ + 1.times{ + throw :foo, :ok + } + } + :ng + } +} +assert_equal %q{2}, %q{ + module Enumerable + def all_? + self.each{|e| + unless yield(e) + return false + end + } + true + end + end + + xxx = 0 + [1,2].each{|bi| + [3,4].each{|bj| + [true, nil, true].all_?{|be| be} + break + } + xxx += 1 + } + xxx +} +assert_equal %q{ok}, %q{ + def m + yield + end + + m{ + begin + ensure + break :ok + end + } +} +assert_equal %q{ok}, %q{ + def m + yield + :ok + end + i=0 + m{ + if i>10 + i*i + else + i+=1 + next + end + } +} +assert_equal %q{ok}, %q{ + def m + yield + end + + m{ + next :ok + } +} +assert_equal %q{131}, %q{ + def m + yield + 10 + end + i=0 + m{ + if i>10 + i*i + else + i+=1 + redo + end + } +} +assert_equal %q{ok}, %q{ + def m a + yield + end + + i=0 + m(i+=1){ + retry if i<10 + :ok + } +} +assert_equal %q{3}, %q{ + def m + return 3 + end + m +} +assert_equal %q{ok}, %q{ + def m + :ng1 + mm{ + return :ok + } + :ng2 + end + + def mm + :ng3 + yield + :ng4 + end + m +} +assert_equal %q{100}, %q{ + $i = 0 + def m + begin + iter{ + return + } + ensure + $i = 100 + end + end + + def iter + yield + end + m + $i +} +assert_equal %q{ok}, %q{ + def m + begin + raise + rescue + return :ok + end + :ng + end + m +} +assert_equal %q{1}, %q{ + def m + begin + raise + rescue + return 1 + end + end + + m +} +assert_equal %q{1}, %q{ + def m + begin + # + ensure + return 1 + end + end + + m +} diff --git a/bootstraptest/test_proc.rb b/bootstraptest/test_proc.rb new file mode 100644 index 0000000000..049bc99131 --- /dev/null +++ b/bootstraptest/test_proc.rb @@ -0,0 +1,255 @@ +assert_equal %q{[1, 2, 3]}, %q{ + def getproc &b + b + end + + def m + yield + end + + m{ + i = 1 + m{ + j = 2 + m{ + k = 3 + getproc{ + [i, j, k] + } + } + } + }.call +} +assert_equal %q{7}, %q{ + def make_proc(&b) + b + end + + def make_closure + a = 0 + make_proc{ + a+=1 + } + end + + cl = make_closure + cl.call + cl.call * cl.call +} +assert_equal %q{ok}, %q{ + class C + def foo + :ok + end + end + + def block + C.method(:new).to_proc + end + b = block() + b.call.foo +} +assert_equal %q{[0, 1, :last, 0, 2, :last]}, %q{ + def proc &b + b + end + + pr = [] + proc{|i_b| + p3 = proc{|j_b| + pr << proc{|k_b| + [i_b, j_b, k_b] + } + } + p3.call(1) + p3.call(2) + }.call(0) + + pr[0].call(:last).concat pr[1].call(:last) +} +assert_equal %q{12}, %q{ + def iter + yield + end + + def getproc &b + b + end + + iter{ + bvar = 3 + getproc{ + bvar2 = 4 + bvar * bvar2 + } + }.call +} +assert_equal %q{200}, %q{ + def iter + yield + end + + def getproc &b + b + end + + loc1 = 0 + pr1 = iter{ + bl1 = 1 + getproc{ + loc1 += 1 + bl1 += 1 + loc1 + bl1 + } + } + + pr2 = iter{ + bl1 = 1 + getproc{ + loc1 += 1 + bl1 += 1 + loc1 + bl1 + } + } + + pr1.call; pr2.call + pr1.call; pr2.call + pr1.call; pr2.call + (pr1.call + pr2.call) * loc1 +} +assert_equal %q{[1, 2]}, %q{ + def proc(&pr) + pr + end + + def m + a = 1 + m2{ + a + } + end + + def m2 + b = 2 + proc{ + [yield, b] + } + end + + pr = m + x = ['a', 1,2,3,4,5,6,7,8,9,0, + 1,2,3,4,5,6,7,8,9,0, + 1,2,3,4,5,6,7,8,9,0, + 1,2,3,4,5,6,7,8,9,0, + 1,2,3,4,5,6,7,8,9,0,] + pr.call +} +assert_equal %q{1}, %q{ + def proc(&pr) + pr + end + + def m + a = 1 + m2{ + a + } + end + + def m2 + b = 2 + proc{ + [yield, b] + } + 100000.times{|x| + "#{x}" + } + yield + end + m +} +assert_equal %q{[:C, :C]}, %q{ + Const = :top + class C + Const = :C + $pr = proc{ + (1..2).map{ + Const + } + } + end + $pr.call +} +assert_equal %q{top}, %q{ + Const = :top + class C + Const = :C + end + pr = proc{ + Const + } + C.class_eval %q{ + pr.call + } +} +assert_equal %q{1}, %q{ + def m(&b) + b + end + + m{|e_proctest| e_proctest}.call(1) +} +assert_equal %q{12}, %q{ + def m(&b) + b + end + + m{|e_proctest1, e_proctest2| + a = e_proctest1 * e_proctest2 * 2 + a * 3 + }.call(1, 2) +} +assert_equal %q{[[], [1], [1, 2], [1, 2, 3]]}, %q{ + [ + Proc.new{|*args| args}.call(), + Proc.new{|*args| args}.call(1), + Proc.new{|*args| args}.call(1, 2), + Proc.new{|*args| args}.call(1, 2, 3), + ] +} +assert_equal %q{[[nil, []], [1, []], [1, [2]], [1, [2, 3]]]}, %q{ + [ + Proc.new{|a, *b| [a, b]}.call(), + Proc.new{|a, *b| [a, b]}.call(1), + Proc.new{|a, *b| [a, b]}.call(1, 2), + Proc.new{|a, *b| [a, b]}.call(1, 2, 3), + ] +} +assert_equal %q{0}, %q{ + pr = proc{ + $SAFE + } + $SAFE = 1 + pr.call +} +assert_equal %q{[1, 0]}, %q{ + pr = proc{ + $SAFE += 1 + } + [pr.call, $SAFE] +} +assert_equal %q{1}, %q{ + def m(&b) + b + end + m{1}.call +} +assert_equal %q{3}, %q{ + def m(&b) + b + end + + m{ + a = 1 + a + 2 + }.call +} diff --git a/bootstraptest/test_syntax.rb b/bootstraptest/test_syntax.rb new file mode 100644 index 0000000000..d60cd6f85b --- /dev/null +++ b/bootstraptest/test_syntax.rb @@ -0,0 +1,525 @@ +assert_equal %q{4}, %q{1 && 2 && 3 && 4} +assert_equal %q{}, %q{1 && nil && 3 && 4} +assert_equal %q{}, %q{1 && 2 && 3 && nil} +assert_equal %q{false}, %q{1 && 2 && 3 && false} +assert_equal %q{4}, %q{1 and 2 and 3 and 4} +assert_equal %q{}, %q{1 and nil and 3 and 4} +assert_equal %q{}, %q{1 and 2 and 3 and nil} +assert_equal %q{false}, %q{1 and 2 and 3 and false} +assert_equal %q{}, %q{nil && true} +assert_equal %q{false}, %q{false && true} +assert_equal %q{}, %q{ + case 1 + when 2 + :ng + end} +assert_equal %q{ok}, %q{ + case 1 + when 10,20,30 + :ng1 + when 1,2,3 + :ok + when 100,200,300 + :ng2 + else + :elseng + end} +assert_equal %q{elseok}, %q{ + case 123 + when 10,20,30 + :ng1 + when 1,2,3 + :ng2 + when 100,200,300 + :ng3 + else + :elseok + end +} +assert_equal %q{ok}, %q{ + case 'test' + when /testx/ + :ng1 + when /test/ + :ok + when /tetxx/ + :ng2 + else + :ng_else + end +} +assert_equal %q{ok}, %q{ + case Object.new + when Object + :ok + end +} +assert_equal %q{ok}, %q{ + case Object + when Object.new + :ng + else + :ok + end +} +assert_equal %q{ok}, %q{ + case 'test' + when 'tes' + :ng + when 'te' + :ng + else + :ok + end +} +assert_equal %q{ok}, %q{ + case 'test' + when 'tes' + :ng + when 'te' + :ng + when 'test' + :ok + end +} +assert_equal %q{ng}, %q{ + case 'test' + when 'tes' + :ng + when /te/ + :ng + else + :ok + end +} +assert_equal %q{ok}, %q{ + case 'test' + when 'tes' + :ng + when /test/ + :ok + else + :ng + end +} +assert_equal %q{100}, %q{ + def test(arg) + case 1 + when 2 + 3 + end + return arg + end + + test(100) +} +assert_equal %q{ok}, %q{ + ary = [1, 2] + case 1 + when *ary + :ok + else + :ng + end +} +assert_equal %q{ok}, %q{ + ary = [1, 2] + case 3 + when *ary + :ng + else + :ok + end +} +assert_equal %q{ok}, %q{ + ary = [1, 2] + case 1 + when :x, *ary + :ok + when :z + :ng1 + else + :ng2 + end +} +assert_equal %q{ok}, %q{ + ary = [1, 2] + case 3 + when :x, *ary + :ng1 + when :z + :ng2 + else + :ok + end +} +assert_equal %q{[:false, :false, :false, :false, :false, :false, :false, :false, :false, :false, :false, :then, :false, :false, :false, :then, :false, :false, :false, :then, :false, :false, :false, :then, :false, :false, :then, :then, :false, :false, :then, :then, :false, :false, :then, :then, :false, :false, :then, :then, :false, :then, :then, :then, :false, :then, :then, :then, :false, :then, :then, :then, :false, :then, :then, :then, :then, :then, :then, :then, :then, :then, :then, :then, :false, :false, :false, :then, :false, :false, :false, :then, :false, :false, :false, :false, :false, :false, :false, :false, :false, :false, :then, :then, :false, :false, :then, :then, :false, :false, :false, :then, :false, :false, :false, :then, :false, :then, :then, :then, :false, :then, :then, :then, :false, :false, :then, :then, :false, :false, :then, :then, :then, :then, :then, :then, :then, :then, :then, :then, :false, :then, :then, :then, :false, :then, :then, :then, :false, :false, :false, :then, :false, :false, :false, :then, :false, :false, :then, :then, :false, :false, :then, :then, :false, :false, :false, :false, :false, :false, :false, :false, :false, :false, :false, :then, :false, :false, :false, :then, :false, :then, :then, :then, :false, :then, :then, :then, :then, :then, :then, :then, :then, :then, :then, :then, :false, :false, :then, :then, :false, :false, :then, :then, :false, :then, :then, :then, :false, :then, :then, :then, :false, :false, :then, :then, :false, :false, :then, :then, :false, :false, :false, :then, :false, :false, :false, :then, :false, :false, :false, :then, :false, :false, :false, :then, :false, :false, :false, :false, :false, :false, :false, :false, :then, :then, :then, :then, :then, :then, :then, :then, :false, :then, :then, :then, :false, :then, :then, :then, :false, :then, :then, :then, :false, :then, :then, :then, :false, :false, :then, :then, :false, :false, :then, :then, :false, :false, :then, :then, :false, :false, :then, :then, :false, :then, :then, :then, :false, :then, :then, :then, :false, :then, :then, :then, :false, :then, :then, :then, :then, :then, :then, :then, :then, :then, :then, :then, :false, :false, :false, :false, :false, :false, :false, :false, :false, :false, :false, :then, :false, :false, :false, :then, :false, :false, :false, :then, :false, :false, :false, :then, :false, :false, :then, :then, :false, :false, :then, :then, :false, :then, :then, :then, :false, :then, :then, :then, :false, :false, :then, :then, :false, :false, :then, :then, :then, :then, :then, :then, :then, :then, :then, :then, :false, :then, :then, :then, :false, :then, :then, :then, :false, :false, :false, :then, :false, :false, :false, :then, :false, :false, :false, :false, :false, :false, :false, :false, :false, :false, :then, :then, :false, :false, :then, :then, :false, :false, :false, :then, :false, :false, :false, :then, :false, :then, :then, :then, :false, :then, :then, :then, :then, :then, :then, :then, :then, :then, :then, :then, :false, :false, :then, :then, :false, :false, :then, :then, :false, :then, :then, :then, :false, :then, :then, :then, :false, :false, :false, :then, :false, :false, :false, :then, :false, :false, :then, :then, :false, :false, :then, :then, :false, :false, :false, :false, :false, :false, :false, :false, :false, :false, :false, :then, :false, :false, :false, :then, :then, :then, :then, :then, :then, :then, :then, :then, :false, :then, :then, :then, :false, :then, :then, :then, :false, :then, :then, :then, :false, :then, :then, :then, :false, :false, :then, :then, :false, :false, :then, :then, :false, :false, :then, :then, :false, :false, :then, :then, :false, :false, :false, :then, :false, :false, :false, :then, :false, :false, :false, :then, :false, :false, :false, :then, :false, :false, :false, :false, :false, :false, :false, :false, :then, :then, :then, :then, :then, :then, :then, :then, :then, :then, :then, :false, :then, :then, :then, :false, :then, :then, :then, :false, :then, :then, :then, :false, :then, :then, :false, :false, :then, :then, :false, :false, :then, :then, :false, :false, :then, :then, :false, :false, :then, :false, :false, :false, :then, :false, :false, :false, :then, :false, :false, :false, :then, :false, :false, :false, :false, :false, :false, :false, :false, :false, :false, :false, :then, :then, :then, :false, :then, :then, :then, :false, :then, :then, :then, :then, :then, :then, :then, :then, :then, :then, :false, :false, :then, :then, :false, :false, :then, :then, :then, :false, :then, :then, :then, :false, :then, :false, :false, :false, :then, :false, :false, :false, :then, :then, :false, :false, :then, :then, :false, :false, :false, :false, :false, :false, :false, :false, :false, :false, :then, :false, :false, :false, :then, :false, :false, :false, :then, :then, :then, :false, :then, :then, :then, :false, :then, :then, :false, :false, :then, :then, :false, :false, :then, :then, :then, :then, :then, :then, :then, :then, :then, :then, :then, :false, :then, :then, :then, :false, :then, :false, :false, :false, :then, :false, :false, :false, :false, :false, :false, :false, :false, :false, :false, :false, :then, :then, :false, :false, :then, :then, :false, :false, :then, :false, :false, :false, :then, :false, :false, :false, :then, :then, :false, :false, :then, :then, :false, :false, :then, :then, :then, :false, :then, :then, :then, :false, :then, :then, :then, :false, :then, :then, :then, :false, :then, :then, :then, :then, :then, :then, :then, :then, :false, :false, :false, :false, :false, :false, :false, :false, :then, :false, :false, :false, :then, :false, :false, :false, :then, :false, :false, :false, :then, :false, :false, :false, :then, :then, :false, :false, :then, :then, :false, :false, :then, :then, :false, :false, :then, :then, :false, :false, :then, :false, :false, :false, :then, :false, :false, :false, :then, :false, :false, :false, :then, :false, :false, :false, :false, :false, :false, :false, :false, :false, :false, :false, :then, :then, :then, :then, :then, :then, :then, :then, :then, :then, :then, :false, :then, :then, :then, :false, :then, :then, :then, :false, :then, :then, :then, :false, :then, :then, :false, :false, :then, :then, :false, :false, :then, :false, :false, :false, :then, :false, :false, :false, :then, :then, :false, :false, :then, :then, :false, :false, :false, :false, :false, :false, :false, :false, :false, :false, :then, :false, :false, :false, :then, :false, :false, :false, :then, :then, :then, :false, :then, :then, :then, :false, :then, :then, :then, :then, :then, :then, :then, :then, :then, :then, :false, :false, :then, :then, :false, :false, :then, :then, :then, :false, :then, :then, :then, :false, :then, :false, :false, :false, :then, :false, :false, :false, :false, :false, :false, :false, :false, :false, :false, :false, :then, :then, :false, :false, :then, :then, :false, :false, :then, :false, :false, :false, :then, :false, :false, :false, :then, :then, :then, :false, :then, :then, :then, :false, :then, :then, :false, :false, :then, :then, :false, :false, :then, :then, :then, :then, :then, :then, :then, :then, :then, :then, :then, :false, :then, :then, :then, :false, :false, :false, :false, :false, :false, :false, :false, :false, :then, :false, :false, :false, :then, :false, :false, :false, :then, :false, :false, :false, :then, :false, :false, :false, :then, :then, :false, :false, :then, :then, :false, :false, :then, :then, :false, :false, :then, :then, :false, :false, :then, :then, :then, :false, :then, :then, :then, :false, :then, :then, :then, :false, :then, :then, :then, :false, :then, :then, :then, :then, :then, :then, :then, :then, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep, :then, :sep]}, %q{ + + def make_perm ary, num + if num == 1 + ary.map{|e| [e]} + else + base = make_perm(ary, num-1) + res = [] + base.each{|b| + ary.each{|e| + res << [e] + b + } + } + res + end + end + + def each_test + conds = make_perm(['fv', 'tv'], 3) + bangs = make_perm(['', '!'], 3) + exprs = make_perm(['and', 'or'], 3) + ['if', 'unless'].each{|syn| + conds.each{|cs| + bangs.each{|bs| + exprs.each{|es| + yield(syn, cs, bs, es) + } + } + } + } + end + + fv = false + tv = true + + $ans = [] + each_test{|syn, conds, bangs, exprs| + c1, c2, c3 = conds + bang1, bang2, bang3 = bangs + e1, e2 = exprs + eval %Q{ + #{syn} #{bang1}#{c1} #{e1} #{bang2}#{c2} #{e2} #{bang3}#{c3} + $ans << :then + else + $ans << :false + end + } + } + + each_test{|syn, conds, bangs, exprs| + c1, c2, c3 = conds + bang1, bang2, bang3 = bangs + e1, e2 = exprs + eval %Q{ + #{syn} #{bang1}#{c1} #{e1} #{bang2}#{c2} #{e2} #{bang3}#{c3} + $ans << :then + end + $ans << :sep + } + } + $ans +} +assert_equal %q{}, %q{ + defined?(m) +} +assert_equal %q{method}, %q{ + def m + end + defined?(m) +} +assert_equal %q{}, %q{ + defined?(a.class) +} +assert_equal %q{method}, %q{ + a = 1 + defined?(a.class) +} +assert_equal %q{["method", "method", "method", "method", nil, nil, "method", "method", "method", nil]}, %q{ + class C + def test + [defined?(m1()), defined?(self.m1), defined?(C.new.m1), + defined?(m2()), defined?(self.m2), defined?(C.new.m2), + defined?(m3()), defined?(self.m3), defined?(C.new.m3)] + end + def m1 + end + private + def m2 + end + protected + def m3 + end + end + C.new.test + [defined?(C.new.m3)] +} +assert_equal %q{[nil, nil, nil, nil, "$1", "$2", nil, nil]}, %q{ + $ans = [defined?($1), defined?($2), defined?($3), defined?($4)] + /(a)(b)/ =~ 'ab' + $ans + [defined?($1), defined?($2), defined?($3), defined?($4)] +} +assert_equal %q{nilselftruefalse}, %q{ + defined?(nil) + defined?(self) + + defined?(true) + defined?(false) +} +assert_equal %q{}, %q{ + defined?(@a) +} +assert_equal %q{instance-variable}, %q{ + @a = 1 + defined?(@a) +} +assert_equal %q{}, %q{ + defined?(@@a) +} +assert_equal %q{class variable}, %q{ + @@a = 1 + defined?(@@a) +} +assert_equal %q{}, %q{ + defined?($a) +} +assert_equal %q{global-variable}, %q{ + $a = 1 + defined?($a) +} +assert_equal %q{}, %q{ + defined?(C_definedtest) +} +assert_equal %q{constant}, %q{ + C_definedtest = 1 + defined?(C_definedtest) +} +assert_equal %q{}, %q{ + defined?(::C_definedtest) +} +assert_equal %q{constant}, %q{ + C_definedtest = 1 + defined?(::C_definedtest) +} +assert_equal %q{}, %q{ + defined?(C_definedtestA::C_definedtestB::C_definedtestC) +} +assert_equal %q{constant}, %q{ + class C_definedtestA + class C_definedtestB + C_definedtestC = 1 + end + end + defined?(C_definedtestA::C_definedtestB::C_definedtestC) +} +assert_equal %q{30}, %q{ + sum = 0 + 30.times{|ib| + if ib % 10 == 0 .. true + sum += ib + end + } + sum +} +assert_equal %q{63}, %q{ + sum = 0 + 30.times{|ib| + if ib % 10 == 0 ... true + sum += ib + end + } + sum +} +assert_equal %q{[["NUM", "Type: NUM\n"], ["NUM", "123\n"], ["NUM", "456\n"], ["NUM", "Type: ARP\n"], ["NUM", "aaa\n"], ["NUM", "bbb\n"], ["NUM", "\f\n"], ["ARP", "Type: ARP\n"], ["ARP", "aaa\n"], ["ARP", "bbb\n"]]}, %q{ + t = nil + unless ''.respond_to? :lines + class String + def lines + self + end + end + end + ary = [] +"this must not print +Type: NUM +123 +456 +Type: ARP +aaa +bbb +\f +this must not print +hoge +Type: ARP +aaa +bbb +".lines.each{|l| + if (t = l[/^Type: (.*)/, 1])..(/^\f/ =~ l) + ary << [t, l] + end + } + ary +} +assert_equal %q{1}, %q{if true then 1 ; end} +assert_equal %q{}, %q{if false then 1 ; end} +assert_equal %q{1}, %q{if true then 1 ; else; 2; end} +assert_equal %q{2}, %q{if false then 1 ; else; 2; end} +assert_equal %q{}, %q{if true then ; elsif true then ; 1 ; end} +assert_equal %q{1}, %q{if false then ; elsif true then ; 1 ; end} +assert_equal %q{}, %q{unless true then 1 ; end} +assert_equal %q{1}, %q{unless false then 1 ; end} +assert_equal %q{2}, %q{unless true then 1 ; else; 2; end} +assert_equal %q{1}, %q{unless false then 1 ; else; 2; end} +assert_equal %q{1}, %q{1 if true} +assert_equal %q{}, %q{1 if false} +assert_equal %q{}, %q{1 if nil} +assert_equal %q{}, %q{1 unless true} +assert_equal %q{1}, %q{1 unless false} +assert_equal %q{1}, %q{1 unless nil} +assert_equal %q{1}, %q{1 || 2 || 3 || 4} +assert_equal %q{1}, %q{1 || false || 3 || 4} +assert_equal %q{2}, %q{nil || 2 || 3 || 4} +assert_equal %q{2}, %q{false || 2 || 3 || 4} +assert_equal %q{false}, %q{nil || false || nil || false} +assert_equal %q{1}, %q{1 or 2 or 3 or 4} +assert_equal %q{1}, %q{1 or false or 3 or 4} +assert_equal %q{2}, %q{nil or 2 or 3 or 4} +assert_equal %q{2}, %q{false or 2 or 3 or 4} +assert_equal %q{false}, %q{nil or false or nil or false} +assert_equal %q{elseng}, %q{ + case + when 1==2, 2==3 + :ng1 + when false, 4==5 + :ok + when false + :ng2 + else + :elseng + end +} +assert_equal %q{ok}, %q{ + case + when nil, nil + :ng1 + when 1,2,3 + :ok + when false, false + :ng2 + else + :elseng + end +} +assert_equal %q{elseok}, %q{ + case + when nil + :ng1 + when false + :ng2 + else + :elseok + end} +assert_equal %q{}, %q{ + case + when 1 + end +} +assert_equal %q{ok}, %q{ + r = nil + ary = [] + case + when false + r = :ng1 + when false, false + r = :ng2 + when *ary + r = :ng3 + when false, *ary + r = :ng4 + when true, *ary + r = :ok + end + r +} +assert_equal %q{ok}, %q{ + ary = [] + case + when false, *ary + :ng + else + :ok + end +} +assert_equal %q{ok}, %q{ + ary = [false, nil] + case + when *ary + :ng + else + :ok + end +} +assert_equal %q{ok}, %q{ + ary = [false, nil] + case + when *ary + :ng + when true + :ok + else + :ng2 + end +} +assert_equal %q{ng}, %q{ + ary = [false, nil] + case + when *ary + :ok + else + :ng + end +} +assert_equal %q{ok}, %q{ + ary = [false, true] + case + when *ary + :ok + else + :ng + end +} +assert_equal %q{ok}, %q{ + ary = [false, true] + case + when false, false + when false, *ary + :ok + else + :ng + end +} +assert_equal %q{}, %q{ + i = 0 + while i < 10 + i+=1 + end} +assert_equal %q{10}, %q{ + i = 0 + while i < 10 + i+=1 + end; i} +assert_equal %q{}, %q{ + i = 0 + until i > 10 + i+=1 + end} +assert_equal %q{11}, %q{ + i = 0 + until i > 10 + i+=1 + end; i} +assert_equal %q{1}, %q{ + i = 0 + begin + i+=1 + end while false + i +} +assert_equal %q{1}, %q{ + i = 0 + begin + i+=1 + end until true + i +} diff --git a/bootstraptest/test_thread.rb b/bootstraptest/test_thread.rb new file mode 100644 index 0000000000..64d685fa19 --- /dev/null +++ b/bootstraptest/test_thread.rb @@ -0,0 +1,171 @@ +assert_equal %q{ok}, %q{ + Thread.new{ + }.join + :ok +} +assert_equal %q{ok}, %q{ + Thread.new{ + :ok + }.value +} +assert_equal %q{20100}, %q{ + v = 0 + (1..200).map{|i| + Thread.new{ + i + } + }.each{|t| + v += t.value + } + v +} +assert_equal %q{5000}, %q{ + 5000.times{|e| + (1..2).map{ + Thread.new{ + } + }.each{|e| + e.join + } + } +} +assert_equal %q{5000}, %q{ + 5000.times{ + t = Thread.new{} + while t.alive? + Thread.pass + end + } +} +assert_equal %q{100}, %q{ + 100.times{ + Thread.new{loop{Thread.pass}} + } +} +assert_equal %q{ok}, %q{ + Thread.new{ + :ok + }.join.value +} +assert_equal %q{ok}, %q{ + begin + Thread.new{ + raise "ok" + }.join + rescue => e + e + end +} +assert_equal %q{ok}, %q{ + ans = nil + t = Thread.new{ + begin + sleep 0.5 + ensure + ans = :ok + end + } + Thread.pass + t.kill + t.join + ans +} +assert_equal %q{ok}, %q{ + t = Thread.new{ + sleep + } + sleep 0.1 + t.raise + begin + t.join + :ng + rescue + :ok + end +} +assert_equal %q{ok}, %q{ + t = Thread.new{ + loop{} + } + Thread.pass + t.raise + begin + t.join + :ng + rescue + :ok + end +} +assert_equal %q{ok}, %q{ + t = Thread.new{ + } + Thread.pass + t.join + t.raise # raise to exited thread + begin + t.join + :ok + rescue + :ng + end +} +assert_equal %q{run}, %q{ + t = Thread.new{ + loop{} + } + st = t.status + t.kill + st +} +assert_equal %q{sleep}, %q{ + t = Thread.new{ + sleep + } + sleep 0.1 + st = t.status + t.kill + st +} +assert_equal %q{false}, %q{ + t = Thread.new{ + } + t.kill + sleep 0.1 + t.status +} +assert_equal %q{[ThreadGroup, true]}, %q{ + ptg = Thread.current.group + Thread.new{ + ctg = Thread.current.group + [ctg.class, ctg == ptg] + }.value +} +assert_equal %q{[1, 1]}, %q{ + thg = ThreadGroup.new + + t = Thread.new{ + thg.add Thread.current + sleep + } + sleep 0.1 + [thg.list.size, ThreadGroup::Default.list.size] +} +assert_equal %q{[true, nil, true]}, %q{ + /a/ =~ 'a' + $a = $~ + Thread.new{ + $b = $~ + /a/ =~ 'a' + $c = $~ + } + $d = $~ + [$a == $d, $b, $c != $d] +} +assert_equal %q{11}, %q{ + Thread.current[:a] = 1 + Thread.new{ + Thread.current[:a] = 10 + Thread.pass + Thread.current[:a] + }.value + Thread.current[:a] +} -- cgit v1.2.3