Skip to content

Commit 1a5e163

Browse files
committed
Leveraging MonadErrorAssert in EitherTTest
1 parent de1ae8a commit 1a5e163

File tree

1 file changed

+5
-9
lines changed
  • src/test/java/com/jnape/palatable/lambda/monad/transformer/builtin

1 file changed

+5
-9
lines changed

src/test/java/com/jnape/palatable/lambda/monad/transformer/builtin/EitherTTest.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import com.jnape.palatable.lambda.adt.Either;
44
import com.jnape.palatable.lambda.adt.Unit;
5-
import com.jnape.palatable.lambda.functions.specialized.Pure;
65
import com.jnape.palatable.lambda.functor.builtin.Identity;
76
import com.jnape.palatable.lambda.io.IO;
87
import com.jnape.palatable.traitor.annotations.TestTraits;
@@ -28,9 +27,9 @@
2827
import static com.jnape.palatable.lambda.io.IO.io;
2928
import static com.jnape.palatable.lambda.monad.transformer.builtin.EitherT.eitherT;
3029
import static com.jnape.palatable.lambda.monad.transformer.builtin.EitherT.liftEitherT;
31-
import static com.jnape.palatable.lambda.monad.transformer.builtin.EitherT.pureEitherT;
3230
import static com.jnape.palatable.traitor.framework.Subjects.subjects;
3331
import static org.junit.Assert.assertEquals;
32+
import static testsupport.assertion.MonadErrorAssert.assertLaws;
3433

3534
@RunWith(Traits.class)
3635
public class EitherTTest {
@@ -78,12 +77,9 @@ public void staticPure() {
7877

7978
@Test
8079
public void monadError() {
81-
Pure<EitherT<Identity<?>, String, ?>> pure = pureEitherT(pureIdentity());
82-
83-
assertEquals(eitherT(new Identity<>(left("Hello"))),
84-
pure.<Integer, EitherT<Identity<?>, String, Integer>>apply(1).throwError("Hello"));
85-
assertEquals(pure.apply(5),
86-
EitherT.<Identity<?>, String, Integer>eitherT(new Identity<>(left("Hello")))
87-
.catchError(s -> pure.apply(s.length())));
80+
assertLaws(subjects(eitherT(new Identity<>(right(1))),
81+
eitherT(new Identity<>(left("")))),
82+
"bar",
83+
str -> eitherT(new Identity<>(right(str.length()))));
8884
}
8985
}

0 commit comments

Comments
 (0)