Fixed tests and added a comment to the box method.

This commit is contained in:
Jack Conradson 2016-05-20 11:04:09 -07:00
parent 2b793c1e06
commit d836194095
2 changed files with 8 additions and 4 deletions

View File

@ -200,9 +200,15 @@ public final class MethodWriter extends GeneratorAdapter {
}
}
/**
* ASM does boxing in an evil way to be compatible with Java prior to verison 5.
* Supporting versions prior to 5 is not a requirement of this project, so the modern
* boxing methods are used instead.
*/
@Override
public void box(final org.objectweb.asm.Type type) {
switch (type.getSort()) {
case org.objectweb.asm.Type.VOID: visitInsn(Opcodes.ACONST_NULL); break;
case org.objectweb.asm.Type.BOOLEAN: invokeStatic(BOOLEAN_OBJECT , BOOLEAN_VALUE_OF); break;
case org.objectweb.asm.Type.BYTE: invokeStatic(BYTE_OBJECT , BYTE_VALUE_OF); break;
case org.objectweb.asm.Type.SHORT: invokeStatic(SHORT_OBJECT , SHORT_VALUE_OF); break;
@ -211,8 +217,6 @@ public final class MethodWriter extends GeneratorAdapter {
case org.objectweb.asm.Type.LONG: invokeStatic(LONG_OBJECT , LONG_VALUE_OF); break;
case org.objectweb.asm.Type.FLOAT: invokeStatic(FLOAT_OBJECT , FLOAT_VALUE_OF); break;
case org.objectweb.asm.Type.DOUBLE: invokeStatic(DOUBLE_OBJECT , DOUBLE_VALUE_OF); break;
default:
throw new IllegalArgumentException("Illegal tree structure.");
}
}

View File

@ -119,7 +119,7 @@ public class EqualsTests extends ScriptTestCase {
assertEquals(0, exec("def a = (char)'a'; def b = (char)'b'; if (a == b) return 1; else return 0;"));
assertEquals(1, exec("def a = (char)'a'; def b = (char)'a'; if (a == b) return 1; else return 0;"));
assertEquals(1, exec("def a = 1; def b = 1; if (a === b) return 1; else return 0;"));
assertEquals(0, exec("def a = (char)'a'; def b = (char)'a'; if (a === b) return 1; else return 0;"));
assertEquals(1, exec("def a = (char)'a'; def b = (char)'a'; if (a === b) return 1; else return 0;"));
assertEquals(1, exec("def a = (char)'a'; Object b = a; if (a === b) return 1; else return 0;"));
assertEquals(1, exec("def a = 1; Number b = a; Number c = a; if (c === b) return 1; else return 0;"));
assertEquals(0, exec("def a = 1; Object b = new HashMap(); if (a === (Object)b) return 1; else return 0;"));
@ -129,7 +129,7 @@ public class EqualsTests extends ScriptTestCase {
assertEquals(1, exec("def a = (char)'a'; def b = (char)'b'; if (a != b) return 1; else return 0;"));
assertEquals(0, exec("def a = (char)'a'; def b = (char)'a'; if (a != b) return 1; else return 0;"));
assertEquals(0, exec("def a = 1; def b = 1; if (a !== b) return 1; else return 0;"));
assertEquals(1, exec("def a = (char)'a'; def b = (char)'a'; if (a !== b) return 1; else return 0;"));
assertEquals(0, exec("def a = (char)'a'; def b = (char)'a'; if (a !== b) return 1; else return 0;"));
assertEquals(0, exec("def a = (char)'a'; Object b = a; if (a !== b) return 1; else return 0;"));
assertEquals(0, exec("def a = 1; Number b = a; Number c = a; if (c !== b) return 1; else return 0;"));
assertEquals(1, exec("def a = 1; Object b = new HashMap(); if (a !== (Object)b) return 1; else return 0;"));