Sha256: 198ab40e0ecbfe018f483f98f22aa2b570b650b9e2a020144d2b6566430b7057

Contents?: true

Size: 942 Bytes

Versions: 1

Compression:

Stored size: 942 Bytes

Contents

#  _____         _
# |_   _|__  ___| |_
#   | |/ _ \/ __| __|
#   | |  __/\__ \ |_
#   |_|\___||___/\__|
#
# for lib/facets/more/nilcomparable.rb
#
# Extracted Fri Sep 08 20:20:32 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.7.46 test/lib/facets/more/test_nilcomparable.rb