Java Code Examples for org.pitest.bytecode.analysis.ClassTree#fromBytes()
The following examples show how to use
org.pitest.bytecode.analysis.ClassTree#fromBytes() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MutationSource.java From pitest with Apache License 2.0 | 6 votes |
public Collection<MutationDetails> createMutations(final ClassName clazz) { final Mutater m = this.mutationConfig.createMutator(this.source); final Collection<MutationDetails> availableMutations = m .findMutations(clazz); if (availableMutations.isEmpty()) { return availableMutations; } else { final ClassTree tree = ClassTree .fromBytes(this.source.getBytes(clazz.asJavaName()).get()); this.interceptor.begin(tree); final Collection<MutationDetails> updatedMutations = this.interceptor .intercept(availableMutations, m); this.interceptor.end(); assignTestsToMutations(updatedMutations); return updatedMutations; } }
Example 2
Source File: FilterTester.java From pitest with Apache License 2.0 | 6 votes |
private List<Sample> samples(final String sample) { final Function<String, Stream<Sample>> toPair = compiler -> { final String clazz = makeClassName(sample, compiler); final Optional<byte[]> bs = FilterTester.this.source.getBytes(clazz); if (bs.isPresent()) { final Sample p = new Sample(); p.className = ClassName.fromString(clazz); p.clazz = ClassTree.fromBytes(bs.get()); p.compiler = compiler; return Stream.of(p); } return Stream.empty(); }; return COMPILERS.stream().flatMap(toPair).collect(Collectors.toList()); }
Example 3
Source File: InfiniteLoopFilter.java From pitest with Apache License 2.0 | 5 votes |
private boolean isInfiniteLoop(MutationDetails each, Mutater m) { final ClassTree mutantClass = ClassTree.fromBytes(m.getMutation(each.getId()).getBytes()); final Optional<MethodTree> mutantMethod = mutantClass.methods().stream() .filter(forLocation(each.getId().getLocation())) .findFirst(); return infiniteLoopMatcher().matches(mutantMethod.get().instructions()); }
Example 4
Source File: EqualsPerformanceShortcutFilter.java From pitest with Apache License 2.0 | 5 votes |
private Boolean shortCutEquals(MethodTree tree, MutationDetails a, Mutater m) { if (!mutatesAConditionalJump(tree, a.getInstructionIndex())) { return false; } final ClassTree mutant = ClassTree.fromBytes(m.getMutation(a.getId()).getBytes()); final MethodTree mutantEquals = mutant.methods().stream() .filter(MethodMatchers.forLocation(tree.asLocation())) .findFirst() .get(); return ALWAYS_FALSE.matches(mutantEquals.instructions()); }
Example 5
Source File: FilterTester.java From pitest with Apache License 2.0 | 5 votes |
private Sample makeSampleForCurrentCompiler(Class<?> clazz) { final ClassloaderByteArraySource source = ClassloaderByteArraySource.fromContext(); final Sample s = new Sample(); s.className = ClassName.fromClass(clazz); s.clazz = ClassTree.fromBytes(source.getBytes(clazz.getName()).get()); s.compiler = "current"; return s; }
Example 6
Source File: FilterTester.java From pitest with Apache License 2.0 | 5 votes |
private Sample sampleForClass(Class<?> clazz) { final ClassloaderByteArraySource source = ClassloaderByteArraySource.fromContext(); final Sample s = new Sample(); s.className = ClassName.fromClass(clazz); s.clazz = ClassTree.fromBytes(source.getBytes(clazz.getName()).get()); s.compiler = "current"; return s; }
Example 7
Source File: InfiniteLoopBaseTest.java From pitest with Apache License 2.0 | 5 votes |
private Optional<MethodTree> parseMethodFromCompiledResource(ClassName clazz, Compiler compiler, Predicate<MethodTree> method) { final ResourceFolderByteArraySource source = new ResourceFolderByteArraySource(); final Optional<byte[]> bs = source.getBytes("loops/" + compiler.name() + "/" + clazz.getNameWithoutPackage().asJavaName()); if (bs.isPresent()) { final ClassTree tree = ClassTree.fromBytes(bs.get()); return tree.methods().stream().filter(method).findFirst(); } return Optional.empty(); }
Example 8
Source File: TestUtils.java From pitest-descartes with GNU Lesser General Public License v3.0 | 4 votes |
public static ClassTree getClassTreeForResource(String path) throws IOException { return ClassTree.fromBytes(toByteArray(TestUtils.class.getResourceAsStream(path))); }
Example 9
Source File: MutantExportInterceptorTest.java From pitest with Apache License 2.0 | 4 votes |
private ClassTree tree(Class<?> clazz) { return ClassTree.fromBytes(this.source.getBytes(clazz.getName()).get()); }
Example 10
Source File: StaticInitializerInterceptorTest.java From pitest with Apache License 2.0 | 4 votes |
private ClassTree treeFor(Class<?> clazz) { final ClassloaderByteArraySource source = ClassloaderByteArraySource.fromContext(); return ClassTree.fromBytes(source.getBytes(clazz.getName()).get()); }
Example 11
Source File: LoggingCallsFilterTest.java From pitest with Apache License 2.0 | 4 votes |
ClassTree treeFor(Class<?> clazz) { final ClassloaderByteArraySource source = ClassloaderByteArraySource.fromContext(); return ClassTree.fromBytes(source.getBytes(clazz.getName()).get()); }
Example 12
Source File: InfiniteLoopBaseTest.java From pitest with Apache License 2.0 | 4 votes |
ClassTree forClass(Class<?> clazz) { final byte[] bs = this.source.getBytes(clazz.getName()).get(); return ClassTree.fromBytes(bs); }
Example 13
Source File: EqualsPerformanceShortcutFilterTest.java From pitest with Apache License 2.0 | 4 votes |
ClassTree forClass(Class<?> clazz) { final byte[] bs = this.source.getBytes(clazz.getName()).get(); return ClassTree.fromBytes(bs); }
Example 14
Source File: ExcludedAnnotationInterceptorTest.java From pitest with Apache License 2.0 | 4 votes |
ClassTree treeFor(Class<?> clazz) { final ClassloaderByteArraySource source = ClassloaderByteArraySource.fromContext(); return ClassTree.fromBytes(source.getBytes(clazz.getName()).get()); }