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

ruby-changes:14598

From: akr <ko1@a...>
Date: Wed, 27 Jan 2010 21:10:57 +0900 (JST)
Subject: [ruby-changes:14598] Ruby:r26441 (trunk): suppress warnings.

akr	2010-01-27 21:04:17 +0900 (Wed, 27 Jan 2010)

  New Revision: 26441

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

  Log:
    suppress warnings.

  Modified files:
    trunk/test/ruby/test_system.rb
    trunk/test/ruby/test_yield.rb

Index: test/ruby/test_system.rb
===================================================================
--- test/ruby/test_system.rb	(revision 26440)
+++ test/ruby/test_system.rb	(revision 26441)
@@ -37,7 +37,7 @@
       tmp = open(tmpfilename, "w")
       tmp.print "this is a leading junk\n";
       tmp.print "#! /usr/local/bin/ruby -s\n";
-      tmp.print "print $zzz\n";
+      tmp.print "print $zzz if defined? $zzz\n";
       tmp.print "__END__\n";
       tmp.print "this is a trailing junk\n";
       tmp.close
@@ -49,7 +49,7 @@
       tmp.print "#! /non/exist\\interpreter?/./to|be:ignored\n";
       tmp.print "this is a leading junk\n";
       tmp.print "#! /usr/local/bin/ruby -s\n";
-      tmp.print "print $zzz\n";
+      tmp.print "print $zzz if defined? $zzz\n";
       tmp.print "__END__\n";
       tmp.print "this is a trailing junk\n";
       tmp.close
Index: test/ruby/test_yield.rb
===================================================================
--- test/ruby/test_yield.rb	(revision 26440)
+++ test/ruby/test_yield.rb	(revision 26441)
@@ -1,4 +1,5 @@
 require 'test/unit'
+require 'stringio'
 
 class TestRubyYield < Test::Unit::TestCase
 
@@ -209,8 +210,8 @@
     if args.last == []
       args = args[0...-1]
     end
-    code = "emu_return_args #{args.map {|a| a.join('') }.join(",")}"
-    eval code
+    code = "emu_return_args(#{args.map {|a| a.join('') }.join(",")})"
+    eval code, nil, 'generated_code_in_emu_eval_args'
   end
 
   def emu_bind_single(arg, param, result_binding)
@@ -324,6 +325,16 @@
     }
   end
 
+  def disable_stderr
+    begin
+      save_stderr = $stderr
+      $stderr = StringIO.new
+      yield
+    ensure
+      $stderr = save_stderr
+    end
+  end
+
   def check_nofork(t, islambda=false)
     t, vars = rename_var(t)
     t = t.subst('vars') { " [#{vars.join(",")}]" }
@@ -331,11 +342,13 @@
     s = t.to_s
     #print "#{s}\t\t"
     #STDOUT.flush
-    begin
-      eval_values = eval(s)
-    rescue ArgumentError
-      eval_values = ArgumentError
-    end
+    eval_values = disable_stderr {
+      begin
+        eval(s, nil, 'generated_code_in_check_nofork')
+      rescue ArgumentError
+        ArgumentError
+      end
+    }
     #success = emu_values == eval_values ? 'succ' : 'fail'
     #puts "eval:#{vs_ev.inspect[1...-1].delete(' ')}\temu:#{vs_emu.inspect[1...-1].delete(' ')}\t#{success}"
     assert_equal(emu_values, eval_values, s)
@@ -358,7 +371,10 @@
   def test_yield_enum
     syntax = Sentence.expand_syntax(Syntax)
     Sentence.each(syntax, :test_enum, 4) {|t|
-      r1, r2 = eval(t.to_s)
+      code = t.to_s
+      r1, r2 = disable_stderr {
+        eval(code, nil, 'generated_code_in_test_yield_enum')
+      }
       assert_equal(r1, r2, "#{t}")
     }
   end

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

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