Sha256: c2d9e71f202bfa2f50ae5a55fb935f9ad2cb496d4348da38e542219ad86690b2

Contents?: true

Size: 942 Bytes

Versions: 1

Compression:

Stored size: 942 Bytes

Contents

#  _____         _
# |_   _|__  ___| |_
#   | |/ _ \/ __| __|
#   | |  __/\__ \ |_
#   |_|\___||___/\__|
#
# for lib/facets/more/nilcomparable.rb
#
# Extracted Tue Jun 06 09:30:19 EDT 2006
# Unit Tools Reap Test Extractor
#

require 'facets/more/nilcomparable.rb'


  require 'test/unit'

  class Mock < String
    alias_method :compare_without_nil, :<=>
    def <=>( other )
      return 1 if other.nil?
      compare_without_nil( other )
    end
  end

  class TC_NilClass_Comparable < Test::Unit::TestCase

    def test001
      assert_equal( 0, nil <=> nil )
      assert_equal( -1, nil <=> 4 )
      assert_equal( -1, nil <=> "a" )
      assert_equal( -1, nil <=> Object.new )
      assert_equal( 0, nil.cmp(nil) )
      assert( nil < 4 )
    end

    def test002
      m = Mock.new("A")
      assert_equal( 1, m <=> nil )
      assert_equal( -1, m <=> "B" )
      #assert_equal( 1, m.cmp(nil) )
      assert( m > nil )
    end

  end


Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
facets-1.4.1 test/lib/facets/more/test_nilcomparable.rb