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

* test/ruby/test_system.rb (test_syntax2): moved from sample/test.rb

[ruby-dev:41721]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28538 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2010-07-04 12:01:46 +00:00
parent 6fb59decd0
commit 16923c25a1
3 changed files with 32 additions and 28 deletions

View file

@ -1,3 +1,8 @@
Sun Jul 4 21:00:39 2010 Tanaka Akira <akr@fsij.org>
* test/ruby/test_system.rb (test_syntax2): moved from sample/test.rb
[ruby-dev:41721]
Sun Jul 4 17:13:14 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
* io.c (swallow, prepare_getline_args, rb_io_getline_1): fix for

View file

@ -1921,34 +1921,6 @@ test_ok(done)
File.unlink "script_tmp" or `/bin/rm -f "script_tmp"`
File.unlink "script_tmp.bak" or `/bin/rm -f "script_tmp.bak"`
$bad = false
if (dir = File.dirname(File.dirname(__FILE__))) == '.'
dir = ""
else
dir << "/"
end
def valid_syntax?(code, fname)
p 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 Exception
STDERR.puts $!.message
false
end
for script in Dir["#{dir}{lib,sample,ext,test}/**/*.rb"].sort
unless valid_syntax? IO::read(script), script
STDERR.puts script
$bad = true
end
end
test_ok(!$bad)
test_check "const"
TEST1 = 1
TEST2 = 2

View file

@ -14,6 +14,19 @@ class TestSystem < Test::Unit::TestCase
false
end
def valid_syntax2?(code, fname)
p 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 Exception
STDERR.puts $!.message
false
end
def test_system
ruby = EnvUtil.rubybin
assert_equal("foobar\n", `echo foobar`)
@ -107,6 +120,20 @@ class TestSystem < Test::Unit::TestCase
end
end
def test_syntax2
if (dir = File.dirname(File.dirname(File.dirname(__FILE__)))) == '.'
dir = ""
else
dir << "/"
end
for script in Dir["#{dir}{lib,sample,ext,test}/**/*.rb"].sort
unless valid_syntax2? IO::read(script), script
STDERR.puts script
flunk("syntax error: #{script}")
end
end
end
def test_empty_evstr
assert_equal("", eval('"#{}"', nil, __FILE__, __LINE__), "[ruby-dev:25113]")
end