示例#1
0
 public void testNestedLambdas() throws Exception {
   Function<String, Function<String, String>> f = (x) -> (y) -> x;
   assertEquals(f.apply("Foo").apply("Bar"), "Foo");
   Function<Integer, Function<Integer, Integer>> f2 = (x) -> (y) -> x;
   assertEquals(f2.apply(42).apply(43), Integer.valueOf(42));
   Function<Integer, Function<Integer, Integer>> f3 = (y) -> (x) -> x;
   assertEquals(f3.apply(43).apply(42), Integer.valueOf(42));
   Function<String, Function<String, Integer>> f4 = (x) -> (y) -> Integer.parseInt(x);
   assertEquals(f4.apply("42").apply("43"), Integer.valueOf(42));
   Function<String, Function<Integer, Integer>> f5 = (x) -> (y) -> Integer.parseInt(x);
   assertEquals(f5.apply("42").apply(43), Integer.valueOf(42));
   // Callable<Callable> c2 = () -> () -> 42;
   // assertEquals(c2.call().call(), 42);
   Supplier<Supplier> s2 = () -> () -> 42;
   assertEquals(s2.get().get(), 42);
 }
示例#2
0
 public void testBasicSupplier() throws Exception {
   Supplier s = () -> 42;
   assertEquals(42, s.get());
 }