示例#1
0
 @Test
 public void right_A$() throws Exception {
   Either<String, Integer> target = Left.apply("foo");
   Option<Integer> actual = target.right();
   assertThat(actual.isDefined(), is(false));
   assertThat(actual.getOrNull(), is(nullValue()));
 }
示例#2
0
 @Test
 public void toString_A$() throws Exception {
   Either<String, Integer> target = Left.apply("foo");
   String actual = target.toString();
   String expected = "Left(foo)";
   assertThat(actual, is(equalTo(expected)));
 }
示例#3
0
 @Test
 public void left_A$() throws Exception {
   Either<String, Integer> target = Left.apply("foo");
   Option<String> actual = target.left();
   assertThat(actual.isDefined(), is(true));
   assertThat(actual.getOrNull(), is(equalTo("foo")));
 }
示例#4
0
 @Test
 public void isRight_A$() throws Exception {
   Either<String, Integer> target = Left.apply("foo");
   boolean actual = target.isRight();
   boolean expected = false;
   assertThat(actual, is(equalTo(expected)));
 }
示例#5
0
 @Test
 public void swap_A$() throws Exception {
   Either<String, Integer> target = Left.apply("foo");
   Either<Integer, String> swapped = target.swap();
   Option<String> right = swapped.right();
   assertThat(right.isDefined(), is(true));
   assertThat(right.getOrNull(), is(equalTo("foo")));
 }
示例#6
0
 @Test
 public void mergeToLeft_A$Function1() throws Exception {
   String value = "xxx";
   Either<String, Integer> target = Left.apply(value);
   Function1<Integer, String> rightToLeft =
       new F1<Integer, String>() {
         public String apply(Integer v) {
           return v.toString();
         }
       };
   String actual = target.mergeToLeft(rightToLeft);
   String expected = "xxx";
   assertThat(actual, is(equalTo(expected)));
 }
示例#7
0
 @Test
 public void mergeToRight_A$Function1() throws Exception {
   String value = "xxx";
   Either<String, Integer> target = Left.apply(value);
   Function1<String, Integer> leftToRight =
       new F1<String, Integer>() {
         public Integer apply(String v) throws Exception {
           return v.length();
         }
       };
   Integer actual = target.mergeToRight(leftToRight);
   Integer expected = 3;
   assertThat(actual, is(equalTo(expected)));
 }
示例#8
0
 @Test
 public void __A$Option() throws Exception {
   Either<String, Integer> target = Left.apply(Option.apply("foo"));
   assertThat(target, notNullValue());
 }