Пример #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 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")));
 }
Пример #3
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")));
 }
Пример #4
0
 @Test
 public void flatMap_A$Function1() throws Exception {
   String value = "vvv";
   Some<String> target = new Some<String>(value);
   F1<String, Option<String>> f =
       new F1<String, Option<String>>() {
         @Override
         public Option<String> apply(String v1) {
           return Option.apply(v1);
         }
       };
   Option<String> actual = target.flatMap(f);
   assertThat(actual.isDefined(), is(true));
 }
Пример #5
0
 @Test
 public void filter_A$Function1() throws Exception {
   String value = "vvv";
   Some<String> target = new Some<String>(value);
   F1<String, Boolean> f =
       new F1<String, Boolean>() {
         @Override
         public Boolean apply(String v1) {
           return true;
         }
       };
   Option<String> actual = target.filter(f);
   assertThat(actual.isDefined(), is(true));
 }