diff --git a/js/js.tests/test/org/jetbrains/k2js/test/semantics/StringTemplatesTest.java b/js/js.tests/test/org/jetbrains/k2js/test/semantics/StringTemplatesTest.java new file mode 100644 index 00000000000..3d9713a9c36 --- /dev/null +++ b/js/js.tests/test/org/jetbrains/k2js/test/semantics/StringTemplatesTest.java @@ -0,0 +1,36 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.k2js.test.semantics; + +public final class StringTemplatesTest extends AbstractExpressionTest { + + public StringTemplatesTest() { + super("stringTemplates/"); + } + + public void TODO_testObjectWithExtensionToString() throws Exception { + fooBoxIsValue("a = abcX, b = defX"); + } + + public void testObjectWithToString() throws Exception { + fooBoxIsValue("a = abcS, b = defS"); + } + + public void testStringValues() throws Exception { + fooBoxTest(); + } +} \ No newline at end of file diff --git a/js/js.translator/testFiles/expression/stringTemplates/cases/objectWithExtensionToString.kt b/js/js.translator/testFiles/expression/stringTemplates/cases/objectWithExtensionToString.kt new file mode 100644 index 00000000000..e091d8a9fa5 --- /dev/null +++ b/js/js.translator/testFiles/expression/stringTemplates/cases/objectWithExtensionToString.kt @@ -0,0 +1,15 @@ +package foo + +class Foo(val name: String) { +} + +public fun Foo.toString(): String { + return name + "X" +} + +fun box(): String { + val a = Foo("abc") + val b = Foo("def") + val message = "a = $a, b = $b" + return message +} \ No newline at end of file diff --git a/js/js.translator/testFiles/expression/stringTemplates/cases/objectWithToString.kt b/js/js.translator/testFiles/expression/stringTemplates/cases/objectWithToString.kt new file mode 100644 index 00000000000..cae8f2a7da2 --- /dev/null +++ b/js/js.translator/testFiles/expression/stringTemplates/cases/objectWithToString.kt @@ -0,0 +1,14 @@ +package foo + +class Foo(val name: String) { + public fun toString(): String { + return name + "S" + } +} + +fun box(): String { + val a = Foo("abc") + val b = Foo("def") + val message = "a = $a, b = $b" + return message +} \ No newline at end of file diff --git a/js/js.translator/testFiles/expression/stringTemplates/cases/stringValues.kt b/js/js.translator/testFiles/expression/stringTemplates/cases/stringValues.kt new file mode 100644 index 00000000000..b69f8fc95f3 --- /dev/null +++ b/js/js.translator/testFiles/expression/stringTemplates/cases/stringValues.kt @@ -0,0 +1,11 @@ +package foo + +fun box(): Boolean { + val a = "abc" + val b = "def" + val message = "a = $a, b = $b" + + if (message != "a = abc, b = def") return false + + return true +} \ No newline at end of file