Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,23 @@ public List<Patch> findAngelicValuesAndBuildPatch(URL[] classpath, List<TestResu

final Collection<Specification<T>> data = instrumentedProgram.collectSpecifications(classpath, testClasses, failures);

int dataSize = data.size();
if (dataSize == 0) {
LoggerFactory.getLogger(this.getClass()).info("No angelic value for {} ({}).", sourceLocation, type.toString());
return Collections.EMPTY_LIST;
}

nopolResult.incrementNbAngelicValues(sourceLocation, conditionalProcessor);
nbStatementsWithAngelicValue++;

// XXX FIXME TODO move this
// there should be at least two sets of values, otherwise the patch would be "true" or "false"
int dataSize = data.size();
if (dataSize < 2) {
LoggerFactory.getLogger(this.getClass()).info("Not enough specifications: {}. A trivial patch is \"true\" or \"false\", please write new tests specifying {}.", dataSize, sourceLocation);
// we return so that we can start working on the next statement in the suspicious list
return Collections.EMPTY_LIST;
}


nopolResult.incrementNbAngelicValues(sourceLocation, conditionalProcessor);
nbStatementsWithAngelicValue++;

//collects available constants
Map<String, Number> constants = new HashMap<>();
DefaultConstantCollector constantCollector = new DefaultConstantCollector(constants);
Expand Down
12 changes: 12 additions & 0 deletions nopol/src/test/java/fr/inria/lille/repair/nopol/NopolTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -286,4 +286,16 @@ public void testDynamoth() {
assertEquals(10, nopol.build().getPatches().size());
}

@Test
public void testNbAngelicValuesWithNotEnoughSpecifications() {
NopolContext nopolContext = TestUtility.configForExample(executionType, 14);
nopolContext.setType(RepairType.CONDITIONAL);
SolverFactory.setSolver("z3", TestUtility.solverPath);

NoPol nopol = new NoPol(nopolContext);
NopolResult result = nopol.build();

assertEquals(1, result.getNbAngelicValues());
assertEquals(NopolStatus.NO_SYNTHESIS, result.getNopolStatus());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package nopol_examples.nopol_example_14;

public class NopolExample {

/*
* Buggy implementation of the identity function.
*/
public int identity(int a){
if (a == 1) { // With *only* the test a = 1, there are "Not enough specifications",
// yet this statement admits an angelic value.
return 0;
}

return a;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package nopol_examples.nopol_example_14;

import static org.junit.Assert.assertEquals;

import org.junit.Test;

public class NopolExampleTest {

@Test
public void test1() {
NopolExample ex = new NopolExample();
assertEquals(1, ex.identity(1));
}

}
Loading