Program: 53456
Project: 53456
Buggy source:
/** 
 * Invokes FragmentExtractor with a fragment description claiming that Bar was not made live by the current fragment, but that it has a constructor which *was* made live. Verifies that the defineClass invocation from the global JS block *is* included in the extracted statement output.
 */
public void testDefineClass_DeadTypeLiveConstructor(){
  FragmentExtractor fragmentExtractor;
  LivenessPredicate constructorLivePredicate;
{
    SourceInfo nullSourceInfo=new MockSourceInfo();
    final JClassType barType=new JClassType(nullSourceInfo,"String_Node_Str",false,false);
    final JsName barConstructorName=new JsName(null,"String_Node_Str","String_Node_Str");
    final JConstructor barConstructor=new JConstructor(nullSourceInfo,barType);
    Map<String,JsFunction> functionsByName=new HashMap<String,JsFunction>();
    functionsByName.put("String_Node_Str",new JsFunction(nullSourceInfo,new JsRootScope(),DEFINE_CLASS_FUNCTION_NAME));
    final JsExprStmt defineClassStatement=createDefineClassStatement(barConstructorName);
    JsProgram jsProgram=new JsProgram();
    jsProgram.setIndexedFunctions(functionsByName);
    jsProgram.getGlobalBlock().getStatements().add(defineClassStatement);
    JavaToJavaScriptMap map=new MockJavaToJavaScriptMap(){
      @Override public JMethod nameToMethod(      JsName name){
        if (name == barConstructorName) {
          return barConstructor;
        }
        return null;
      }
      @Override public JClassType typeForStatement(      JsStatement statement){
        if (statement == defineClassStatement) {
          return barType;
        }
        return null;
      }
    }
;
    fragmentExtractor=new FragmentExtractor(null,jsProgram,map);
    constructorLivePredicate=new MockLivenessPredicate(){
      @Override public boolean isLive(      JDeclaredType type){
        return false;
      }
      @Override public boolean isLive(      JMethod method){
        return method == barConstructor;
      }
    }
;
  }
  List<JsStatement> extractedStatements=fragmentExtractor.extractStatements(constructorLivePredicate,new NothingAlivePredicate());
  assertEquals(1,extractedStatements.size());
  JsStatement defineClassStatement=extractedStatements.get(0);
  assertTrue(defineClassStatement.toString().contains("String_Node_Str"));
}

Fixed version (ground truth):
/** 
 * Invokes FragmentExtractor with a fragment description claiming that Bar was not made live by the current fragment, but that it has a constructor which *was* made live. Verifies that the defineClass invocation from the global JS block *is* included in the extracted statement output.
 */
public void testDefineClass_DeadTypeLiveConstructor(){
  FragmentExtractor fragmentExtractor;
  LivenessPredicate constructorLivePredicate;
{
    SourceInfo nullSourceInfo=new MockSourceInfo();
    final JClassType barType=new JClassType(nullSourceInfo,"String_Node_Str",false,false);
    final JsName barConstructorName=new JsName(null,"String_Node_Str","String_Node_Str");
    final JConstructor barConstructor=new JConstructor(nullSourceInfo,barType,AccessModifier.PUBLIC);
    Map<String,JsFunction> functionsByName=new HashMap<String,JsFunction>();
    functionsByName.put("String_Node_Str",new JsFunction(nullSourceInfo,new JsRootScope(),DEFINE_CLASS_FUNCTION_NAME));
    final JsExprStmt defineClassStatement=createDefineClassStatement(barConstructorName);
    JsProgram jsProgram=new JsProgram();
    jsProgram.setIndexedFunctions(functionsByName);
    jsProgram.getGlobalBlock().getStatements().add(defineClassStatement);
    JavaToJavaScriptMap map=new MockJavaToJavaScriptMap(){
      @Override public JMethod nameToMethod(      JsName name){
        if (name == barConstructorName) {
          return barConstructor;
        }
        return null;
      }
      @Override public JClassType typeForStatement(      JsStatement statement){
        if (statement == defineClassStatement) {
          return barType;
        }
        return null;
      }
    }
;
    fragmentExtractor=new FragmentExtractor(null,jsProgram,map);
    constructorLivePredicate=new MockLivenessPredicate(){
      @Override public boolean isLive(      JDeclaredType type){
        return false;
      }
      @Override public boolean isLive(      JMethod method){
        return method == barConstructor;
      }
    }
;
  }
  List<JsStatement> extractedStatements=fragmentExtractor.extractStatements(constructorLivePredicate,new NothingAlivePredicate());
  assertEquals(1,extractedStatements.size());
  JsStatement defineClassStatement=extractedStatements.get(0);
  assertTrue(defineClassStatement.toString().contains("String_Node_Str"));
}