Some magic to make test work

This commit is contained in:
Pavel V. Talanov
2012-05-25 14:45:01 +04:00
parent f03ce0795e
commit 2bb647bdb8
4 changed files with 32 additions and 38 deletions
+25 -19
View File
@@ -1,27 +1,33 @@
package org.w3c.dom package org.w3c.dom
import js.noImpl
/** /**
* A stub class definition so we can work with the DOM APIs as native objects * A stub class definition so we can work with the DOM APIs as native objects
*/ */
native public interface Document : Node { native public trait Document : Node {
fun getElementById(id : String) : Element = js.noImpl
fun createTextNode(text : String) : Node = js.noImpl
} }
native public interface Attr : Node {} native public trait Attr : Node {}
native public interface CDATASection : Text {} native public trait CDATASection : Text {}
native public interface CharacterData : Node {} native public trait CharacterData : Node {}
native public interface Comment : CharacterData {} native public trait Comment : CharacterData {}
native public interface DOMImplementation {} native public trait DOMImplementation {}
native public interface DocumentType : Node {} native public trait DocumentType : Node {}
native public interface Element : Node {} native public trait Element : Node {
native public interface Entity : Node {} fun appendChild(child : Node) : Unit = js.noImpl
native public interface EntityReference : Node {} }
native public interface NameList {} native public trait Entity : Node {}
native public interface NamedNodeMap {} native public trait EntityReference : Node {}
native public interface Node {} native public trait NameList {}
native public interface NodeList {} native public trait NamedNodeMap {}
native public interface Notation : Node {} native public trait Node {}
native public interface ProcessingInstruction : Node {} native public trait NodeList {}
native public interface Text : CharacterData {} native public trait Notation : Node {}
native public interface TypeInfo {} native public trait ProcessingInstruction : Node {}
native public interface UserDataHandler {} native public trait Text : CharacterData {}
native public trait TypeInfo {}
native public trait UserDataHandler {}
+1 -1
View File
@@ -1,8 +1,8 @@
package kotlin.browser package kotlin.browser
import org.w3c.dom.Document
import js.native import js.native
import js.library import js.library
import org.w3c.dom.Document
/** /**
* Provides access to the current active browsers DOM for the currently visible page. * Provides access to the current active browsers DOM for the currently visible page.
@@ -21,7 +21,6 @@ import org.jetbrains.k2js.config.EcmaVersion;
import org.jetbrains.k2js.facade.MainCallParameters; import org.jetbrains.k2js.facade.MainCallParameters;
import org.jetbrains.k2js.test.SingleFileTranslationTest; import org.jetbrains.k2js.test.SingleFileTranslationTest;
import java.io.File;
import java.util.Arrays; import java.util.Arrays;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.List; import java.util.List;
@@ -38,29 +37,16 @@ public final class StdLibTest extends SingleFileTranslationTest {
public void testDummy() { public void testDummy() {
} }
public void TODO_testBrowserDocumentAccess() throws Exception { public void testBrowserDocumentAccessCompiles() throws Exception {
runFunctionOutputTest("browserDocumentAccess.kt", "test.browser", "foo", "Hello World!"); generateJavaScriptFiles("browserDocumentAccess.kt", MainCallParameters.noCall(), EcmaVersion.all());
} }
@Override @Override
protected void generateJavaScriptFiles(@NotNull String kotlinFilename, protected void generateJavaScriptFiles(@NotNull String kotlinFilename,
@NotNull MainCallParameters mainCallParameters, @NotNull MainCallParameters mainCallParameters,
@NotNull EnumSet<EcmaVersion> ecmaVersions) throws Exception { @NotNull EnumSet<EcmaVersion> ecmaVersions) throws Exception {
List<String> files = Arrays.asList(getInputFilePath(kotlinFilename));
String stdlibdir = pathToTestFiles() + "../../../../libraries/stdlib/src/";
String jscoredir = pathToTestFiles() + "../../../js.libraries/src/core/";
String dom = jscoredir + "dom.kt";
String jsbrowser = jscoredir + "../stdlib/browser.kt";
String stdlibBrowser = stdlibdir + "kotlin/browser/Properties.kt";
List<String> files = Arrays.asList(getInputFilePath(kotlinFilename), dom, jsbrowser);
generateJavaScriptFiles(files, kotlinFilename, mainCallParameters, ecmaVersions); generateJavaScriptFiles(files, kotlinFilename, mainCallParameters, ecmaVersions);
} }
@Override
protected boolean shouldCreateOut() {
return false;
}
} }
@@ -65,7 +65,9 @@ public abstract class Config {
"/html5/canvas.kt", "/html5/canvas.kt",
"/html5/files.kt", "/html5/files.kt",
"/html5/image.kt", "/html5/image.kt",
"/stdlib/JUMaps.kt" "/stdlib/JUMaps.kt",
"/stdlib/browser.kt",
"/core/dom.kt"
); );
protected static final String LIBRARIES_LOCATION = "js/js.libraries/src"; protected static final String LIBRARIES_LOCATION = "js/js.libraries/src";