cast for value on stack
This commit is contained in:
@@ -108,6 +108,7 @@ public abstract class StackValue {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void put(Type type, InstructionAdapter v) {
|
public void put(Type type, InstructionAdapter v) {
|
||||||
|
coerce(type, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -327,6 +327,15 @@ public class NamespaceGenTest extends LightCodeInsightFixtureTestCase {
|
|||||||
assertEquals(1.0, main.invoke(null));
|
assertEquals(1.0, main.invoke(null));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testCastOnStack() throws Exception {
|
||||||
|
loadText("fun foo(): Double = System.currentTimeMillis().dbl");
|
||||||
|
final Method main = generateFunction();
|
||||||
|
double currentTimeMillis = (double) System.currentTimeMillis();
|
||||||
|
double result = (Double) main.invoke(null);
|
||||||
|
double delta = Math.abs(currentTimeMillis - result);
|
||||||
|
assertTrue(delta <= 1.0);
|
||||||
|
}
|
||||||
|
|
||||||
private void binOpTest(final String text, final Object arg1, final Object arg2, final Object expected) throws Exception {
|
private void binOpTest(final String text, final Object arg1, final Object arg2, final Object expected) throws Exception {
|
||||||
loadText(text);
|
loadText(text);
|
||||||
System.out.println(generateToText());
|
System.out.println(generateToText());
|
||||||
|
|||||||
Reference in New Issue
Block a user