summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-07-04 13:50:34 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-07-04 13:50:34 +0000
commit9f56a870af1c88430a053b4e50ba39c244a4bd57 (patch)
tree735b89f4663214f85e815433788f89e7b131d5e6 /test
parentc5de4d4cbd28c1763259f814c4cc29ea01e6af59 (diff)
* 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
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_syntax.rb22
-rw-r--r--test/ruby/test_system.rb19
2 files changed, 22 insertions, 19 deletions
diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb
new file mode 100644
index 0000000000..e25ad75f7a
--- /dev/null
+++ b/test/ruby/test_syntax.rb
@@ -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
diff --git a/test/ruby/test_system.rb b/test/ruby/test_system.rb
index 24b6a0d235..358fa54ef8 100644
--- a/test/ruby/test_system.rb
+++ b/test/ruby/test_system.rb
@@ -3,17 +3,6 @@ require 'tmpdir'
require_relative 'envutil'
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
ruby = EnvUtil.rubybin
assert_equal("foobar\n", `echo foobar`)
@@ -99,14 +88,6 @@ class TestSystem < Test::Unit::TestCase
}
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
assert_equal("", eval('"#{}"', nil, __FILE__, __LINE__), "[ruby-dev:25113]")
end