Sha256: b42129f4f964dcbc9ab7e1f29eea8060ef6f75a05923828e8f82fabcf7773da5
Contents?: true
Size: 700 Bytes
Versions: 6
Compression:
Stored size: 700 Bytes
Contents
require 'test_helper' class TryTest < Minitest::Test def test_success assert_equal 2, Try { 10 / 5 }.value end def test_failure assert_kind_of ZeroDivisionError, Try { 10 / 0 }.exception end def test_to_maybe_success assert_equal Some(2), Try { 10 / 5 }.to_maybe end def test_to_maybe_failure assert_equal None(), Try { 10 / 0 }.to_maybe end def test_fmap_success assert_equal 4, Try { 10 / 5 }.fmap { |x| x * 2 }.value end def test_fmap_failure assert_kind_of ZeroDivisionError, Try { 10 / 0 }.fmap { |x| x * 2 }.exception end def test_bind try = Try { 20 / 10 } >-> number { Try { 10 / number } } assert_equal 5, try.value end end
Version data entries
6 entries across 6 versions & 1 rubygems