cast for value on stack

This commit is contained in:
Dmitry Jemerov
2011-04-07 17:06:33 +02:00
parent 812d2a185b
commit 39a6b63f0a
2 changed files with 10 additions and 0 deletions
@@ -108,6 +108,7 @@ public abstract class StackValue {
@Override
public void put(Type type, InstructionAdapter v) {
coerce(type, v);
}
@Override
@@ -327,6 +327,15 @@ public class NamespaceGenTest extends LightCodeInsightFixtureTestCase {
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 {
loadText(text);
System.out.println(generateToText());