提交 39a6b63f 编写于 作者: D Dmitry Jemerov

cast for value on stack

上级 812d2a18
......@@ -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());
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册