@Test
  public void analyzingTwoArgumentsLambda() throws Exception {
    class C {
      void m() {
        λ(s, n, null);
      }
    }

    LambdaAnalyzer lambda = lambdaIn(C.class);

    assertTrue(lambda.locals.isEmpty());
    assertTrue(lambda.getMutableLocals().isEmpty());

    assertEquals(list("s", "n"), list(lambda.parameters.keySet()));
    assertEquals(list(getType(String.class), INT_TYPE), lambda.getParameterTypes());

    assertEquals(list(object, object), lambda.newLambdaParameterTypes);

    assertEquals(object, lambda.expressionType);
    assertEquals(getType(Fn2.class), lambda.lambdaType);

    assertEquals("call", lambda.sam.getName());
    assertEquals(list(object, object), list(lambda.sam.getArgumentTypes()));
    assertEquals(object, lambda.sam.getReturnType());

    assertFalse(lambda.parameterNeedsUnboxing("s"));
    assertTrue(lambda.parameterNeedsUnboxing("n"));
  }
  @Test
  public void analyzingLambdaClosingOverVariableInitialziedInLambda() throws Exception {
    class C {
      void m() {
        int i;
        λ(i = 2);
      }
    }

    LambdaAnalyzer lambda = lambdaIn(C.class);

    assertEquals(1, lambda.locals.size());
    assertEquals(1, lambda.getMutableLocals().size());

    assertEquals(list("i"), list(lambda.getMutableLocals().keySet()));
    assertEquals(INT_TYPE, lambda.getLocalVariableType("i"));
  }
  @Test
  public void analyzingLambdaClosingOverIncreasedVariableOutsideLambda() throws Exception {
    class C {
      void m() {
        int i = 1;
        λ(i++);
      }
    }

    LambdaAnalyzer lambda = lambdaIn(C.class);

    assertEquals(1, lambda.locals.size());
    assertEquals(1, lambda.getMutableLocals().size());

    assertEquals(list("i"), list(lambda.getMutableLocals().keySet()));
    assertEquals(INT_TYPE, lambda.getLocalVariableType("i"));
  }
  @Test
  public void analyzingLambdaClosingOverMutableVariableMutatedOutsideLambda() throws Exception {
    class C {
      void m() {
        int i = 1;
        i = 2;
        λ(i);
      }
    }

    LambdaAnalyzer lambda = lambdaIn(C.class);

    assertEquals(1, lambda.locals.size());
    assertEquals(1, lambda.getMutableLocals().size());

    assertEquals(list("i"), list(lambda.getMutableLocals().keySet()));
  }
  @Test
  public void analyzingLambdaClosingOverMutableArgument() throws Exception {
    class C {
      void m(int i) {
        i = 2;
        i = 4;
        λ(i);
      }
    }

    LambdaAnalyzer lambda = lambdaIn(C.class);

    assertEquals(1, lambda.locals.size());
    assertEquals(1, lambda.getMutableLocals().size());

    assertEquals(list("i"), list(lambda.getMutableLocals().keySet()));
    assertEquals(INT_TYPE, lambda.getLocalVariableType("i"));
  }
  @Test
  public void analyzingLambdaClosingOverEffectivelyFinalArgument() throws Exception {
    class C {
      void m(int i) {
        λ(i);
      }
    }

    LambdaAnalyzer lambda = lambdaIn(C.class);

    assertEquals(1, lambda.locals.size());
    assertTrue(lambda.getMutableLocals().isEmpty());

    assertEquals(list("i"), list(lambda.locals.keySet()));
    assertEquals(INT_TYPE, lambda.getLocalVariableType("i"));
  }
  @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"));
  }
  @Test
  public void analyzingZeroArgumentLambda() throws Exception {
    class C {
      void m() {
        λ();
      }
    }

    LambdaTreeWeaver weaver = analyze(C.class);
    assertEquals(getType(C.class).getInternalName(), weaver.c.name);
    assertEquals(2, weaver.methods.size());

    MethodAnalyzer constructor = weaver.methods.get(0);
    assertEquals("<init>", constructor.m.name);
    assertTrue(constructor.lambdas.isEmpty());

    MethodAnalyzer method = weaver.methods.get(1);
    assertEquals("m", method.m.name);

    assertEquals(1, method.lambdas.size());
    LambdaAnalyzer lambda = method.lambdas.get(0);

    assertTrue(lambda.locals.isEmpty());
    assertTrue(lambda.getMutableLocals().isEmpty());

    assertTrue(lambda.parameters.isEmpty());
    assertTrue(lambda.newLambdaParameterTypes.isEmpty());

    assertEquals(object, lambda.expressionType);
    assertEquals(getType(Fn0.class), lambda.lambdaType);

    assertEquals("call", lambda.sam.getName());
    assertEquals(0, lambda.sam.getArgumentTypes().length);

    assertEquals(object, lambda.sam.getReturnType());
    assertFalse(lambda.returnNeedsUnboxing());
    assertFalse(lambda.returnNeedsBoxing());
  }