From 0d322fe8bcdc11fe0b27234cbf724a44da97798a Mon Sep 17 00:00:00 2001 From: Zalim Bashorov Date: Fri, 18 Oct 2013 19:21:59 +0400 Subject: [PATCH] K2JS: add ed outputPrefix and outputPostfix compiler arguments to K2JSCompiler. --- .../arguments/K2JSCompilerArguments.java | 6 + .../jetbrains/jet/cli/js/K2JSCompiler.java | 31 ++++- .../cli/outputPostfixFileNotFound.out | 2 + .../testData/cli/outputPrefixFileNotFound.out | 2 + .../jetbrains/jet/cli/jvm/CliBaseTest.java | 1 + .../jetbrains/jet/cli/jvm/K2JsCliTest.java | 57 +++++++++ .../jetbrains/jet/cli/jvm/K2JvmCliTest.java | 9 +- .../k2js/test/OutputPrefixPostfixTest.java | 118 ++++++++++++++++++ .../test/{semantics => }/SourcemapTest.java | 8 +- .../compiler/sourcemap/SourceMap3Builder.java | 8 +- .../compiler/sourcemap/SourceMapBuilder.java | 2 + .../jetbrains/k2js/facade/K2JSTranslator.java | 26 +++- .../outputPrefixPostfix/cases/simple.kt | 21 ++++ .../cases/simpleWithPostfix.kt | 21 ++++ .../cases/simpleWithPostfix.kt.postfix | 3 + .../cases/simpleWithPrefix.kt | 21 ++++ .../cases/simpleWithPrefix.kt.prefix | 3 + .../cases/simpleWithPrefixAndPostfix.kt | 21 ++++ .../simpleWithPrefixAndPostfix.kt.postfix | 3 + .../simpleWithPrefixAndPostfix.kt.prefix | 3 + 20 files changed, 352 insertions(+), 14 deletions(-) create mode 100644 compiler/testData/cli/outputPostfixFileNotFound.out create mode 100644 compiler/testData/cli/outputPrefixFileNotFound.out create mode 100644 compiler/tests/org/jetbrains/jet/cli/jvm/K2JsCliTest.java create mode 100644 js/js.tests/test/org/jetbrains/k2js/test/OutputPrefixPostfixTest.java rename js/js.tests/test/org/jetbrains/k2js/test/{semantics => }/SourcemapTest.java (93%) create mode 100644 js/js.translator/testFiles/outputPrefixPostfix/cases/simple.kt create mode 100644 js/js.translator/testFiles/outputPrefixPostfix/cases/simpleWithPostfix.kt create mode 100644 js/js.translator/testFiles/outputPrefixPostfix/cases/simpleWithPostfix.kt.postfix create mode 100644 js/js.translator/testFiles/outputPrefixPostfix/cases/simpleWithPrefix.kt create mode 100644 js/js.translator/testFiles/outputPrefixPostfix/cases/simpleWithPrefix.kt.prefix create mode 100644 js/js.translator/testFiles/outputPrefixPostfix/cases/simpleWithPrefixAndPostfix.kt create mode 100644 js/js.translator/testFiles/outputPrefixPostfix/cases/simpleWithPrefixAndPostfix.kt.postfix create mode 100644 js/js.translator/testFiles/outputPrefixPostfix/cases/simpleWithPrefixAndPostfix.kt.prefix diff --git a/compiler/cli/cli-common/src/org/jetbrains/jet/cli/common/arguments/K2JSCompilerArguments.java b/compiler/cli/cli-common/src/org/jetbrains/jet/cli/common/arguments/K2JSCompilerArguments.java index b5c3e8b0471..bcf0c91fbbf 100644 --- a/compiler/cli/cli-common/src/org/jetbrains/jet/cli/common/arguments/K2JSCompilerArguments.java +++ b/compiler/cli/cli-common/src/org/jetbrains/jet/cli/common/arguments/K2JSCompilerArguments.java @@ -45,4 +45,10 @@ public class K2JSCompilerArguments extends CommonCompilerArguments { @Argument(value = "main", description = "Whether a main function should be called; either '" + CALL + "' or '" + NO_CALL + "', default '" + CALL + "' (main function will be auto detected)") public String main; + + @Argument(value = "outputPrefix", description = "Path to file which will be added to the begin of output file") + public String outputPrefix; + + @Argument(value = "outputPostfix", description = "Path to file which will be added to the end of output file") + public String outputPostfix; } diff --git a/compiler/cli/src/org/jetbrains/jet/cli/js/K2JSCompiler.java b/compiler/cli/src/org/jetbrains/jet/cli/js/K2JSCompiler.java index cc0bd6f3981..f5a42afe5e0 100644 --- a/compiler/cli/src/org/jetbrains/jet/cli/js/K2JSCompiler.java +++ b/compiler/cli/src/org/jetbrains/jet/cli/js/K2JSCompiler.java @@ -104,8 +104,30 @@ public class K2JSCompiler extends CLICompiler { return COMPILATION_ERROR; } + File outputPrefixFile = null; + if (arguments.outputPrefix != null) { + outputPrefixFile = new File(arguments.outputPrefix); + if (!outputPrefixFile.exists()) { + messageCollector.report(CompilerMessageSeverity.ERROR, + "Output prefix file '" + arguments.outputPrefix + "' not found", + CompilerMessageLocation.NO_LOCATION); + return ExitCode.COMPILATION_ERROR; + } + } + + File outputPostfixFile = null; + if (arguments.outputPostfix != null) { + outputPostfixFile = new File(arguments.outputPostfix); + if (!outputPostfixFile.exists()) { + messageCollector.report(CompilerMessageSeverity.ERROR, + "Output postfix file '" + arguments.outputPostfix + "' not found", + CompilerMessageLocation.NO_LOCATION); + return ExitCode.COMPILATION_ERROR; + } + } + MainCallParameters mainCallParameters = createMainCallParameters(arguments.main); - return translateAndGenerateOutputFile(mainCallParameters, environmentForJS, config, outputFile); + return translateAndGenerateOutputFile(mainCallParameters, environmentForJS, config, outputFile, outputPrefixFile, outputPostfixFile); } private static void reportCompiledSourcesList(@NotNull MessageCollector messageCollector, @@ -131,10 +153,13 @@ public class K2JSCompiler extends CLICompiler { @NotNull MainCallParameters mainCall, @NotNull JetCoreEnvironment environmentForJS, @NotNull Config config, - @NotNull String outputFile + @NotNull String outputFile, + @Nullable File outputPrefix, + @Nullable File outputPostfix ) { try { - K2JSTranslator.translateWithMainCallParametersAndSaveToFile(mainCall, environmentForJS.getSourceFiles(), outputFile, config); + K2JSTranslator.translateWithMainCallParametersAndSaveToFile(mainCall, environmentForJS.getSourceFiles(), + outputFile, outputPrefix, outputPostfix, config); } catch (Exception e) { throw new RuntimeException(e); diff --git a/compiler/testData/cli/outputPostfixFileNotFound.out b/compiler/testData/cli/outputPostfixFileNotFound.out new file mode 100644 index 00000000000..03501d1cd7d --- /dev/null +++ b/compiler/testData/cli/outputPostfixFileNotFound.out @@ -0,0 +1,2 @@ +ERROR: Output postfix file 'not/existing/path' not found +COMPILATION_ERROR diff --git a/compiler/testData/cli/outputPrefixFileNotFound.out b/compiler/testData/cli/outputPrefixFileNotFound.out new file mode 100644 index 00000000000..2544f978613 --- /dev/null +++ b/compiler/testData/cli/outputPrefixFileNotFound.out @@ -0,0 +1,2 @@ +ERROR: Output prefix file 'not/existing/path' not found +COMPILATION_ERROR diff --git a/compiler/tests/org/jetbrains/jet/cli/jvm/CliBaseTest.java b/compiler/tests/org/jetbrains/jet/cli/jvm/CliBaseTest.java index 1e737e5a830..bdf54e07c06 100644 --- a/compiler/tests/org/jetbrains/jet/cli/jvm/CliBaseTest.java +++ b/compiler/tests/org/jetbrains/jet/cli/jvm/CliBaseTest.java @@ -31,6 +31,7 @@ import java.io.File; import java.io.PrintStream; public class CliBaseTest { + protected static final String NOT_EXISTING_PATH = "not/existing/path"; @Rule public final Tmpdir tmpdir = new Tmpdir(); diff --git a/compiler/tests/org/jetbrains/jet/cli/jvm/K2JsCliTest.java b/compiler/tests/org/jetbrains/jet/cli/jvm/K2JsCliTest.java new file mode 100644 index 00000000000..87a1fd8ec4d --- /dev/null +++ b/compiler/tests/org/jetbrains/jet/cli/jvm/K2JsCliTest.java @@ -0,0 +1,57 @@ +/* + * Copyright 2010-2013 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.jet.cli.jvm; + +import com.google.common.collect.Lists; +import com.intellij.util.ArrayUtil; +import junit.framework.Assert; +import org.junit.Test; + +import java.io.File; +import java.util.Collections; +import java.util.List; + +public class K2JsCliTest extends CliBaseTest { + @Test + public void simple() { + doSimpleTest(/*expectedOutFile =*/ true); + } + + @Test + public void outputPrefixFileNotFound() { + doSimpleTest(/*expectedOutFile =*/ false, + "-outputPrefix", NOT_EXISTING_PATH); + } + + @Test + public void outputPostfixFileNotFound() { + doSimpleTest(/*expectedOutFile =*/ false, + "-outputPostfix", NOT_EXISTING_PATH); + } + + private void doSimpleTest(boolean expectedOutFile, String... additionalArgs) { + File outputFile = new File(tmpdir.getTmpDir(), "out.js"); + List args = Lists.newArrayList( + "-sourceFiles", "compiler/testData/cli/simple2js.kt", + "-output", outputFile.getPath()); + Collections.addAll(args, additionalArgs); + + executeCompilerCompareOutputJS(ArrayUtil.toStringArray(args)); + + Assert.assertEquals(expectedOutFile, outputFile.isFile()); + } +} diff --git a/compiler/tests/org/jetbrains/jet/cli/jvm/K2JvmCliTest.java b/compiler/tests/org/jetbrains/jet/cli/jvm/K2JvmCliTest.java index 399782b7c25..41e6d0722a5 100644 --- a/compiler/tests/org/jetbrains/jet/cli/jvm/K2JvmCliTest.java +++ b/compiler/tests/org/jetbrains/jet/cli/jvm/K2JvmCliTest.java @@ -24,6 +24,9 @@ import org.junit.Test; import java.io.File; public class K2JvmCliTest extends CliBaseTest { + + protected static final String ANOTHER_NOT_EXISTING_PATH = "yet/another/not/existing/path"; + @Test public void wrongKotlinSignature() throws Exception { String[] args = { @@ -46,8 +49,8 @@ public class K2JvmCliTest extends CliBaseTest { public void nonExistingClassPathAndAnnotationsPath() { String[] args = { "-src", "compiler/testData/cli/simple.kt", - "-classpath", "not/existing/path", - "-annotations", "yet/another/not/existing/path", + "-classpath", NOT_EXISTING_PATH, + "-annotations", ANOTHER_NOT_EXISTING_PATH, "-output", tmpdir.getTmpDir().getPath()}; executeCompilerCompareOutputJVM(args); @@ -57,7 +60,7 @@ public class K2JvmCliTest extends CliBaseTest { @Test public void nonExistingSourcePath() { String[] args = { - "-src", "not/existing/path", + "-src", NOT_EXISTING_PATH, "-output", tmpdir.getTmpDir().getPath()}; executeCompilerCompareOutputJVM(args); } diff --git a/js/js.tests/test/org/jetbrains/k2js/test/OutputPrefixPostfixTest.java b/js/js.tests/test/org/jetbrains/k2js/test/OutputPrefixPostfixTest.java new file mode 100644 index 00000000000..a60d7ef68f1 --- /dev/null +++ b/js/js.tests/test/org/jetbrains/k2js/test/OutputPrefixPostfixTest.java @@ -0,0 +1,118 @@ +/* + * Copyright 2010-2013 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.intellij.openapi.project.Project; +import com.intellij.openapi.util.io.FileUtil; +import junit.framework.Test; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.k2js.config.EcmaVersion; +import org.jetbrains.k2js.facade.K2JSTranslator; +import org.jetbrains.k2js.facade.MainCallParameters; +import org.jetbrains.k2js.test.config.TestConfigFactory; +import org.jetbrains.k2js.test.semantics.TranslatorTestCaseBuilder; + +import java.io.File; +import java.util.List; + +import static org.jetbrains.k2js.test.utils.TranslationUtils.createJetFileList; +import static org.jetbrains.k2js.test.utils.TranslationUtils.getConfig; + +@SuppressWarnings("JUnitTestCaseWithNoTests") +public final class OutputPrefixPostfixTest extends SingleFileTranslationTest { + private static final String PREFIX_EXT = ".prefix"; + private static final String POSTFIX_EXT = ".postfix"; + + @NotNull + private final String filename; + private final File outputPrefixFile; + private final File outputPostfixFile; + + @SuppressWarnings("JUnitTestCaseWithNonTrivialConstructors") + public OutputPrefixPostfixTest(@NotNull String filename) { + super("outputPrefixPostfix/"); + this.filename = filename; + + String inputFilePath = getInputFilePath(filename); + this.outputPrefixFile = newFileIfExists(inputFilePath + PREFIX_EXT); + this.outputPostfixFile = newFileIfExists(inputFilePath + POSTFIX_EXT); + } + + @Override + protected void translateFiles( + @NotNull Project project, + @NotNull List files, + @NotNull String outputFile, + @NotNull MainCallParameters mainCallParameters, + @NotNull EcmaVersion version, + @NotNull TestConfigFactory configFactory + ) throws Exception { + K2JSTranslator.translateWithMainCallParametersAndSaveToFile(mainCallParameters, createJetFileList(project, files, null), + outputFile, outputPrefixFile, outputPostfixFile, + getConfig(project, version, configFactory)); + } + + @Override + public void runTest() throws Exception { + checkFooBoxIsOk(filename); + } + + @Override + protected void runFunctionOutputTest( + @NotNull Iterable ecmaVersions, + @NotNull String kotlinFilename, + @NotNull String namespaceName, + @NotNull String functionName, + @NotNull Object expectedResult + ) throws Exception { + super.runFunctionOutputTest(ecmaVersions, kotlinFilename, namespaceName, functionName, expectedResult); + + for (EcmaVersion ecmaVersion : ecmaVersions) { + String output = FileUtil.loadFile(new File(getOutputFilePath(filename, ecmaVersion))); + if (outputPrefixFile != null) { + assertTrue(output.startsWith(FileUtil.loadFile(outputPrefixFile))); + } + if (outputPostfixFile != null) { + assertTrue(output.endsWith(FileUtil.loadFile(outputPostfixFile))); + } + } + } + + public static Test suite() throws Exception { + return TranslatorTestCaseBuilder + .suiteForDirectory(BasicTest.pathToTestFilesRoot() + "outputPrefixPostfix/cases/", new TranslatorTestCaseBuilder.NamedTestFactory() { + @NotNull + @Override + public Test createTest(@NotNull String filename) { + OutputPrefixPostfixTest examplesTest = new OutputPrefixPostfixTest(filename); + examplesTest.setName(filename); + return examplesTest; + } + }); + } + + @Nullable + private static File newFileIfExists(@NotNull String path) { + File file = new File(path); + if (!file.exists()) { + file = null; + } + + return file; + } +} diff --git a/js/js.tests/test/org/jetbrains/k2js/test/semantics/SourcemapTest.java b/js/js.tests/test/org/jetbrains/k2js/test/SourcemapTest.java similarity index 93% rename from js/js.tests/test/org/jetbrains/k2js/test/semantics/SourcemapTest.java rename to js/js.tests/test/org/jetbrains/k2js/test/SourcemapTest.java index 0973cc0e4c1..e18f4e12f72 100644 --- a/js/js.tests/test/org/jetbrains/k2js/test/semantics/SourcemapTest.java +++ b/js/js.tests/test/org/jetbrains/k2js/test/SourcemapTest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.jetbrains.k2js.test.semantics; +package org.jetbrains.k2js.test; import com.intellij.openapi.project.Project; import junit.framework.Test; @@ -22,10 +22,9 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.k2js.config.EcmaVersion; import org.jetbrains.k2js.facade.K2JSTranslator; import org.jetbrains.k2js.facade.MainCallParameters; -import org.jetbrains.k2js.test.BasicTest; -import org.jetbrains.k2js.test.SingleFileTranslationTest; import org.jetbrains.k2js.test.config.TestConfig; import org.jetbrains.k2js.test.config.TestConfigFactory; +import org.jetbrains.k2js.test.semantics.TranslatorTestCaseBuilder; import java.util.List; @@ -53,7 +52,8 @@ public final class SourcemapTest extends SingleFileTranslationTest { @NotNull EcmaVersion version, @NotNull TestConfigFactory configFactory ) throws Exception { - K2JSTranslator.translateWithMainCallParametersAndSaveToFile(mainCallParameters, createJetFileList(project, files, null), outputFile, + K2JSTranslator.translateWithMainCallParametersAndSaveToFile(mainCallParameters, createJetFileList(project, files, null), + outputFile, null, null, getConfig(project, version, configFactory)); } diff --git a/js/js.translator/src/org/jetbrains/js/compiler/sourcemap/SourceMap3Builder.java b/js/js.translator/src/org/jetbrains/js/compiler/sourcemap/SourceMap3Builder.java index e56f9a3180b..b68457478bf 100644 --- a/js/js.translator/src/org/jetbrains/js/compiler/sourcemap/SourceMap3Builder.java +++ b/js/js.translator/src/org/jetbrains/js/compiler/sourcemap/SourceMap3Builder.java @@ -2,6 +2,7 @@ package org.jetbrains.js.compiler.sourcemap; import com.google.dart.compiler.common.SourceInfo; import com.google.dart.compiler.util.TextOutput; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.util.PairConsumer; import gnu.trove.TObjectIntHashMap; @@ -77,6 +78,11 @@ public class SourceMap3Builder implements SourceMapBuilder { previousGeneratedColumn = -1; } + @Override + public void skipLinesInBegin(int count) { + out.insert(0, StringUtil.repeatSymbol(';', count)); + } + @Override public void processSourceInfo(Object sourceInfo) { if (sourceInfo instanceof SourceInfo) { @@ -132,7 +138,7 @@ public class SourceMap3Builder implements SourceMapBuilder { public void addLink() { textOutput.print("\n//@ sourceMappingURL="); textOutput.print(generatedFile.getName()); - textOutput.print(".map"); + textOutput.print(".map\n"); } private static final class Base64VLQ { diff --git a/js/js.translator/src/org/jetbrains/js/compiler/sourcemap/SourceMapBuilder.java b/js/js.translator/src/org/jetbrains/js/compiler/sourcemap/SourceMapBuilder.java index 8897c9646f2..0b65aef1087 100644 --- a/js/js.translator/src/org/jetbrains/js/compiler/sourcemap/SourceMapBuilder.java +++ b/js/js.translator/src/org/jetbrains/js/compiler/sourcemap/SourceMapBuilder.java @@ -21,6 +21,8 @@ import java.io.File; public interface SourceMapBuilder { void newLine(); + void skipLinesInBegin(int count); + void addMapping(String source, int sourceLine, int sourceColumn); void processSourceInfo(Object info); diff --git a/js/js.translator/src/org/jetbrains/k2js/facade/K2JSTranslator.java b/js/js.translator/src/org/jetbrains/k2js/facade/K2JSTranslator.java index c1223a8a43e..d0c7de6c3c9 100644 --- a/js/js.translator/src/org/jetbrains/k2js/facade/K2JSTranslator.java +++ b/js/js.translator/src/org/jetbrains/k2js/facade/K2JSTranslator.java @@ -20,6 +20,7 @@ import com.google.dart.compiler.backend.js.ast.JsProgram; import com.google.dart.compiler.util.TextOutputImpl; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.io.FileUtil; +import com.intellij.openapi.util.text.StringUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.psi.JetFile; @@ -48,16 +49,35 @@ public final class K2JSTranslator { public static final String FLUSH_SYSTEM_OUT = "Kotlin.System.flush();\n"; public static final String GET_SYSTEM_OUT = "Kotlin.System.output();\n"; - public static void translateWithMainCallParametersAndSaveToFile(@NotNull MainCallParameters mainCall, + public static void translateWithMainCallParametersAndSaveToFile( + @NotNull MainCallParameters mainCall, @NotNull List files, @NotNull String outputPath, - @NotNull Config config) throws TranslationException, IOException { + @Nullable File outputPrefixFile, + @Nullable File outputPostfixFile, + @NotNull Config config + ) throws TranslationException, IOException { K2JSTranslator translator = new K2JSTranslator(config); File outFile = new File(outputPath); TextOutputImpl output = new TextOutputImpl(); SourceMapBuilder sourceMapBuilder = config.isSourcemap() ? new SourceMap3Builder(outFile, output, new SourceMapBuilderConsumer()) : null; String programCode = translator.generateProgramCode(files, mainCall, output, sourceMapBuilder); - FileUtil.writeToFile(outFile, programCode); + + if (outputPrefixFile != null) { + String prefix = FileUtil.loadFile(outputPrefixFile); + FileUtil.writeToFile(outFile, prefix); + if (sourceMapBuilder != null) { + sourceMapBuilder.skipLinesInBegin(StringUtil.getLineBreakCount(prefix)); + } + } + + FileUtil.writeToFile(outFile, programCode.getBytes(), outputPrefixFile != null); + + if (outputPostfixFile != null) { + byte[] postfix = FileUtil.loadFileBytes(outputPostfixFile); + FileUtil.writeToFile(outFile, postfix, true); + } + if (sourceMapBuilder != null) { FileUtil.writeToFile(sourceMapBuilder.getOutFile(), sourceMapBuilder.build()); } diff --git a/js/js.translator/testFiles/outputPrefixPostfix/cases/simple.kt b/js/js.translator/testFiles/outputPrefixPostfix/cases/simple.kt new file mode 100644 index 00000000000..326708020f8 --- /dev/null +++ b/js/js.translator/testFiles/outputPrefixPostfix/cases/simple.kt @@ -0,0 +1,21 @@ +/* + * Copyright 2010-2013 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 foo + +fun box(): String { + return "OK" +} diff --git a/js/js.translator/testFiles/outputPrefixPostfix/cases/simpleWithPostfix.kt b/js/js.translator/testFiles/outputPrefixPostfix/cases/simpleWithPostfix.kt new file mode 100644 index 00000000000..326708020f8 --- /dev/null +++ b/js/js.translator/testFiles/outputPrefixPostfix/cases/simpleWithPostfix.kt @@ -0,0 +1,21 @@ +/* + * Copyright 2010-2013 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 foo + +fun box(): String { + return "OK" +} diff --git a/js/js.translator/testFiles/outputPrefixPostfix/cases/simpleWithPostfix.kt.postfix b/js/js.translator/testFiles/outputPrefixPostfix/cases/simpleWithPostfix.kt.postfix new file mode 100644 index 00000000000..d0d052bb514 --- /dev/null +++ b/js/js.translator/testFiles/outputPrefixPostfix/cases/simpleWithPostfix.kt.postfix @@ -0,0 +1,3 @@ +/* +SOME POSTFIX +*/ diff --git a/js/js.translator/testFiles/outputPrefixPostfix/cases/simpleWithPrefix.kt b/js/js.translator/testFiles/outputPrefixPostfix/cases/simpleWithPrefix.kt new file mode 100644 index 00000000000..326708020f8 --- /dev/null +++ b/js/js.translator/testFiles/outputPrefixPostfix/cases/simpleWithPrefix.kt @@ -0,0 +1,21 @@ +/* + * Copyright 2010-2013 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 foo + +fun box(): String { + return "OK" +} diff --git a/js/js.translator/testFiles/outputPrefixPostfix/cases/simpleWithPrefix.kt.prefix b/js/js.translator/testFiles/outputPrefixPostfix/cases/simpleWithPrefix.kt.prefix new file mode 100644 index 00000000000..066c305aeb8 --- /dev/null +++ b/js/js.translator/testFiles/outputPrefixPostfix/cases/simpleWithPrefix.kt.prefix @@ -0,0 +1,3 @@ +/* +SOME PREFIX +*/ diff --git a/js/js.translator/testFiles/outputPrefixPostfix/cases/simpleWithPrefixAndPostfix.kt b/js/js.translator/testFiles/outputPrefixPostfix/cases/simpleWithPrefixAndPostfix.kt new file mode 100644 index 00000000000..326708020f8 --- /dev/null +++ b/js/js.translator/testFiles/outputPrefixPostfix/cases/simpleWithPrefixAndPostfix.kt @@ -0,0 +1,21 @@ +/* + * Copyright 2010-2013 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 foo + +fun box(): String { + return "OK" +} diff --git a/js/js.translator/testFiles/outputPrefixPostfix/cases/simpleWithPrefixAndPostfix.kt.postfix b/js/js.translator/testFiles/outputPrefixPostfix/cases/simpleWithPrefixAndPostfix.kt.postfix new file mode 100644 index 00000000000..d0d052bb514 --- /dev/null +++ b/js/js.translator/testFiles/outputPrefixPostfix/cases/simpleWithPrefixAndPostfix.kt.postfix @@ -0,0 +1,3 @@ +/* +SOME POSTFIX +*/ diff --git a/js/js.translator/testFiles/outputPrefixPostfix/cases/simpleWithPrefixAndPostfix.kt.prefix b/js/js.translator/testFiles/outputPrefixPostfix/cases/simpleWithPrefixAndPostfix.kt.prefix new file mode 100644 index 00000000000..066c305aeb8 --- /dev/null +++ b/js/js.translator/testFiles/outputPrefixPostfix/cases/simpleWithPrefixAndPostfix.kt.prefix @@ -0,0 +1,3 @@ +/* +SOME PREFIX +*/