ruby-changes:4687
From: ko1@a...
Date: Thu, 24 Apr 2008 22:38:17 +0900 (JST)
Subject: [ruby-changes:4687] mame - Ruby:r16181 (trunk): * test/ruby/test_comparable.rb: new tests for Comparable, to achieve
mame 2008-04-24 22:38:01 +0900 (Thu, 24 Apr 2008) New Revision: 16181 Added files: trunk/test/ruby/test_comparable.rb Modified files: trunk/ChangeLog Log: * test/ruby/test_comparable.rb: new tests for Comparable, to achieve 100% test coverage of compar.c. http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/ruby/test_comparable.rb?revision=16181&view=markup http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/ruby/test_comparable.rb?r1=16181&r2=16180&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=16181&r2=16180&diff_format=u Index: ChangeLog =================================================================== --- ChangeLog (revision 16180) +++ ChangeLog (revision 16181) @@ -1,3 +1,8 @@ +Thu Apr 24 22:34:52 2008 Yusuke Endoh <mame@t...> + + * test/ruby/test_comparable.rb: new tests for Comparable, to achieve + 100% test coverage of compar.c. + Thu Apr 24 17:19:01 2008 Yukihiro Matsumoto <matz@r...> * ruby.c (process_options): set safe_level before loading script. Index: test/ruby/test_comparable.rb =================================================================== --- test/ruby/test_comparable.rb (revision 0) +++ test/ruby/test_comparable.rb (revision 16181) @@ -0,0 +1,66 @@ +require 'test/unit' + +class TestComparable < Test::Unit::TestCase + def setup + @o = Object.new + @o.extend(Comparable) + end + + def test_equal + def @o.<=>(x); 0; end + assert_equal(true, @o == nil) + def @o.<=>(x); 1; end + assert_equal(false, @o == nil) + def @o.<=>(x); raise; end + assert_equal(false, @o == nil) + end + + def test_gt + def @o.<=>(x); 1; end + assert_equal(true, @o > nil) + def @o.<=>(x); 0; end + assert_equal(false, @o > nil) + def @o.<=>(x); -1; end + assert_equal(false, @o > nil) + end + + def test_ge + def @o.<=>(x); 1; end + assert_equal(true, @o >= nil) + def @o.<=>(x); 0; end + assert_equal(true, @o >= nil) + def @o.<=>(x); -1; end + assert_equal(false, @o >= nil) + end + + def test_lt + def @o.<=>(x); 1; end + assert_equal(false, @o < nil) + def @o.<=>(x); 0; end + assert_equal(false, @o < nil) + def @o.<=>(x); -1; end + assert_equal(true, @o < nil) + end + + def test_le + def @o.<=>(x); 1; end + assert_equal(false, @o <= nil) + def @o.<=>(x); 0; end + assert_equal(true, @o <= nil) + def @o.<=>(x); -1; end + assert_equal(true, @o <= nil) + end + + def test_between + def @o.<=>(x); 0 <=> x end + assert_equal(false, @o.between?(1, 2)) + assert_equal(false, @o.between?(-2, -1)) + assert_equal(true, @o.between?(-1, 1)) + assert_equal(true, @o.between?(0, 0)) + end + + def test_err + assert_raise(ArgumentError) { 1.0 < nil } + assert_raise(ArgumentError) { 1.0 < Object.new } + end +end Property changes on: test/ruby/test_comparable.rb ___________________________________________________________________ Name: svn:eol-style + LF -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/