2015-11-23 13:16:39 +01:00
|
|
|
/**
|
2017-01-04 17:37:10 +01:00
|
|
|
* Copyright (C) 2009-2017 Lightbend Inc. <http://www.lightbend.com>
|
2015-11-23 13:16:39 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
package akka.japi.pf;
|
|
|
|
|
|
|
|
|
|
import org.junit.Test;
|
2016-04-06 01:23:21 +02:00
|
|
|
import org.scalatest.junit.JUnitSuite;
|
2015-11-23 13:16:39 +01:00
|
|
|
import scala.PartialFunction;
|
|
|
|
|
|
|
|
|
|
import static org.junit.Assert.*;
|
|
|
|
|
|
2016-04-06 01:23:21 +02:00
|
|
|
public class PFBuilderTest extends JUnitSuite {
|
|
|
|
|
|
2015-11-23 13:16:39 +01:00
|
|
|
@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());
|
|
|
|
|
}
|
|
|
|
|
}
|