Sha256: 1ad5b614062bc86888f1245ddc99abda5cb90cbfa43c9e38d2c92baacb0dba37

Contents?: true

Size: 1.18 KB

Versions: 16

Compression:

Stored size: 1.18 KB

Contents

# Test lib/more/add/facets/compare_on.rb

require 'facets/comparable/comparable.rb'
require 'test/unit'

class TestModuleCompare < Test::Unit::TestCase

  def test_comparable_with_arguments
    c = Class.new
    c.class_eval {
      include Comparable(:a,:b)
      attr_accessor :a, :b
      def initialize(a,b)
        @a=a; @b=b
      end
    }
    a = [c.new(10,20),c.new(10,30)]
    assert_equal( a, a.sort )
    a = [c.new(10,30),c.new(10,20)]
    assert_equal( a.reverse, a.sort )
    a = [c.new(10,10),c.new(20,10)]
    assert_equal( a, a.sort )
    a = [c.new(20,10),c.new(10,10)]
    assert_equal( a.reverse, a.sort )
    a = [c.new(10,30),c.new(20,10)]
    assert_equal( a, a.sort )
  end

=begin
  def test_sort_on_old
    c = Class.new
    c.class_eval {
      def initialize(a,b)
        @a=a; @b=b
      end
      sort_on :a,:b
    }
    a = [c.new(10,20),c.new(10,30)]
    assert_equal( a, a.sort )
    a = [c.new(10,30),c.new(10,20)]
    assert_equal( a.reverse, a.sort )
    a = [c.new(10,10),c.new(20,10)]
    assert_equal( a, a.sort )
    a = [c.new(20,10),c.new(10,10)]
    assert_equal( a.reverse, a.sort )
    a = [c.new(10,30),c.new(20,10)]
    assert_equal( a, a.sort )
  end
=end

end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
facets-2.8.4 test/core/comparable/test_comparable.rb
facets-2.8.3 test/core/comparable/test_comparable.rb
facets-2.8.2 test/core/comparable/test_comparable.rb
facets-2.8.1 test/core/comparable/test_comparable.rb
facets-2.8.0 test/core/comparable/test_comparable.rb
facets-2.7.0 test/core/comparable/test_comparable.rb
facets-2.6.0 test/core/comparable/test_comparable.rb
facets-2.4.0 test/comparable/test_comparable.rb
facets-2.4.1 test/comparable/test_comparable.rb
facets-2.4.3 test/core/comparable/test_comparable.rb
facets-2.4.2 test/core/comparable/test_comparable.rb
facets-2.4.4 test/core/comparable/test_comparable.rb
facets-2.5.1 test/core/comparable/test_comparable.rb
facets-2.5.0 test/core/comparable/test_comparable.rb
facets-2.4.5 test/core/comparable/test_comparable.rb
facets-2.5.2 test/core/comparable/test_comparable.rb