From bed2ec95d15fad86c57c23dcc43b8cf6cb1b5a31 Mon Sep 17 00:00:00 2001 From: James Strachan Date: Tue, 29 May 2012 10:29:18 +0100 Subject: [PATCH] added a test case to compile some of the standard kotlin library as JS --- .../k2js/test/semantics/StdLibToJSTest.java | 82 +++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 js/js.tests/test/org/jetbrains/k2js/test/semantics/StdLibToJSTest.java diff --git a/js/js.tests/test/org/jetbrains/k2js/test/semantics/StdLibToJSTest.java b/js/js.tests/test/org/jetbrains/k2js/test/semantics/StdLibToJSTest.java new file mode 100644 index 00000000000..3144673b67a --- /dev/null +++ b/js/js.tests/test/org/jetbrains/k2js/test/semantics/StdLibToJSTest.java @@ -0,0 +1,82 @@ +/* + * Copyright 2010-2012 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.semantics; + +import com.google.common.collect.Lists; +import com.intellij.openapi.util.io.FileUtil; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.lang.psi.JetFile; +import org.jetbrains.k2js.config.Config; +import org.jetbrains.k2js.config.EcmaVersion; +import org.jetbrains.k2js.facade.MainCallParameters; +import org.jetbrains.k2js.test.SingleFileTranslationTest; +import org.jetbrains.k2js.test.rhino.RhinoFunctionNativeObjectResultChecker; +import org.jetbrains.k2js.utils.JetFileUtils; +import org.w3c.dom.Document; +import org.w3c.dom.Element; + +import javax.xml.parsers.DocumentBuilderFactory; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.*; + +/** + */ +public final class StdLibToJSTest extends SingleFileTranslationTest { + + public StdLibToJSTest() { + super("stdlib/"); + } + + public void testDummy() { + } + + public void TODO_testCompileStandardLibraryFiles() throws Exception { + + generateJavaScriptFiles(MainCallParameters.noCall(), EcmaVersion.all(), + "kotlin/dom/Dom.kt", + "kotlin/support/AbstractIterator.kt" + ); + } + + protected void generateJavaScriptFiles(@NotNull MainCallParameters mainCallParameters, + @NotNull EnumSet ecmaVersions, + String... stdLibFiles) throws Exception { + List files = Lists.newArrayList(); + + // lets add the standard JS library files + /* + for (String libFileName : Config.LIB_FILE_NAMES) { + files.add(Config.LIBRARIES_LOCATION + libFileName); + } + */ + + File stdlibDir = new File("libraries/stdlib/src"); + assertTrue("Cannot find stdlib source: " + stdlibDir, stdlibDir.exists()); + for (String file : stdLibFiles) { + files.add(new File(stdlibDir, file).getPath()); + } + generateJavaScriptFiles(files, getTestName(false) + ".kt", mainCallParameters, ecmaVersions); + + /* + runRhinoTests(getOutputFilePaths(kotlinFilename, ecmaVersions), + new RhinoFunctionNativeObjectResultChecker("test.browser", "foo", "Some Dynamically Created Content!!!")); + */ + } +}