Commit 84c9bb83 authored by Eric Bruneton's avatar Eric Bruneton

Merge branch 'generator-adapter-unit-tests' into 'master'

Add unit tests for GeneratorAdapter. Also exclude the deprecated Remapping*…

See merge request !135
parents 10aaef5b a4b16ab3
Pipeline #851 passed with stage
in 5 minutes and 59 seconds
......@@ -173,6 +173,9 @@ public class GeneratorAdapter extends LocalVariablesSorter {
/** Access flags of the method visited by this adapter. */
private final int access;
/** The name of the method visited by this adapter. */
private final String name;
/** Return type of the method visited by this adapter. */
private final Type returnType;
......@@ -219,6 +222,7 @@ public class GeneratorAdapter extends LocalVariablesSorter {
final String desc) {
super(api, access, desc, mv);
this.access = access;
this.name = name;
this.returnType = Type.getReturnType(desc);
this.argumentTypes = Type.getArgumentTypes(desc);
}
......@@ -233,7 +237,7 @@ public class GeneratorAdapter extends LocalVariablesSorter {
* @param mv the method visitor to which this adapter delegates calls.
*/
public GeneratorAdapter(final int access, final Method method, final MethodVisitor mv) {
this(mv, access, null, method.getDescriptor());
this(mv, access, method.getName(), method.getDescriptor());
}
/**
......@@ -281,6 +285,22 @@ public class GeneratorAdapter extends LocalVariablesSorter {
return names;
}
public int getAccess() {
return access;
}
public String getName() {
return name;
}
public Type getReturnType() {
return returnType;
}
public Type[] getArgumentTypes() {
return argumentTypes.clone();
}
// ------------------------------------------------------------------------
// Instructions to push constants on the stack
// ------------------------------------------------------------------------
......@@ -411,7 +431,11 @@ public class GeneratorAdapter extends LocalVariablesSorter {
* @param handle the handle to be pushed on the stack.
*/
public void push(final Handle handle) {
mv.visitLdcInsn(handle);
if (handle == null) {
mv.visitInsn(Opcodes.ACONST_NULL);
} else {
mv.visitLdcInsn(handle);
}
}
// ------------------------------------------------------------------------
......@@ -753,7 +777,9 @@ public class GeneratorAdapter extends LocalVariablesSorter {
mv.visitInsn(Opcodes.I2L);
} else if (to == Type.SHORT_TYPE) {
mv.visitInsn(Opcodes.I2S);
}
} else {
throw new IllegalArgumentException();
}
}
}
}
......@@ -957,6 +983,8 @@ public class GeneratorAdapter extends LocalVariablesSorter {
case GT:
intOp = Opcodes.IF_ICMPGT;
break;
default:
throw new IllegalArgumentException("Bad comparison mode " + mode);
}
mv.visitJumpInsn(intOp, label);
return;
......
......@@ -73,7 +73,7 @@ project(':asm-commons') {
provides = ['org.objectweb.asm.commons']
requires = [':asm', ':asm-tree', ':asm-analysis']
dependencies { testCompile project(':asm-util') }
minCodeCoverage = 0.5 // TODO: improve the code coverage of this project.
minCodeCoverage = 0.85 // TODO: improve the code coverage of this project.
}
project(':asm-test') {
......@@ -190,22 +190,21 @@ configure(subprojects.findAll { it.provides }) {
apply plugin: 'jacoco'
jacoco { applyTo junitPlatformTest }
afterEvaluate {
def classes = files(project.sourceSets.main.output.collect { fileTree(
dir: it, include: 'org/objectweb/asm/**', exclude: '**/Remapping*'
)})
task jacocoTestReport(type: JacocoReport, overwrite: true) {
executionData junitPlatformTest
sourceSets sourceSets.main
sourceDirectories = files(project.sourceSets.main.allSource.srcDirs)
classDirectories = files(project.sourceSets.main.output.collect {
fileTree(dir: it, include: 'org/objectweb/asm/**')
})
classDirectories = classes
}
task jacocoTestCoverageVerification(
type: JacocoCoverageVerification, overwrite: true) {
executionData junitPlatformTest
sourceSets sourceSets.main
sourceDirectories = files(project.sourceSets.main.allSource.srcDirs)
classDirectories = files(project.sourceSets.main.output.collect {
fileTree(dir: it, include: 'org/objectweb/asm/**')
})
classDirectories = classes
violationRules.rule {
limit {
counter = 'INSTRUCTION'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment