summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--ext/curses/curses.c2
-rw-r--r--test/test_curses.rb48
-rw-r--r--version.h2
4 files changed, 55 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index c9ff762435..71538b4d8c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Sat Apr 20 02:37:33 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * 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@gmail.com>
* ext/openssl/ossl_ssl.c: Correct shutdown behavior w.r.t GC.
diff --git a/ext/curses/curses.c b/ext/curses/curses.c
index 175e32cff9..88b1bdb3aa 100644
--- a/ext/curses/curses.c
+++ b/ext/curses/curses.c
@@ -2715,7 +2715,7 @@ Init_curses(void)
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);
diff --git a/test/test_curses.rb b/test/test_curses.rb
index 03462d6f7e..d03a94173d 100644
--- a/test/test_curses.rb
+++ b/test/test_curses.rb
@@ -1,7 +1,9 @@
require 'test/unit'
+require_relative 'ruby/envutil'
begin
require 'curses'
+ require 'pty'
rescue LoadError
end
@@ -10,3 +12,49 @@ class TestCurses < Test::Unit::TestCase
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
diff --git a/version.h b/version.h
index 30dbc428fe..5fca50c8c5 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#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