Rename: SingleFileTest -> SuiteBuilder
This commit is contained in:
@@ -19,13 +19,13 @@ package org.jetbrains.k2js.test;
|
|||||||
import com.intellij.testFramework.UsefulTestCase;
|
import com.intellij.testFramework.UsefulTestCase;
|
||||||
import junit.framework.Test;
|
import junit.framework.Test;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.k2js.test.utils.SingleFileTest;
|
import org.jetbrains.k2js.test.utils.SuiteBuilder;
|
||||||
|
|
||||||
@SuppressWarnings("JUnitTestCaseWithNoTests")
|
@SuppressWarnings("JUnitTestCaseWithNoTests")
|
||||||
public final class ExamplesTest extends UsefulTestCase {
|
public final class ExamplesTest extends UsefulTestCase {
|
||||||
|
|
||||||
public static Test suite() {
|
public static Test suite() throws Exception {
|
||||||
return SingleFileTest.suiteForDirectory("examples/", new SingleFileTest.Tester() {
|
return SuiteBuilder.suiteForDirectory("examples/", new SuiteBuilder.Tester() {
|
||||||
@Override
|
@Override
|
||||||
public void performTest(@NotNull TranslationTest test, @NotNull String filename) throws Exception {
|
public void performTest(@NotNull TranslationTest test, @NotNull String filename) throws Exception {
|
||||||
test.runFunctionOutputTest(filename, "Anonymous", "box", "OK");
|
test.runFunctionOutputTest(filename, "Anonymous", "box", "OK");
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ package org.jetbrains.k2js.test;
|
|||||||
import com.intellij.testFramework.UsefulTestCase;
|
import com.intellij.testFramework.UsefulTestCase;
|
||||||
import junit.framework.Test;
|
import junit.framework.Test;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.k2js.test.utils.SingleFileTest;
|
import org.jetbrains.k2js.test.utils.SuiteBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Pavel Talanov
|
* @author Pavel Talanov
|
||||||
@@ -27,8 +27,8 @@ import org.jetbrains.k2js.test.utils.SingleFileTest;
|
|||||||
@SuppressWarnings("JUnitTestCaseWithNoTests")
|
@SuppressWarnings("JUnitTestCaseWithNoTests")
|
||||||
public final class SimpleTestSuite extends UsefulTestCase {
|
public final class SimpleTestSuite extends UsefulTestCase {
|
||||||
|
|
||||||
public static Test suite() {
|
public static Test suite() throws Exception {
|
||||||
return SingleFileTest.suiteForDirectory("simple/", new SingleFileTest.Tester() {
|
return SuiteBuilder.suiteForDirectory("simple/", new SuiteBuilder.Tester() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void performTest(@NotNull TranslationTest test, @NotNull String filename) throws Exception {
|
public void performTest(@NotNull TranslationTest test, @NotNull String filename) throws Exception {
|
||||||
|
|||||||
+27
-15
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.k2js.test.utils;
|
package org.jetbrains.k2js.test.utils;
|
||||||
|
|
||||||
|
import com.intellij.testFramework.UsefulTestCase;
|
||||||
import junit.framework.Test;
|
import junit.framework.Test;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.k2js.test.TranslationTest;
|
import org.jetbrains.k2js.test.TranslationTest;
|
||||||
@@ -24,29 +25,41 @@ import org.jetbrains.k2js.test.TranslatorTestCaseBuilder;
|
|||||||
/**
|
/**
|
||||||
* @author Pavel Talanov
|
* @author Pavel Talanov
|
||||||
*/
|
*/
|
||||||
public abstract class SingleFileTest extends TranslationTest {
|
@SuppressWarnings("JUnitTestCaseWithNoTests")
|
||||||
|
public abstract class SuiteBuilder extends TranslationTest {
|
||||||
|
|
||||||
@NotNull
|
private SuiteBuilder(@NotNull String pathToMain) {
|
||||||
private final Tester tester;
|
|
||||||
@NotNull
|
|
||||||
private final String name;
|
|
||||||
|
|
||||||
protected SingleFileTest(@NotNull String pathToMain, @NotNull String name, @NotNull Tester tester) {
|
|
||||||
super(pathToMain);
|
super(pathToMain);
|
||||||
setName(name);
|
|
||||||
this.tester = tester;
|
|
||||||
this.name = name;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface Tester {
|
public interface Tester {
|
||||||
void performTest(@NotNull TranslationTest test, @NotNull String filename) throws Exception;
|
void performTest(@NotNull TranslationTest test, @NotNull String filename) throws Exception;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void runTest() throws Exception {
|
@SuppressWarnings("JUnitTestCaseWithNonTrivialConstructors")
|
||||||
tester.performTest(this, name);
|
private class SingleFileTest extends UsefulTestCase {
|
||||||
|
|
||||||
|
public SingleFileTest(@NotNull String name, @NotNull Tester tester) {
|
||||||
|
setName(name);
|
||||||
|
this.tester = tester;
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private final Tester tester;
|
||||||
|
@NotNull
|
||||||
|
private final String name;
|
||||||
|
|
||||||
|
public void runTest() throws Exception {
|
||||||
|
tester.performTest(SuiteBuilder.this, name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Test suiteForDirectory(@NotNull final String main, @NotNull final SingleFileTest.Tester testMethod) {
|
|
||||||
|
public static Test suiteForDirectory(@NotNull final String main, @NotNull final SuiteBuilder.Tester testMethod) throws Exception {
|
||||||
|
final SuiteBuilder singleFileTest = new SuiteBuilder(main) {
|
||||||
|
};
|
||||||
|
singleFileTest.setUp();
|
||||||
|
|
||||||
return TranslatorTestCaseBuilder.suiteForDirectory(TEST_FILES + main + casesDirectoryName(),
|
return TranslatorTestCaseBuilder.suiteForDirectory(TEST_FILES + main + casesDirectoryName(),
|
||||||
true,
|
true,
|
||||||
@@ -54,8 +67,7 @@ public abstract class SingleFileTest extends TranslationTest {
|
|||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public Test createTest(@NotNull String name) {
|
public Test createTest(@NotNull String name) {
|
||||||
return (new SingleFileTest(main, name, testMethod) {
|
return singleFileTest.new SingleFileTest(name, testMethod);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user