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.38.0 tests/case_predicate_test.rb
tins-1.37.1 tests/case_predicate_test.rb
tins-1.37.0 tests/case_predicate_test.rb
tins-1.36.1 tests/case_predicate_test.rb
tins-1.36.0 tests/case_predicate_test.rb
tins-1.35.0 tests/case_predicate_test.rb
tins-1.34.0 tests/case_predicate_test.rb
tins-1.33.0 tests/case_predicate_test.rb
tdiary-5.2.4 vendor/bundle/ruby/3.1.0/gems/tins-1.31.1/tests/case_predicate_test.rb
tins-1.32.1 tests/case_predicate_test.rb
tins-1.32.0 tests/case_predicate_test.rb
tdiary-5.2.3 vendor/bundle/ruby/3.1.0/gems/tins-1.31.1/tests/case_predicate_test.rb
tdiary-5.2.2 vendor/bundle/ruby/3.1.0/gems/tins-1.31.1/tests/case_predicate_test.rb
tins-1.31.1 tests/case_predicate_test.rb
tdiary-5.2.1 vendor/bundle/ruby/3.1.0/gems/tins-1.31.0/tests/case_predicate_test.rb
tins-1.31.0 tests/case_predicate_test.rb
tins-1.30.0 tests/case_predicate_test.rb
tdiary-5.2.0 vendor/bundle/ruby/3.0.0/gems/tins-1.29.1/tests/case_predicate_test.rb
tdiary-5.2.0 vendor/bundle/ruby/2.7.0/gems/tins-1.29.1/tests/case_predicate_test.rb
tdiary-5.1.7 vendor/bundle/ruby/2.7.0/gems/tins-1.29.1/tests/case_predicate_test.rb