Better message for long constants.

This commit is contained in:
Pavel V. Talanov
2012-07-27 13:15:47 +04:00
parent 99bf7553e0
commit b234294863
3 changed files with 20 additions and 2 deletions
@@ -16,6 +16,8 @@
package org.jetbrains.k2js.test.semantics;
import junit.framework.Assert;
import org.jetbrains.k2js.facade.exceptions.TranslationInternalException;
import org.jetbrains.k2js.test.SingleFileTranslationTest;
/**
@@ -45,4 +47,14 @@ public final class NumberTest extends SingleFileTranslationTest {
public void testDivision() throws Exception {
fooBoxIsValue("SUCCESS");
}
public void testHexademicalConstant() throws Exception {
try {
fooBoxTest();
} catch (TranslationInternalException e) {
Throwable cause = e.getCause();
Assert.assertTrue(cause instanceof IllegalStateException);
Assert.assertTrue(cause.getMessage().startsWith("Unsupported long constant "));
}
}
}
@@ -89,8 +89,10 @@ public final class ExpressionVisitor extends TranslatorVisitor<JsNode> {
if (value instanceof Short) {
return context.program().getNumberLiteral((Short) value);
}
//TODO: long and char
throw new AssertionError(message(expression, "Unsupported constant expression"));
if (value instanceof Long) {
throw new IllegalStateException(message(expression, "Unsupported long constant"));
}
throw new IllegalStateException(message(expression, "Unsupported constant expression"));
}
@Override
@@ -0,0 +1,4 @@
fun box(): Boolean {
val i = 0x80000000 + 0x8000000
return true
}