Sha256: 0d8a80ac179e3a375de715d8598002b6fdda5327905c7e51bdfbf7971af034bd

Contents?: true

Size: 691 Bytes

Versions: 123

Compression:

Stored size: 691 Bytes

Contents

require 'test_helper'
require 'tins/xt/case_predicate'

module Tins
  class CasePredicateTest < Test::Unit::TestCase
    def test_case_predicate_failure
      assert_nil 4.case?(1, 2..3, 5...7)
    end

    def test_case_predicate_failure_is_a
      s = 'foo'
      assert_nil s.case?(Array, Hash)
      s = Class.new(String).new
      assert_nil s.case?(Array, Hash)
    end

    def test_case_predicate_success
      assert_equal 2..3, 3.case?(1, 2..3, 5...7)
    end

    def test_case_predicate_success_is_a
      s = 'foo'
      assert_equal String, s.case?(Array, Hash, String)
      s = Class.new(String).new
      assert_equal String, s.case?(Array, Hash, String)
    end
  end
end

Version data entries

123 entries across 109 versions & 8 rubygems

Version Path
tins-1.25.0 tests/case_predicate_test.rb
tdiary-5.1.1 vendor/bundle/ruby/2.7.0/gems/tins-1.24.1/tests/case_predicate_test.rb
tins-1.24.1 tests/case_predicate_test.rb
tins-1.24.0 tests/case_predicate_test.rb
tins-1.23.0 tests/case_predicate_test.rb
tdiary-5.1.0 vendor/bundle/gems/tins-1.22.2/tests/case_predicate_test.rb
tins-1.22.2 tests/case_predicate_test.rb
tins-1.22.1 tests/case_predicate_test.rb
tins-1.22.0 tests/case_predicate_test.rb
tins-1.21.1 tests/case_predicate_test.rb
tins-1.21.0 tests/case_predicate_test.rb
tins-1.20.3 tests/case_predicate_test.rb
tdiary-5.0.13 vendor/bundle/gems/tins-1.20.2/tests/case_predicate_test.rb
tdiary-5.0.12.1 vendor/bundle/gems/tins-1.20.2/tests/case_predicate_test.rb
tdiary-5.0.11 vendor/bundle/gems/tins-1.20.2/tests/case_predicate_test.rb
tdiary-5.0.11 vendor/bundle/gems/tins-1.16.3/tests/case_predicate_test.rb
tins-1.20.2 tests/case_predicate_test.rb
tins-1.20.1 tests/case_predicate_test.rb
tins-1.20.0 tests/case_predicate_test.rb
tins-1.19.0 tests/case_predicate_test.rb