JS test: removed legacy inline tests

This commit is contained in:
Alexey Tsvetkov
2014-07-18 12:04:43 +04:00
committed by Zalim Bashorov
parent 0484df00c3
commit 1dcc096753
10 changed files with 1 additions and 150 deletions
@@ -16,72 +16,10 @@
package org.jetbrains.k2js.test.semantics;
import com.intellij.openapi.util.io.FileUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.k2js.config.EcmaVersion;
import org.jetbrains.k2js.test.SingleFileTranslationTest;
import java.io.File;
//TODO:
//Inlining turned off
@SuppressWarnings("UnusedDeclaration")
public abstract class InlineTest extends SingleFileTranslationTest {
public final class InlineTest extends SingleFileTranslationTest {
public InlineTest() {
super("inline/");
}
public void testFunctionWithoutParameters() throws Exception {
checkFooBoxIsTrueAndFunctionNameIsNotReferenced("functionWithoutParameters.kt", "myInlineFun");
}
public void testFunctionWithBlockBody() throws Exception {
checkFooBoxIsTrueAndFunctionNameIsNotReferenced("functionWithBlockBody.kt", "myInlineFun");
}
public void testFunctionWithOneParameter() throws Exception {
checkFooBoxIsTrueAndFunctionNameIsNotReferenced("functionWithOneParameter.kt", "myInlineFun");
}
public void testFunctionWithTwoParameters() throws Exception {
checkFooBoxIsTrueAndFunctionNameIsNotReferenced("functionWithTwoParameters.kt", "myInlineFun");
}
public void testMethod() throws Exception {
checkFooBoxIsTrueAndFunctionNameIsNotReferenced("method.kt", "myInlineMethod");
}
public void testMethodWithReferenceToThis() throws Exception {
checkFooBoxIsTrueAndFunctionNameIsNotReferenced("methodWithReferenceToThis.kt", "myInlineMethod");
}
public void testMethodWithIndirectlyReferencedThis() throws Exception {
checkFooBoxIsTrueAndFunctionNameIsNotReferenced("methodWithIndirectlyReferencedThis.kt", "myInlineMethod");
}
public void testExtension() throws Exception {
checkFooBoxIsTrueAndFunctionNameIsNotReferenced("extension.kt", "myInlineExtension");
}
public void testExtensionWithParameter() throws Exception {
checkFooBoxIsTrueAndFunctionNameIsNotReferenced("extensionWithParameter.kt", "myInlineExtension");
}
private void checkFooBoxIsTrueAndFunctionNameIsNotReferenced(@NotNull String filename, String funName) throws Exception {
fooBoxTest();
String generatedJSFilePath = getOutputFilePath(filename, EcmaVersion.defaultVersion());
String outputFileText = FileUtil.loadFile(new File(generatedJSFilePath), true);
assertTrue(countOccurrences(outputFileText, funName) == 1);
}
private static int countOccurrences(@NotNull String str, @NotNull String subStr) {
int count = 0;
String s = str;
while (s.contains(subStr)) {
s = s.replaceFirst(subStr, "");
count++;
}
return count;
}
}
@@ -1,9 +0,0 @@
package foo
class A() {
val a = 5
}
inline fun A.myInlineExtension() = a + 1
fun box() = A().myInlineExtension() == 6
@@ -1,9 +0,0 @@
package foo
class A() {
val a = 5
}
inline fun A.myInlineExtension(i: Int) = a + i
fun box() = A().myInlineExtension(1) == 6
@@ -1,7 +0,0 @@
package foo
fun box() = !myInlineFun()
inline fun myInlineFun(): Boolean {
return false
}
@@ -1,9 +0,0 @@
package foo
fun box(): Boolean {
val t = myInlineFun(1 == 2)
val f = myInlineFun(1 == 2)
return t and f
}
inline fun myInlineFun(t: Boolean) = !t
@@ -1,13 +0,0 @@
package foo
fun box(): Boolean {
if (myInlineFun(3, 2) != 1) {
return false;
}
if (myInlineFun(100, -100) != 200) {
return false;
}
return true;
}
inline fun myInlineFun(l: Int, r: Int) = l - r
@@ -1,5 +0,0 @@
package foo
fun box() = myInlineFun()
inline fun myInlineFun() = true
@@ -1,11 +0,0 @@
package foo
fun box(): Boolean {
return (!(A().myInlineMethod()))
}
class A() {
inline fun myInlineMethod(): Boolean {
return false
}
}
@@ -1,13 +0,0 @@
package foo
fun box(): Boolean {
return !(A(false).wrap()) and A(true).wrap()
}
class A(val a: Boolean) {
inline fun myInlineMethod(): Boolean {
return a
}
fun wrap() = myInlineMethod()
}
@@ -1,11 +0,0 @@
package foo
fun box(): Boolean {
return !(A(false).myInlineMethod()) and A(true).myInlineMethod()
}
class A(val a: Boolean) {
inline fun myInlineMethod(): Boolean {
return a
}
}