~ubuntu-branches/ubuntu/quantal/ruby1.9.1/quantal

« back to all changes in this revision

Viewing changes to test/ruby/test_comparable.rb

  • Committer: Bazaar Package Importer
  • Author(s): Lucas Nussbaum
  • Date: 2010-07-31 17:08:39 UTC
  • mfrom: (1.1.4 upstream) (8.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20100731170839-j034dmpdqt1cc4p6
Tags: 1.9.2~svn28788-1
* New release based on upstream snapshot from the 1.9.2 branch,
  after 1.9.2 RC2. That branch is (supposed to be) binary-compatible
  with the 1.9.1 branch.
  + Builds fine on i386. Closes: #580852.
* Upgrade to Standards-Version: 3.9.1. No changes needed.
* Updated generated incs.
* Patches that still need work:
  + Unclear status, need more investigation:
   090729_fix_Makefile_deps.dpatch
   090803_exclude_rdoc.dpatch
   203_adjust_base_of_search_path.dpatch
   902_define_YAML_in_yaml_stringio.rb.dpatch
   919_common.mk_tweaks.dpatch
   931_libruby_suffix.dpatch
   940_test_thread_mutex_sync_shorter.dpatch
  + Maybe not needed anymore, keeping but not applying.
   102_skip_test_copy_stream.dpatch (test doesn't block anymore?)
   104_skip_btest_io.dpatch (test doesn't block anymore?)
   201_gem_prelude.dpatch (we don't use that rubygems anyway?)
   202_gem_default_dir.dpatch (we don't use that rubygems anyway?)
   940_test_file_exhaustive_fails_as_root.dpatch
   940_test_priority_fails.dpatch
   100518_load_libc_libm.dpatch
* Add disable-tests.diff: disable some tests that cause failures on FreeBSD.
  Closes: #590002, #543805, #542927.
* However, many new failures on FreeBSD. Since that version is still an
  improvement, add the check that makes test suite failures non-fatal on
  FreeBSD again. That still needs to be investigated.
* Re-add 903_skip_base_ruby_check.dpatch
* Add build-dependency on ruby1.8 and drop all pre-generated files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
    @o = Object.new
6
6
    @o.extend(Comparable)
7
7
  end
 
8
  def cmp(b)
 
9
    class << @o; self; end.class_eval {
 
10
      undef :<=>
 
11
      define_method(:<=>, b)
 
12
    }
 
13
  end
8
14
 
9
15
  def test_equal
10
 
    def @o.<=>(x); 0; end
 
16
    cmp->(x) do 0; end
11
17
    assert_equal(true, @o == nil)
12
 
    def @o.<=>(x); 1; end
 
18
    cmp->(x) do 1; end
13
19
    assert_equal(false, @o == nil)
14
 
    def @o.<=>(x); raise; end
 
20
    cmp->(x) do raise; end
15
21
    assert_equal(false, @o == nil)
16
22
  end
17
23
 
18
24
  def test_gt
19
 
    def @o.<=>(x); 1; end
 
25
    cmp->(x) do 1; end
20
26
    assert_equal(true, @o > nil)
21
 
    def @o.<=>(x); 0; end
 
27
    cmp->(x) do 0; end
22
28
    assert_equal(false, @o > nil)
23
 
    def @o.<=>(x); -1; end
 
29
    cmp->(x) do -1; end
24
30
    assert_equal(false, @o > nil)
25
31
  end
26
32
 
27
33
  def test_ge
28
 
    def @o.<=>(x); 1; end
29
 
    assert_equal(true, @o >= nil)
30
 
    def @o.<=>(x); 0; end
31
 
    assert_equal(true, @o >= nil)
32
 
    def @o.<=>(x); -1; end
 
34
    cmp->(x) do 1; end
 
35
    assert_equal(true, @o >= nil)
 
36
    cmp->(x) do 0; end
 
37
    assert_equal(true, @o >= nil)
 
38
    cmp->(x) do -1; end
33
39
    assert_equal(false, @o >= nil)
34
40
  end
35
41
 
36
42
  def test_lt
37
 
    def @o.<=>(x); 1; end
38
 
    assert_equal(false, @o < nil)
39
 
    def @o.<=>(x); 0; end
40
 
    assert_equal(false, @o < nil)
41
 
    def @o.<=>(x); -1; end
 
43
    cmp->(x) do 1; end
 
44
    assert_equal(false, @o < nil)
 
45
    cmp->(x) do 0; end
 
46
    assert_equal(false, @o < nil)
 
47
    cmp->(x) do -1; end
42
48
    assert_equal(true, @o < nil)
43
49
  end
44
50
 
45
51
  def test_le
46
 
    def @o.<=>(x); 1; end
 
52
    cmp->(x) do 1; end
47
53
    assert_equal(false, @o <= nil)
48
 
    def @o.<=>(x); 0; end
 
54
    cmp->(x) do 0; end
49
55
    assert_equal(true, @o <= nil)
50
 
    def @o.<=>(x); -1; end
 
56
    cmp->(x) do -1; end
51
57
    assert_equal(true, @o <= nil)
52
58
  end
53
59
 
54
60
  def test_between
55
 
    def @o.<=>(x); 0 <=> x end
 
61
    cmp->(x) do 0 <=> x end
56
62
    assert_equal(false, @o.between?(1, 2))
57
63
    assert_equal(false, @o.between?(-2, -1))
58
64
    assert_equal(true, @o.between?(-1, 1))