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

ruby-changes:36901

From: nobu <ko1@a...>
Date: Thu, 25 Dec 2014 10:09:26 +0900 (JST)
Subject: [ruby-changes:36901] nobu:r48982 (trunk): console.c: get rid of NameError

nobu	2014-12-25 10:09:17 +0900 (Thu, 25 Dec 2014)

  New Revision: 48982

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

  Log:
    console.c: get rid of NameError
    
    * ext/io/console/console.c (console_dev): id_console is not a
      constant name, use rb_const_remove() to get rid of NameError.

  Modified files:
    trunk/ChangeLog
    trunk/ext/io/console/console.c
    trunk/test/io/console/test_io_console.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 48981)
+++ ChangeLog	(revision 48982)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Dec 25 10:09:14 2014  Nobuyoshi Nakada  <nobu@r...>
+
+	* ext/io/console/console.c (console_dev): id_console is not a
+	  constant name, use rb_const_remove() to get rid of NameError.
+
 Thu Dec 25 09:18:55 2014  NAKAMURA Usaku  <usa@r...>
 
 	* test/resolv/test_dns.rb (TestResolvDNS#test_query_ipv4_address):
Index: ext/io/console/console.c
===================================================================
--- ext/io/console/console.c	(revision 48981)
+++ ext/io/console/console.c	(revision 48982)
@@ -647,7 +647,7 @@ console_dev(VALUE klass) https://github.com/ruby/ruby/blob/trunk/ext/io/console/console.c#L647
 	    if ((fptr = RFILE(con)->fptr) && GetReadFD(fptr) != -1)
 		return con;
 	}
-	rb_mod_remove_const(klass, ID2SYM(id_console));
+	rb_const_remove(klass, id_console);
     }
     {
 	VALUE args[2];
Index: test/io/console/test_io_console.rb
===================================================================
--- test/io/console/test_io_console.rb	(revision 48981)
+++ test/io/console/test_io_console.rb	(revision 48982)
@@ -218,21 +218,22 @@ class TestIO_Console < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/test/io/console/test_io_console.rb#L218
   end
 
   if IO.console
+    def test_close
+      IO.console.close
+      assert_kind_of(IO, IO.console)
+      assert_nothing_raised(IOError) {IO.console.fileno}
+    end
+
     def test_sync
       assert(IO.console.sync, "console should be unbuffered")
     end
   else
+    def test_close
+      assert_equal(["true"], run_pty("IO.console.close; p IO.console.fileno >= 0"))
+    end
+
     def test_sync
-      r, w, pid = PTY.spawn(EnvUtil.rubybin, "-rio/console", "-e", "p IO.console.class")
-    rescue RuntimeError
-      skip $!
-    else
-      con = r.gets.chomp
-      Process.wait(pid)
-      assert_match("File", con)
-    ensure
-      r.close if r
-      w.close if w
+      assert_equal(["true"], run_pty("p IO.console.sync"))
     end
   end
 
@@ -247,6 +248,19 @@ class TestIO_Console < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/test/io/console/test_io_console.rb#L248
     m.close if m
     s.close if s
   end
+
+  def run_pty(src)
+    r, w, pid = PTY.spawn(EnvUtil.rubybin, "-rio/console", "-e", src)
+  rescue RuntimeError
+    skip $!
+  else
+    result = r.readlines(&:chomp)
+    Process.wait(pid)
+    yield result
+  ensure
+    r.close if r
+    w.close if w
+  end
 end if defined?(PTY) and defined?(IO::console)
 
 class TestIO_Console < Test::Unit::TestCase

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

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