Sha256: 2212c34f8f6a2ba8dde8c4d6ddc2690389316a2977659bf2271276c44d742e60

Contents?: true

Size: 1.92 KB

Versions: 9

Compression:

Stored size: 1.92 KB

Contents

  #  _____         _
  # |_   _|__  ___| |_
  #   | |/ _ \/ __| __|
  #   | |  __/\__ \ |
  #   |_|\___||___/\__|
  #
  # for lib/facets/boolean.rb
  #
  # Extracted Mon Sep 03 16:23:07 -0700 2007
  # w/ Test Extraction Ratchet
  #

 require 'facets/boolean.rb'



  require 'test/unit'


  class TestStringBoolean < Test::Unit::TestCase

    def test_to_b
      assert( 'true'.to_b )
      assert( 'True'.to_b )
      assert( 'yes'.to_b )
      assert( 'YES'.to_b )
      assert( 'on'.to_b )
      assert( 'ON'.to_b )
      assert( 't'.to_b )
      assert( '1'.to_b )
      assert( 'y'.to_b )
      assert( 'Y'.to_b )
      assert( '=='.to_b )
      assert( ! 'nil'.to_b )
      assert( ! 'false'.to_b )
      assert( ! 'blahblahtrueblah'.to_b )
      assert_equal( nil, 'nil'.to_b )
      assert_equal( nil, 'null'.to_b )
    end

  end


  class TestArrayBoolean < Test::Unit::TestCase

    def test_to_b
      a = []
      assert_equal( false, a.to_b )
    end

  end


  class TestNumericBoolean < Test::Unit::TestCase

    def test_to_b
      assert_equal( false, 0.to_b )
      assert_equal( true, 1.to_b )
    end

  end


  class TestKernelBoolean < Test::Unit::TestCase

    def test_to_b
      assert_equal( true, true.to_b )
      assert_equal( false, false.to_b )
      assert_equal( false, nil.to_b )
    end

    def test_false?
      assert( false.false? )
      assert( (1 == 2).false? )
      assert( ! (1 == 1).false? )
    end

    def test_true?
      assert( true.true? )
      assert( (1 == 1).true? )
      assert( ! (1 == 2).true? )
    end

    def test_bool?
      assert_equal( true, true.bool? )
      assert_equal( true, false.bool? )
      assert_equal( false, nil.bool? )
      assert_equal( false, 0.bool? )
    end

  end


  class TestBoolean < Test::Unit::TestCase

    def test_to_bool
      assert_equal( true, true.to_bool )
      assert_equal( false, false.to_bool )
      assert_equal( false, nil.to_bool )
    end

  end



Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
facets-2.0.0 test/unit/test_boolean.rb
facets-2.0.1 test/unit/test_boolean.rb
facets-2.0.2 test/unit/test_boolean.rb
facets-2.0.3 test/unit/test_boolean.rb
facets-2.0.4 test/unit/test_boolean.rb
facets-2.0.5 test/unit/test_boolean.rb
facets-2.1.0 test/unit/test_boolean.rb
facets-2.1.1 test/unit/test_boolean.rb
facets-2.1.2 test/unit/test_boolean.rb