add test for interpolated string
fix minor todo
This commit is contained in:
@@ -3,7 +3,8 @@ package js;
|
||||
import js.native
|
||||
|
||||
native
|
||||
val Math = object {
|
||||
class MathClass() {
|
||||
val PI : Double = 1.0;
|
||||
fun random() : Double = 0.0;
|
||||
fun abs(value : Double) = 0.0
|
||||
fun acos(value : Double) = 0.0
|
||||
@@ -17,10 +18,13 @@ val Math = object {
|
||||
fun min(vararg values : Double) = 0.0
|
||||
fun sqrt(value : Double) = 0.0
|
||||
fun tan(value : Double) = 0.0
|
||||
|
||||
fun log(value : Double) = 0.0
|
||||
fun pow(base : Double, exp : Double) = 0.0
|
||||
fun round(value : Double) = 0.0
|
||||
fun floor(value : Double) = 0.0
|
||||
fun ceil(value : Double) = 0.0
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
native
|
||||
val Math = MathClass();
|
||||
@@ -79,10 +79,7 @@ public abstract class PropertyAccessTranslator extends AccessTranslator {
|
||||
public static boolean canBePropertyGetterCall(@NotNull JetQualifiedExpression expression,
|
||||
@NotNull TranslationContext context) {
|
||||
JetSimpleNameExpression selector = getSelectorAsSimpleName(expression);
|
||||
if (selector == null) {
|
||||
//TODO: never get there. review
|
||||
return false;
|
||||
}
|
||||
assert selector != null : "Only names are allowed after the dot";
|
||||
return canBePropertyGetterCall(selector, context);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package foo
|
||||
|
||||
class A(var i : Int) {
|
||||
fun toString() = "a$i"
|
||||
}
|
||||
|
||||
fun box() : Boolean {
|
||||
var p = A(2);
|
||||
var n = A(1);
|
||||
if ("$p$n" != "a2a1") {
|
||||
return false;
|
||||
}
|
||||
if ("${A(10)}" != "a10") {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -12,28 +12,27 @@ public class StringTest extends AbstractExpressionTest {
|
||||
return MAIN;
|
||||
}
|
||||
|
||||
|
||||
public void testStringConstant() throws Exception {
|
||||
testFooBoxIsTrue("stringConstant.kt");
|
||||
}
|
||||
|
||||
|
||||
public void testStringAssignment() throws Exception {
|
||||
testFooBoxIsTrue("stringAssignment.kt");
|
||||
}
|
||||
|
||||
|
||||
public void testIntInTemplate() throws Exception {
|
||||
testFunctionOutput("intInTemplate.kt", "foo", "box", "my age is 3");
|
||||
}
|
||||
|
||||
|
||||
public void testStringInTemplate() throws Exception {
|
||||
testFunctionOutput("stringInTemplate.kt", "foo", "box", "oHelloo");
|
||||
}
|
||||
|
||||
|
||||
public void testMultipleExpressionInTemplate() throws Exception {
|
||||
testFunctionOutput("multipleExpressionsInTemplate.kt", "foo", "box", "left = 3\nright = 2\nsum = 5\n");
|
||||
}
|
||||
|
||||
public void testToStringMethod() throws Exception {
|
||||
testFooBoxIsTrue("objectToStringCallInTemplate.kt");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user