added a test case to compile some of the standard kotlin library as JS
This commit is contained in:
@@ -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<EcmaVersion> ecmaVersions,
|
||||||
|
String... stdLibFiles) throws Exception {
|
||||||
|
List<String> 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!!!"));
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user