Rename: SingleFileTest -> SuiteBuilder

This commit is contained in:
pTalanov
2012-03-02 15:45:39 +04:00
parent 90de7f6ced
commit 36b5d761a2
3 changed files with 33 additions and 21 deletions
@@ -19,13 +19,13 @@ package org.jetbrains.k2js.test;
import com.intellij.testFramework.UsefulTestCase;
import junit.framework.Test;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.k2js.test.utils.SingleFileTest;
import org.jetbrains.k2js.test.utils.SuiteBuilder;
@SuppressWarnings("JUnitTestCaseWithNoTests")
public final class ExamplesTest extends UsefulTestCase {
public static Test suite() {
return SingleFileTest.suiteForDirectory("examples/", new SingleFileTest.Tester() {
public static Test suite() throws Exception {
return SuiteBuilder.suiteForDirectory("examples/", new SuiteBuilder.Tester() {
@Override
public void performTest(@NotNull TranslationTest test, @NotNull String filename) throws Exception {
test.runFunctionOutputTest(filename, "Anonymous", "box", "OK");
@@ -19,7 +19,7 @@ package org.jetbrains.k2js.test;
import com.intellij.testFramework.UsefulTestCase;
import junit.framework.Test;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.k2js.test.utils.SingleFileTest;
import org.jetbrains.k2js.test.utils.SuiteBuilder;
/**
* @author Pavel Talanov
@@ -27,8 +27,8 @@ import org.jetbrains.k2js.test.utils.SingleFileTest;
@SuppressWarnings("JUnitTestCaseWithNoTests")
public final class SimpleTestSuite extends UsefulTestCase {
public static Test suite() {
return SingleFileTest.suiteForDirectory("simple/", new SingleFileTest.Tester() {
public static Test suite() throws Exception {
return SuiteBuilder.suiteForDirectory("simple/", new SuiteBuilder.Tester() {
@Override
public void performTest(@NotNull TranslationTest test, @NotNull String filename) throws Exception {
@@ -16,6 +16,7 @@
package org.jetbrains.k2js.test.utils;
import com.intellij.testFramework.UsefulTestCase;
import junit.framework.Test;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.k2js.test.TranslationTest;
@@ -24,29 +25,41 @@ import org.jetbrains.k2js.test.TranslatorTestCaseBuilder;
/**
* @author Pavel Talanov
*/
public abstract class SingleFileTest extends TranslationTest {
@SuppressWarnings("JUnitTestCaseWithNoTests")
public abstract class SuiteBuilder extends TranslationTest {
@NotNull
private final Tester tester;
@NotNull
private final String name;
protected SingleFileTest(@NotNull String pathToMain, @NotNull String name, @NotNull Tester tester) {
private SuiteBuilder(@NotNull String pathToMain) {
super(pathToMain);
setName(name);
this.tester = tester;
this.name = name;
}
public interface Tester {
void performTest(@NotNull TranslationTest test, @NotNull String filename) throws Exception;
}
public void runTest() throws Exception {
tester.performTest(this, name);
@SuppressWarnings("JUnitTestCaseWithNonTrivialConstructors")
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(),
true,
@@ -54,8 +67,7 @@ public abstract class SingleFileTest extends TranslationTest {
@NotNull
@Override
public Test createTest(@NotNull String name) {
return (new SingleFileTest(main, name, testMethod) {
});
return singleFileTest.new SingleFileTest(name, testMethod);
}
});
}