summaryrefslogtreecommitdiff
path: root/test/ruby/test_system.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/ruby/test_system.rb')
-rw-r--r--test/ruby/test_system.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/ruby/test_system.rb b/test/ruby/test_system.rb
index fbed36ad57..7a6d35477a 100644
--- a/test/ruby/test_system.rb
+++ b/test/ruby/test_system.rb
@@ -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