[前][次][番号順一覧][スレッド一覧]

ruby-changes:23743

From: naruse <ko1@a...>
Date: Fri, 25 May 2012 21:20:09 +0900 (JST)
Subject: [ruby-changes:23743] naruse:r35794 (ruby_1_9_3): merge revision(s) 34910:

naruse	2012-05-25 21:20:00 +0900 (Fri, 25 May 2012)

  New Revision: 35794

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=35794

  Log:
    merge revision(s) 34910:
    
    assert_valid_syntax
    
    * test/ruby/test_syntax.rb (assert_valid_syntax): new assertion to
      validate syntax.

  Modified files:
    branches/ruby_1_9_3/test/ruby/test_syntax.rb
    branches/ruby_1_9_3/version.h

Index: ruby_1_9_3/version.h
===================================================================
--- ruby_1_9_3/version.h	(revision 35793)
+++ ruby_1_9_3/version.h	(revision 35794)
@@ -1,5 +1,5 @@
 #define RUBY_VERSION "1.9.3"
-#define RUBY_PATCHLEVEL 230
+#define RUBY_PATCHLEVEL 231
 
 #define RUBY_RELEASE_DATE "2012-05-25"
 #define RUBY_RELEASE_YEAR 2012
Index: ruby_1_9_3/test/ruby/test_syntax.rb
===================================================================
--- ruby_1_9_3/test/ruby/test_syntax.rb	(revision 35793)
+++ ruby_1_9_3/test/ruby/test_syntax.rb	(revision 35794)
@@ -1,21 +1,24 @@
 require 'test/unit'
 
 class TestSyntax < Test::Unit::TestCase
-  def valid_syntax?(code, fname)
+  def assert_valid_syntax(code, fname, mesg = 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
+    verbose, $VERBOSE = $VERBOSE, nil
+    assert_nothing_raised(SyntaxError, mesg) do
+      assert_equal(:ok, catch {|tag| eval(code, binding, fname, 0)}, mesg)
+    end
+  ensure
+    $VERBOSE = verbose
   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), script)
+        assert_valid_syntax(IO::read(script), script)
       end
     end
   end
@@ -57,11 +60,6 @@
     assert_valid_syntax("def self; :foo; end", __FILE__, bug6403)
   end
 
-  def test_reserved_method_no_args
-    bug6403 = '[ruby-dev:45626]'
-    assert_valid_syntax("def self; :foo; end", __FILE__, bug6403)
-  end
-
   private
 
   def make_tmpsrc(f, src)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]