@Test public void analyzingTwoArgumentLambdaWithDefaultValue() throws Exception { class C { void m() { λ(n, s = "", null); } } LambdaAnalyzer lambda = lambdaIn(C.class); assertEquals(list("n", "s"), list(lambda.parameters.keySet())); assertEquals(list(INT_TYPE, getType(String.class)), lambda.getParameterTypes()); assertFalse(lambda.parametersWithDefaultValue.contains("n")); assertTrue(lambda.parametersWithDefaultValue.contains("s")); assertTrue(lambda.parameterDefaultValueNeedsBoxing("n")); assertFalse(lambda.parameterDefaultValueNeedsBoxing("s")); }
@Test public void analyzingLambdaCreatedFromPrimitiveLambdaThatHasDefaultValue() throws Exception { class C { void m() { LambdaPrimitives.λ(d = 2, 0); } } LambdaAnalyzer lambda = lambdaIn(C.class); assertEquals(getType(Fn1DtoI.class), lambda.lambdaType); assertEquals(list(DOUBLE_TYPE), list(lambda.sam.getArgumentTypes())); assertEquals(list(DOUBLE_TYPE), lambda.getParameterTypes()); assertTrue(lambda.parametersWithDefaultValue.contains("d")); assertTrue(lambda.parameterDefaultValueNeedsBoxing("d")); }
@Test public void analyzingOneArgumentLambdaWithDefaultValue() throws Exception { class C { void m() { λ(n = 2, null); } } LambdaAnalyzer lambda = lambdaIn(C.class); assertTrue(lambda.locals.isEmpty()); assertTrue(lambda.getMutableLocals().isEmpty()); assertEquals(list("n"), list(lambda.parameters.keySet())); assertEquals(list(INT_TYPE), lambda.getParameterTypes()); assertTrue(lambda.parametersWithDefaultValue.contains("n")); assertTrue(lambda.parameterDefaultValueNeedsBoxing("n")); }