24 lines
613 B
Java
24 lines
613 B
Java
/**
|
|
* Copyright (C) 2009-2016 Typesafe Inc. <http://www.typesafe.com>
|
|
*/
|
|
|
|
package akka.japi.pf;
|
|
|
|
import org.junit.Test;
|
|
import scala.PartialFunction;
|
|
|
|
import static org.junit.Assert.*;
|
|
|
|
public class PFBuilderTest {
|
|
@Test
|
|
public void pfbuilder_matchAny_should_infer_declared_input_type_for_lambda() {
|
|
PartialFunction<String,Integer> pf = new PFBuilder<String,Integer>()
|
|
.matchEquals("hello", s -> 1)
|
|
.matchAny(s -> Integer.valueOf(s))
|
|
.build();
|
|
|
|
assertTrue(pf.isDefinedAt("hello"));
|
|
assertTrue(pf.isDefinedAt("42"));
|
|
assertEquals(42, pf.apply("42").intValue());
|
|
}
|
|
}
|