Sha256: b22db6cc0cf1cdef025ce1c42a03e3687ce9b6838898d5fe82a2e555f88ccd19
Contents?: true
Size: 868 Bytes
Versions: 5
Compression:
Stored size: 868 Bytes
Contents
require 'test_helper' class EitherTest < MiniTest::Unit::TestCase def test_lift_right assert_equal 3, Right(3).value end def test_lift_left assert_equal "error", Left("error").value end def test_bind_right v = Right(1) >-> x { if x == 1 Right(x + 90) else Left("FAIL") end } assert_equal Right(91), v end def test_bind_left v = Left("error") >-> x { Right(x * 20) } assert_equal Left("error"), v end def test_fmap_right assert_equal Right(2), Right(1).fmap { |x| x * 2 } end def test_fmap_left assert_equal Left("error"), Left("error").fmap { |x| x * 2 } end def test_to_maybe_right assert_equal Some(2), Right(1).fmap { |x| x * 2 }.to_maybe end def test_to_maybe_left assert_equal None(), Left("error").fmap { |x| x * 2 }.to_maybe end end
Version data entries
5 entries across 5 versions & 1 rubygems