2003-10-04 22:56:42 -04:00
|
|
|
require 'test/unit'
|
|
|
|
require "#{File.dirname(File.expand_path(__FILE__))}/envutil"
|
|
|
|
|
|
|
|
class TestBeginEndBlock < Test::Unit::TestCase
|
|
|
|
DIR = File.dirname(File.expand_path(__FILE__))
|
|
|
|
|
|
|
|
def test_beginendblock
|
|
|
|
ruby = EnvUtil.rubybin
|
|
|
|
io = IO.popen("\"#{ruby}\" \"#{DIR}/beginmainend.rb\"")
|
2003-10-05 22:58:39 -04:00
|
|
|
assert_equal(%w(begin1 begin2 main innerbegin1 innerbegin2 end1 innerend1 innerend2 end2).join("\n") << "\n", io.read)
|
2003-10-05 00:51:05 -04:00
|
|
|
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
|
2003-10-04 22:56:42 -04:00
|
|
|
end
|
|
|
|
end
|