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

ruby-changes:28336

From: nagachika <ko1@a...>
Date: Sat, 20 Apr 2013 02:39:57 +0900 (JST)
Subject: [ruby-changes:28336] nagachika:r40388 (ruby_2_0_0): merge revision(s) 40117,40118,40333: [Backport #8222]

nagachika	2013-04-20 02:39:44 +0900 (Sat, 20 Apr 2013)

  New Revision: 40388

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

  Log:
    merge revision(s) 40117,40118,40333: [Backport #8222]
    
    * test/test_curses.rb: tests for getch.
    * ext/curses/curses.c (Init_curses): fix implementation function,
      crmode should be same as cbreak.  [ruby-core:54013] [Bug #8222]

  Modified directories:
    branches/ruby_2_0_0/
  Modified files:
    branches/ruby_2_0_0/ChangeLog
    branches/ruby_2_0_0/ext/curses/curses.c
    branches/ruby_2_0_0/test/test_curses.rb
    branches/ruby_2_0_0/version.h

Index: ruby_2_0_0/ChangeLog
===================================================================
--- ruby_2_0_0/ChangeLog	(revision 40387)
+++ ruby_2_0_0/ChangeLog	(revision 40388)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ChangeLog#L1
+Sat Apr 20 02:37:33 2013  Nobuyoshi Nakada  <nobu@r...>
+
+	* ext/curses/curses.c (Init_curses): fix implementation function,
+	  crmode should be same as cbreak.  [ruby-core:54013] [Bug #8222]
+
 Sat Apr 20 02:09:46 2013  Martin Bosslet  <Martin.Bosslet@g...>
 
 	* ext/openssl/ossl_ssl.c: Correct shutdown behavior w.r.t GC.
Index: ruby_2_0_0/ext/curses/curses.c
===================================================================
--- ruby_2_0_0/ext/curses/curses.c	(revision 40387)
+++ ruby_2_0_0/ext/curses/curses.c	(revision 40388)
@@ -2715,7 +2715,7 @@ Init_curses(void) https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ext/curses/curses.c#L2715
     rb_define_module_function(mCurses, "noraw", curses_noraw, 0);
     rb_define_module_function(mCurses, "cbreak", curses_cbreak, 0);
     rb_define_module_function(mCurses, "nocbreak", curses_nocbreak, 0);
-    rb_define_module_function(mCurses, "crmode", curses_nocbreak, 0);
+    rb_define_module_function(mCurses, "crmode", curses_cbreak, 0);
     rb_define_module_function(mCurses, "nocrmode", curses_nocbreak, 0);
     rb_define_module_function(mCurses, "nl", curses_nl, 0);
     rb_define_module_function(mCurses, "nonl", curses_nonl, 0);
Index: ruby_2_0_0/version.h
===================================================================
--- ruby_2_0_0/version.h	(revision 40387)
+++ ruby_2_0_0/version.h	(revision 40388)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/version.h#L1
 #define RUBY_VERSION "2.0.0"
 #define RUBY_RELEASE_DATE "2013-04-20"
-#define RUBY_PATCHLEVEL 153
+#define RUBY_PATCHLEVEL 154
 
 #define RUBY_RELEASE_YEAR 2013
 #define RUBY_RELEASE_MONTH 4
Index: ruby_2_0_0/test/test_curses.rb
===================================================================
--- ruby_2_0_0/test/test_curses.rb	(revision 40387)
+++ ruby_2_0_0/test/test_curses.rb	(revision 40388)
@@ -1,7 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/test_curses.rb#L1
 require 'test/unit'
+require_relative 'ruby/envutil'
 
 begin
   require 'curses'
+  require 'pty'
 rescue LoadError
 end
 
@@ -10,3 +12,49 @@ class TestCurses < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/test_curses.rb#L12
     assert_instance_of(String, Curses::VERSION)
   end
 end if defined? Curses
+
+class TestCurses
+  def run_curses(src, input = nil, timeout: 1)
+    PTY.spawn({"TERM"=>ENV["TERM"]||"dumb"}, EnvUtil.rubybin, "-e", <<-"src") {|r, w, pid|
+require 'timeout'
+require 'curses'
+include Curses
+init_screen
+begin
+  result = Timeout.timeout(#{timeout}) do
+    #{src}
+  end
+rescue Exception => e
+ensure
+  close_screen
+  puts "", [Marshal.dump([result, e])].pack('m').delete("\n")
+end
+src
+      if input
+        w.print(input)
+        w.flush
+      end
+      res = r.read
+      return unless res
+      res, error = Marshal.load(res[/(.*)\Z/, 1].unpack('m')[0])
+      raise error if error
+      return res
+    }
+  end
+
+  def test_getch
+    assert_equal("a", run_curses("getch", "a"))
+  end
+  def test_getch_cbreak
+    assert_equal("a", run_curses("cbreak; getch", "a"))
+  end
+  def test_getch_nocbreak
+    assert_raise(Timeout::Error) {run_curses("nocbreak; getch", "a")}
+  end
+  def test_getch_crmode
+    assert_equal("a", run_curses("crmode; getch", "a"))
+  end
+  def test_getch_nocrmode
+    assert_raise(Timeout::Error) {run_curses("nocrmode; getch", "a")}
+  end
+end if defined? TestCurses and defined? PTY

Property changes on: ruby_2_0_0
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r40117-40118,40333


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

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