add test for interpolated string
fix minor todo
This commit is contained in:
@@ -3,7 +3,8 @@ package js;
|
|||||||
import js.native
|
import js.native
|
||||||
|
|
||||||
native
|
native
|
||||||
val Math = object {
|
class MathClass() {
|
||||||
|
val PI : Double = 1.0;
|
||||||
fun random() : Double = 0.0;
|
fun random() : Double = 0.0;
|
||||||
fun abs(value : Double) = 0.0
|
fun abs(value : Double) = 0.0
|
||||||
fun acos(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 min(vararg values : Double) = 0.0
|
||||||
fun sqrt(value : Double) = 0.0
|
fun sqrt(value : Double) = 0.0
|
||||||
fun tan(value : Double) = 0.0
|
fun tan(value : Double) = 0.0
|
||||||
|
|
||||||
fun log(value : Double) = 0.0
|
fun log(value : Double) = 0.0
|
||||||
fun pow(base : Double, exp : Double) = 0.0
|
fun pow(base : Double, exp : Double) = 0.0
|
||||||
fun round(value : Double) = 0.0
|
fun round(value : Double) = 0.0
|
||||||
fun floor(value : Double) = 0.0
|
fun floor(value : Double) = 0.0
|
||||||
fun ceil(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,
|
public static boolean canBePropertyGetterCall(@NotNull JetQualifiedExpression expression,
|
||||||
@NotNull TranslationContext context) {
|
@NotNull TranslationContext context) {
|
||||||
JetSimpleNameExpression selector = getSelectorAsSimpleName(expression);
|
JetSimpleNameExpression selector = getSelectorAsSimpleName(expression);
|
||||||
if (selector == null) {
|
assert selector != null : "Only names are allowed after the dot";
|
||||||
//TODO: never get there. review
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return canBePropertyGetterCall(selector, context);
|
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;
|
return MAIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testStringConstant() throws Exception {
|
public void testStringConstant() throws Exception {
|
||||||
testFooBoxIsTrue("stringConstant.kt");
|
testFooBoxIsTrue("stringConstant.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testStringAssignment() throws Exception {
|
public void testStringAssignment() throws Exception {
|
||||||
testFooBoxIsTrue("stringAssignment.kt");
|
testFooBoxIsTrue("stringAssignment.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testIntInTemplate() throws Exception {
|
public void testIntInTemplate() throws Exception {
|
||||||
testFunctionOutput("intInTemplate.kt", "foo", "box", "my age is 3");
|
testFunctionOutput("intInTemplate.kt", "foo", "box", "my age is 3");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testStringInTemplate() throws Exception {
|
public void testStringInTemplate() throws Exception {
|
||||||
testFunctionOutput("stringInTemplate.kt", "foo", "box", "oHelloo");
|
testFunctionOutput("stringInTemplate.kt", "foo", "box", "oHelloo");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testMultipleExpressionInTemplate() throws Exception {
|
public void testMultipleExpressionInTemplate() throws Exception {
|
||||||
testFunctionOutput("multipleExpressionsInTemplate.kt", "foo", "box", "left = 3\nright = 2\nsum = 5\n");
|
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