1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* test/ruby/test_beginendblock.rb, test/ruby/beginmainend.rb: add tests about

scope, order and allowd syntax.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4692 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nahi 2003-10-05 04:51:05 +00:00
parent d77b17aa73
commit d50d6d396a
3 changed files with 48 additions and 3 deletions

View file

@ -1,3 +1,8 @@
Sun Oct 5 13:47:22 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
* test/ruby/test_beginendblock.rb, test/ruby/beginmainend.rb: add tests
about scope, order and allowd syntax.
Sun Oct 5 11:54:29 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
* test/ruby/envutil.rb: added. split "rubybin" from test_system.rb.

View file

@ -1,9 +1,37 @@
BEGIN {
puts "begin"
puts "begin1"
local_begin1 = "local_begin1"
$global_begin1 = "global_begin1"
ConstBegin1 = "ConstBegin1"
}
BEGIN {
puts "begin2"
}
# for scope check
raise if defined?(local_begin1)
raise unless defined?($global_begin1)
raise unless defined?(::ConstBegin1)
local_for_end2 = "end2"
$global_for_end1 = "end1"
puts "main"
END {
puts "end"
puts local_for_end2
}
END {
raise
puts "should not be dumped"
}
END {
exit
puts "should not be dumped"
}
END {
puts $global_for_end1
}

View file

@ -7,6 +7,18 @@ class TestBeginEndBlock < Test::Unit::TestCase
def test_beginendblock
ruby = EnvUtil.rubybin
io = IO.popen("\"#{ruby}\" \"#{DIR}/beginmainend.rb\"")
assert_equal("begin\nmain\nend\n", io.read)
assert_equal(%w(begin1 begin2 main end1 end2).join("\n") << "\n", io.read)
end
def test_begininmethod
assert_raises(SyntaxError) do
eval("def foo; BEGIN {}; end")
end
end
def test_endinmethod
assert_raises(SyntaxError) do
eval("def foo; END {}; end")
end
end
end