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

ruby-changes:28259

From: nagachika <ko1@a...>
Date: Mon, 15 Apr 2013 23:20:07 +0900 (JST)
Subject: [ruby-changes:28259] nagachika:r40311 (ruby_2_0_0): merge revision(s) 40117,40118: [Backport #8222]

nagachika	2013-04-15 23:19:55 +0900 (Mon, 15 Apr 2013)

  New Revision: 40311

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

  Log:
    merge revision(s) 40117,40118: [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 40310)
+++ ruby_2_0_0/ChangeLog	(revision 40311)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ChangeLog#L1
+Mon Apr 15 23:19:35 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]
+
 Mon Apr 15 00:25:00 2013  Tanaka Akira  <akr@f...>
 
 	* time.c (num_exact): use to_r method only if to_int method is
Index: ruby_2_0_0/ext/curses/curses.c
===================================================================
--- ruby_2_0_0/ext/curses/curses.c	(revision 40310)
+++ ruby_2_0_0/ext/curses/curses.c	(revision 40311)
@@ -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 40310)
+++ ruby_2_0_0/version.h	(revision 40311)
@@ -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-15"
-#define RUBY_PATCHLEVEL 136
+#define RUBY_PATCHLEVEL 137
 
 #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 40310)
+++ ruby_2_0_0/test/test_curses.rb	(revision 40311)
@@ -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(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


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

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