@Test(expected = PitHelpError.class) public void shouldThrowErrorForClassCompiledWithoutLineNumberDebugInfo() { setupClassPath(new ResourceFolderByteArraySource(), "FooNoLines"); this.testee.verify(this.code); }
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(); }
@Test(expected = PitHelpError.class) public void shouldThrowErrorForClassCompiledWithoutSourceFileDebugInfo() { setupClassPath(new ResourceFolderByteArraySource(), "FooNoSource"); this.testee.verify(this.code); }
@Test public void shouldNotMutateCompilerGeneratedConditionalsInStringSwitch() { createTesteeWith(new ResourceFolderByteArraySource(), i -> true, Mutator.byName("REMOVE_CONDITIONALS")); final Collection<MutationDetails> actualDetails = findMutationsFor("Java7SwitchOnString"); assertThat(actualDetails).isEmpty(); }
@Test public void shouldNotMutateGroovyClosures() { createTesteeWith(new ResourceFolderByteArraySource(), i -> true, Mutator.all()); final Collection<MutationDetails> actualDetails = findMutationsFor("groovy/SomeGroovyCode$_mapToString_closure2"); assertTrue(actualDetails.isEmpty()); }
@Test public void shouldNotMutateGroovyClasses() { createTesteeWith(new ResourceFolderByteArraySource(), i -> true, Mutator.all()); final Collection<MutationDetails> actualDetails = findMutationsFor("groovy/SomeGroovyCode"); assertTrue(actualDetails.isEmpty()); }
@Test public void shouldNotThrowErrorForSyntheticClassCompiledWithoutSourceFileDebugInfo() { setupClassPath(new ResourceFolderByteArraySource(), "SyntheticNoSourceDebug"); try { this.testee.verify(this.code); } catch (final PitHelpError ex) { fail(); } }