diff --git a/js/js.tests/test/org/jetbrains/k2js/test/SingleFileTranslationWithDirectivesTest.java b/js/js.tests/test/org/jetbrains/k2js/test/SingleFileTranslationWithDirectivesTest.java new file mode 100644 index 00000000000..e6318a6bd4f --- /dev/null +++ b/js/js.tests/test/org/jetbrains/k2js/test/SingleFileTranslationWithDirectivesTest.java @@ -0,0 +1,58 @@ +/* + * Copyright 2010-2014 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; + +import com.google.dart.compiler.backend.js.ast.JsNode; +import com.intellij.util.Consumer; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.k2js.test.utils.InlineTestUtils; +import org.jetbrains.k2js.test.utils.JsTestUtils; +import org.jetbrains.k2js.test.utils.MemoizeConsumer; + +public abstract class SingleFileTranslationWithDirectivesTest extends SingleFileTranslationTest { + private final MemoizeConsumer nodeConsumer = new MemoizeConsumer(); + + public SingleFileTranslationWithDirectivesTest(@NotNull String main) { + super(main); + } + + @Override + public void setUp() throws Exception { + super.setUp(); + nodeConsumer.consume(null); + } + + protected void checkFooBoxIsOkWithInlineDirectives() throws Exception { + checkFooBoxIsOk(); + processInlineDirectives(); + } + + protected void processInlineDirectives() throws Exception { + String fileName = getInputFilePath(getTestName(true) + ".kt"); + String fileText = JsTestUtils.readFile(fileName); + + JsNode lastJsNode = nodeConsumer.getLastValue(); + assert lastJsNode != null; + + InlineTestUtils.processDirectives(lastJsNode, fileText); + } + + @Override + protected Consumer getConsumer() { + return nodeConsumer; + } +} diff --git a/js/js.tests/test/org/jetbrains/k2js/test/semantics/InlineTest.java b/js/js.tests/test/org/jetbrains/k2js/test/semantics/InlineTest.java index d2f9f14b71d..9508b389c75 100644 --- a/js/js.tests/test/org/jetbrains/k2js/test/semantics/InlineTest.java +++ b/js/js.tests/test/org/jetbrains/k2js/test/semantics/InlineTest.java @@ -16,27 +16,14 @@ package org.jetbrains.k2js.test.semantics; -import com.google.dart.compiler.backend.js.ast.JsNode; -import com.intellij.util.Consumer; import org.jetbrains.k2js.inline.exception.InlineRecursionException; -import org.jetbrains.k2js.test.SingleFileTranslationTest; -import org.jetbrains.k2js.test.utils.InlineTestUtils; -import org.jetbrains.k2js.test.utils.JsTestUtils; -import org.jetbrains.k2js.test.utils.MemoizeConsumer; - -public final class InlineTest extends SingleFileTranslationTest { - private final MemoizeConsumer nodeConsumer = new MemoizeConsumer(); +import org.jetbrains.k2js.test.SingleFileTranslationWithDirectivesTest; +public final class InlineTest extends SingleFileTranslationWithDirectivesTest { public InlineTest() { super("inline/"); } - @Override - public void setUp() throws Exception { - super.setUp(); - nodeConsumer.consume(null); - } - public void testInlineSimpleAssignment() throws Exception { checkFooBoxIsOkWithInlineDirectives(); } @@ -252,24 +239,4 @@ public final class InlineTest extends SingleFileTranslationTest { public void testSimpleReturnFunctionWithResultUnused() throws Exception { checkFooBoxIsOkWithInlineDirectives(); } - - private void checkFooBoxIsOkWithInlineDirectives() throws Exception { - checkFooBoxIsOk(); - processInlineDirectives(); - } - - private void processInlineDirectives() throws Exception { - String fileName = getInputFilePath(getTestName(true) + ".kt"); - String fileText = JsTestUtils.readFile(fileName); - - JsNode lastJsNode = nodeConsumer.getLastValue(); - assert lastJsNode != null; - - InlineTestUtils.processDirectives(lastJsNode, fileText); - } - - @Override - protected Consumer getConsumer() { - return nodeConsumer; - } }