-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #167 from kusumotolab/keep_fixed_variants
KGenProgMainの最低限の機能を実装
- Loading branch information
Showing
4 changed files
with
203 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
src/main/java/jp/kusumotolab/kgenprog/ga/SiglePointCrossover.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
package jp.kusumotolab.kgenprog.ga; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class SiglePointCrossover implements Crossover{ | ||
public class SiglePointCrossover implements Crossover { | ||
|
||
private static Logger log = LoggerFactory.getLogger(SiglePointCrossover.class); | ||
|
||
@Override | ||
public List<Gene> exec(List<Variant> variants) { | ||
public List<Gene> exec(final List<Variant> variants) { | ||
log.debug("enter exec(List<>)"); | ||
// TODO Auto-generated method stub | ||
return null; | ||
return Collections.emptyList(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
118 changes: 118 additions & 0 deletions
118
src/test/java/jp/kusumotolab/kgenprog/KGenProgMainTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
package jp.kusumotolab.kgenprog; | ||
|
||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import org.junit.Test; | ||
import jp.kusumotolab.kgenprog.fl.FaultLocalization; | ||
import jp.kusumotolab.kgenprog.fl.Ochiai; | ||
import jp.kusumotolab.kgenprog.ga.Crossover; | ||
import jp.kusumotolab.kgenprog.ga.DefaultCodeValidation; | ||
import jp.kusumotolab.kgenprog.ga.DefaultSourceCodeGeneration; | ||
import jp.kusumotolab.kgenprog.ga.DefaultVariantSelection; | ||
import jp.kusumotolab.kgenprog.ga.Mutation; | ||
import jp.kusumotolab.kgenprog.ga.RandomMutation; | ||
import jp.kusumotolab.kgenprog.ga.SiglePointCrossover; | ||
import jp.kusumotolab.kgenprog.ga.SourceCodeGeneration; | ||
import jp.kusumotolab.kgenprog.ga.SourceCodeValidation; | ||
import jp.kusumotolab.kgenprog.ga.VariantSelection; | ||
import jp.kusumotolab.kgenprog.project.DiffOutput; | ||
import jp.kusumotolab.kgenprog.project.ResultOutput; | ||
import jp.kusumotolab.kgenprog.project.SourceFile; | ||
import jp.kusumotolab.kgenprog.project.TargetSourceFile; | ||
import jp.kusumotolab.kgenprog.project.TestSourceFile; | ||
import jp.kusumotolab.kgenprog.project.factory.JUnitLibraryResolver.JUnitVersion; | ||
import jp.kusumotolab.kgenprog.project.factory.TargetProject; | ||
import jp.kusumotolab.kgenprog.project.factory.TargetProjectFactory; | ||
|
||
public class KGenProgMainTest { | ||
|
||
@Test | ||
public void testExample04() { | ||
|
||
final Path rootPath = Paths.get("example/example04/"); | ||
final List<SourceFile> targetSourceFiles = new ArrayList<>(); | ||
targetSourceFiles.add(new TargetSourceFile( | ||
Paths.get("example/example04/src/jp/kusumotolab/BuggyCalculator.java"))); | ||
final List<SourceFile> testSourceFiles = new ArrayList<>(); | ||
testSourceFiles.add(new TestSourceFile( | ||
Paths.get("example/example04/src/jp/kusumotolab/BuggyCalculatorTest.java"))); | ||
|
||
final TargetProject project = TargetProjectFactory.create(rootPath, targetSourceFiles, | ||
testSourceFiles, Collections.emptyList(), JUnitVersion.JUNIT4); | ||
|
||
final FaultLocalization faultLocalization = new Ochiai(); | ||
final Mutation mutation = new RandomMutation(); | ||
final Crossover crossover = new SiglePointCrossover(); | ||
final SourceCodeGeneration sourceCodeGeneration = new DefaultSourceCodeGeneration(); | ||
final SourceCodeValidation sourceCodeValidation = new DefaultCodeValidation(); | ||
final VariantSelection variantSelection = new DefaultVariantSelection(); | ||
|
||
final KGenProgMain kGenProgMain = new KGenProgMain(project, faultLocalization, mutation, | ||
crossover, sourceCodeGeneration, sourceCodeValidation, variantSelection); | ||
kGenProgMain.run(); | ||
|
||
final ResultOutput ro = new DiffOutput(kGenProgMain.workingDir); | ||
ro.outputResult(project, kGenProgMain.getComplatedVariants()); | ||
} | ||
|
||
@Test | ||
public void testExample05() { | ||
|
||
final Path rootPath = Paths.get("example/example05/"); | ||
final List<SourceFile> targetSourceFiles = new ArrayList<>(); | ||
targetSourceFiles.add(new TargetSourceFile( | ||
Paths.get("example/example05/src/jp/kusumotolab/BuggyCalculator.java"))); | ||
final List<SourceFile> testSourceFiles = new ArrayList<>(); | ||
testSourceFiles.add(new TestSourceFile( | ||
Paths.get("example/example05/src/jp/kusumotolab/BuggyCalculatorTest.java"))); | ||
|
||
final TargetProject project = TargetProjectFactory.create(rootPath, targetSourceFiles, | ||
testSourceFiles, Collections.emptyList(), JUnitVersion.JUNIT4); | ||
|
||
FaultLocalization faultLocalization = new Ochiai(); | ||
Mutation mutation = new RandomMutation(); | ||
Crossover crossover = new SiglePointCrossover(); | ||
SourceCodeGeneration sourceCodeGeneration = new DefaultSourceCodeGeneration(); | ||
SourceCodeValidation sourceCodeValidation = new DefaultCodeValidation(); | ||
VariantSelection variantSelection = new DefaultVariantSelection(); | ||
|
||
KGenProgMain kGenProgMain = new KGenProgMain(project, faultLocalization, mutation, crossover, | ||
sourceCodeGeneration, sourceCodeValidation, variantSelection); | ||
kGenProgMain.run(); | ||
|
||
final ResultOutput ro = new DiffOutput(kGenProgMain.workingDir); | ||
ro.outputResult(project, kGenProgMain.getComplatedVariants()); | ||
} | ||
|
||
@Test | ||
public void testExample06() { | ||
|
||
final Path rootPath = Paths.get("example/example06/"); | ||
final List<SourceFile> targetSourceFiles = new ArrayList<>(); | ||
targetSourceFiles.add(new TargetSourceFile( | ||
Paths.get("example/example06/src/jp/kusumotolab/BuggyCalculator.java"))); | ||
final List<SourceFile> testSourceFiles = new ArrayList<>(); | ||
testSourceFiles.add(new TestSourceFile( | ||
Paths.get("example/example06/src/jp/kusumotolab/BuggyCalculatorTest.java"))); | ||
|
||
final TargetProject project = TargetProjectFactory.create(rootPath, targetSourceFiles, | ||
testSourceFiles, Collections.emptyList(), JUnitVersion.JUNIT4); | ||
|
||
FaultLocalization faultLocalization = new Ochiai(); | ||
Mutation mutation = new RandomMutation(); | ||
Crossover crossover = new SiglePointCrossover(); | ||
SourceCodeGeneration sourceCodeGeneration = new DefaultSourceCodeGeneration(); | ||
SourceCodeValidation sourceCodeValidation = new DefaultCodeValidation(); | ||
VariantSelection variantSelection = new DefaultVariantSelection(); | ||
|
||
KGenProgMain kGenProgMain = new KGenProgMain(project, faultLocalization, mutation, crossover, | ||
sourceCodeGeneration, sourceCodeValidation, variantSelection); | ||
kGenProgMain.run(); | ||
|
||
final ResultOutput ro = new DiffOutput(kGenProgMain.workingDir); | ||
ro.outputResult(project, kGenProgMain.getComplatedVariants()); | ||
} | ||
} |