* test/ruby/test_syntax.rb: split test_syntax from test_system.rb.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28540 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
c5de4d4cbd
commit
9f56a870af
@ -1,3 +1,7 @@
|
|||||||
|
Sun Jul 4 22:49:54 2010 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* test/ruby/test_syntax.rb: split test_syntax from test_system.rb.
|
||||||
|
|
||||||
Sun Jul 4 22:02:02 2010 Tanaka Akira <akr@fsij.org>
|
Sun Jul 4 22:02:02 2010 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
* test/ruby/test_system.rb (test_syntax): unified with test_syntax2.
|
* test/ruby/test_system.rb (test_syntax): unified with test_syntax2.
|
||||||
|
22
test/ruby/test_syntax.rb
Normal file
22
test/ruby/test_syntax.rb
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
require 'test/unit'
|
||||||
|
|
||||||
|
class TestSyntax < Test::Unit::TestCase
|
||||||
|
def valid_syntax?(code, fname)
|
||||||
|
code = code.dup.force_encoding("ascii-8bit")
|
||||||
|
code.sub!(/\A(?:\xef\xbb\xbf)?(\s*\#.*$)*(\n)?/n) {
|
||||||
|
"#$&#{"\n" if $1 && !$2}BEGIN{throw tag, :ok}\n"
|
||||||
|
}
|
||||||
|
code.force_encoding("us-ascii")
|
||||||
|
catch {|tag| eval(code, binding, fname, 0)}
|
||||||
|
rescue SyntaxError
|
||||||
|
false
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_syntax
|
||||||
|
assert_nothing_raised(Exception) do
|
||||||
|
for script in Dir[File.expand_path("../../../{lib,sample,ext,test}/**/*.rb", __FILE__)].sort
|
||||||
|
assert(valid_syntax?(IO::read(script), script))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -3,17 +3,6 @@ require 'tmpdir'
|
|||||||
require_relative 'envutil'
|
require_relative 'envutil'
|
||||||
|
|
||||||
class TestSystem < Test::Unit::TestCase
|
class TestSystem < Test::Unit::TestCase
|
||||||
def valid_syntax?(code, fname)
|
|
||||||
code = code.dup.force_encoding("ascii-8bit")
|
|
||||||
code.sub!(/\A(?:\xef\xbb\xbf)?(\s*\#.*$)*(\n)?/n) {
|
|
||||||
"#$&#{"\n" if $1 && !$2}BEGIN{throw tag, :ok}\n"
|
|
||||||
}
|
|
||||||
code.force_encoding("us-ascii")
|
|
||||||
catch {|tag| eval(code, binding, fname, 0)}
|
|
||||||
rescue SyntaxError
|
|
||||||
false
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_system
|
def test_system
|
||||||
ruby = EnvUtil.rubybin
|
ruby = EnvUtil.rubybin
|
||||||
assert_equal("foobar\n", `echo foobar`)
|
assert_equal("foobar\n", `echo foobar`)
|
||||||
@ -99,14 +88,6 @@ class TestSystem < Test::Unit::TestCase
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_syntax
|
|
||||||
assert_nothing_raised(Exception) do
|
|
||||||
for script in Dir[File.expand_path("../../../{lib,sample,ext,test}/**/*.rb", __FILE__)].sort
|
|
||||||
assert(valid_syntax?(IO::read(script), script))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_empty_evstr
|
def test_empty_evstr
|
||||||
assert_equal("", eval('"#{}"', nil, __FILE__, __LINE__), "[ruby-dev:25113]")
|
assert_equal("", eval('"#{}"', nil, __FILE__, __LINE__), "[ruby-dev:25113]")
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user