KT-3008 Merge JS runtime modules in one kotlin.js

This commit is contained in:
Alexey Andreev
2016-04-12 16:30:40 +03:00
parent b556b6efca
commit 0cfacfa44a
25 changed files with 119 additions and 113 deletions
@@ -58,7 +58,7 @@ public class RhinoFunctionResultChecker implements RhinoResultChecker {
protected String functionCallString() {
StringBuilder sb = new StringBuilder();
if (packageName != null) {
sb.append("Kotlin.modules");
sb.append("this");
if (moduleId.contains(".")) {
sb.append("['").append(moduleId).append("']");
} else {
@@ -141,7 +141,7 @@ public final class RhinoUtils {
ScriptableObject scope = getScope(ecmaVersion, context, jsLibraries);
putGlobalVariablesIntoScope(scope, variables);
context.evaluateString(scope, "Kotlin.out = new Kotlin.BufferedOutput();", "setup Kotlin.out", 0, null);
context.evaluateString(scope, "kotlin.out = new kotlin.BufferedOutput();", "setup Kotlin.out", 0, null);
for (String filename : fileNames) {
runFileWithRhino(filename, context, scope);
@@ -172,20 +172,6 @@ public final class RhinoUtils {
parentScope = initScope(version, context, jsLibraries);
versionToScope.put(version, parentScope);
}
else {
NativeObject kotlin = (NativeObject) parentScope.get("Kotlin");
assert kotlin != null;
NativeObject modules = (NativeObject) kotlin.get("modules");
assert modules != null;
NativeObject stdlibModule = (NativeObject) modules.get(STDLIB_JS_MODULE_NAME);
NativeObject builtinsModule = (NativeObject) modules.get(BUILTINS_JS_MODULE_NAME);
NativeObject newModules = new NativeObject();
newModules.put(STDLIB_JS_MODULE_NAME, newModules, stdlibModule);
newModules.put(BUILTINS_JS_MODULE_NAME, newModules, builtinsModule);
kotlin.put("modules", kotlin, newModules);
}
return parentScope;
}
@@ -193,13 +179,7 @@ public final class RhinoUtils {
private static ScriptableObject initScope(@NotNull EcmaVersion version, @NotNull Context context, @NotNull List<String> jsLibraries) {
ScriptableObject scope = context.initStandardObjects();
try {
context.evaluateString(scope, "var Kotlin = {};", ".", 1, null);
runFileWithRhino(getKotlinLibFile(version), context, scope);
runFileWithRhino(TEST_DATA_DIR_PATH + "kotlin_lib.js", context, scope);
runFileWithRhino(TEST_DATA_DIR_PATH + "maps.js", context, scope);
runFileWithRhino(TEST_DATA_DIR_PATH + "long.js", context, scope);
runFileWithRhino(DIST_DIR_JS_PATH + BUILTINS_JS_FILE_NAME, context, scope);
runFileWithRhino(DIST_DIR_JS_PATH + STDLIB_JS_FILE_NAME, context, scope);
runFileWithRhino(DIST_DIR_JS_PATH + "kotlin.js", context, scope);
//runFileWithRhino(pathToTestFilesRoot() + "jshint.js", context, scope);
for (String jsLibrary : jsLibraries) {
runFileWithRhino(jsLibrary, context, scope);
@@ -43,8 +43,8 @@ import static org.jetbrains.kotlin.js.translate.utils.ExpandIsCallsKt.expandIsCa
*/
public final class K2JSTranslator {
public static final String FLUSH_SYSTEM_OUT = "Kotlin.out.flush();\n";
public static final String GET_SYSTEM_OUT = "Kotlin.out.buffer;\n";
public static final String FLUSH_SYSTEM_OUT = "kotlin.out.flush();\n";
public static final String GET_SYSTEM_OUT = "kotlin.out.buffer;\n";
@NotNull
private final JsConfig config;
@@ -112,7 +112,9 @@ public final class StandardClasses {
standardClasses.declare().forFQ("kotlin.Comparable").kotlinClass("Comparable");
standardClasses.declare().forFQ("koltin.Throwable").kotlinClass("Throwable");
standardClasses.declare().forFQ("kotlin.Throwable").kotlinClass("Throwable");
standardClasses.declare().forFQ("kotlin.Annotation").kotlinClass("Annotation");
}
@@ -545,13 +545,6 @@ public final class StaticContext {
JsNameRef result = getQualifierForParentPackage(((PackageFragmentDescriptor) containingDescriptor).getFqName());
// TODO: remove this dirty hack
if (descriptor instanceof ClassDescriptor && DescriptorUtils.isTopLevelDeclaration(descriptor)) {
if (DescriptorUtils.getFqNameFromTopLevelClass(descriptor).toString().equals("Annotation")) {
return result;
}
}
String moduleName = getExternalModuleName(descriptor);
if (moduleName == null) {
return result;
@@ -561,7 +554,8 @@ public final class StaticContext {
return null;
}
JsName moduleId = importedModules.get(moduleName);
JsName moduleId = moduleName.equals(Namer.KOTLIN_LOWER_NAME) ? rootScope.declareName(Namer.KOTLIN_NAME) :
importedModules.get(moduleName);
if (moduleId == null) {
moduleId = rootScope.declareFreshName(Namer.LOCAL_MODULE_PREFIX + Namer.suggestedModuleName(moduleName));
importedModules.put(moduleName, moduleId);
@@ -289,7 +289,7 @@ public final class Translation {
JsBlock amdBody = new JsBlock(wrapAmd(moduleId, factoryName.makeRef(), importedModules, program));
JsBlock commonJsBody = new JsBlock(wrapCommonJs(factoryName.makeRef(), importedModules, program));
JsInvocation plainInvocation = makePlainInvocation(factoryName.makeRef(), importedModules);
JsInvocation plainInvocation = makePlainInvocation(factoryName.makeRef(), importedModules, program);
JsExpression plainExpr = moduleId != null ?
JsAstUtils.assignment(new JsNameRef(moduleId, rootName.makeRef()), plainInvocation) :
plainInvocation;
@@ -356,7 +356,7 @@ public final class Translation {
@NotNull List<ImportedModule> importedModules,
@NotNull JsProgram program
) {
JsInvocation invocation = makePlainInvocation(function, importedModules);
JsInvocation invocation = makePlainInvocation(function, importedModules, program);
JsStatement statement;
if (moduleId == null) {
@@ -370,11 +370,12 @@ public final class Translation {
}
@NotNull
private static JsInvocation makePlainInvocation(@NotNull JsExpression function, @NotNull List<ImportedModule> importedModules) {
private static JsInvocation makePlainInvocation(@NotNull JsExpression function, @NotNull List<ImportedModule> importedModules,
JsProgram program) {
List<JsExpression> invocationArgs = new ArrayList<JsExpression>(importedModules.size());
for (ImportedModule importedModule : importedModules) {
invocationArgs.add(importedModule.name.makeRef());
invocationArgs.add(program.getRootScope().declareName(importedModule.id).makeRef());
}
return new JsInvocation(function, invocationArgs);
@@ -23,17 +23,16 @@ import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.js.config.LibrarySourcesConfig
import org.jetbrains.kotlin.js.resolve.JsPlatform
import org.jetbrains.kotlin.js.translate.context.Namer
import org.jetbrains.kotlin.js.translate.context.TranslationContext
import org.jetbrains.kotlin.js.translate.utils.JsAstUtils
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name
class DefaultClassObjectIntrinsic(val fqName: FqName, val moduleName: String): ObjectIntrinsic {
class DefaultClassObjectIntrinsic(val fqName: FqName): ObjectIntrinsic {
override fun apply(context: TranslationContext): JsExpression {
val nameRef = context.getQualifiedReference(fqName)
return JsAstUtils.replaceRootReference(
nameRef,
JsArrayAccess(context.namer().kotlin("modules"), context.program().getStringLiteral(moduleName)))
return JsAstUtils.replaceRootReference(nameRef, Namer.kotlinObject())
}
}
@@ -46,7 +45,7 @@ class ObjectIntrinsics {
val containingDeclaration = classDescriptor.containingDeclaration
val name = Name.identifier(containingDeclaration.name.asString() + "CompanionObject")
return DefaultClassObjectIntrinsic(FqName("kotlin.js.internal").child(name), LibrarySourcesConfig.STDLIB_JS_MODULE_NAME)
return DefaultClassObjectIntrinsic(FqName("kotlin.js.internal").child(name));
}
}
@@ -25,6 +25,7 @@ import org.jetbrains.kotlin.builtins.KotlinBuiltIns;
import org.jetbrains.kotlin.descriptors.*;
import org.jetbrains.kotlin.js.config.LibrarySourcesConfig;
import org.jetbrains.kotlin.js.descriptorUtils.DescriptorUtilsKt;
import org.jetbrains.kotlin.js.translate.context.Namer;
import org.jetbrains.kotlin.js.translate.context.TranslationContext;
import org.jetbrains.kotlin.name.Name;
import org.jetbrains.kotlin.psi.KtExpression;
@@ -38,7 +39,6 @@ import java.util.Collection;
import java.util.List;
import java.util.Set;
import static org.jetbrains.kotlin.js.config.LibrarySourcesConfig.BUILTINS_JS_MODULE_NAME;
import static org.jetbrains.kotlin.js.translate.utils.AnnotationsUtils.isNativeObject;
import static org.jetbrains.kotlin.resolve.DescriptorToSourceUtils.descriptorToDeclaration;
import static org.jetbrains.kotlin.resolve.DescriptorUtils.*;
@@ -185,7 +185,7 @@ public final class JsDescriptorUtils {
@Nullable
public static String getExternalModuleName(@NotNull DeclarationDescriptor descriptor) {
if (isBuiltin(descriptor)) return BUILTINS_JS_MODULE_NAME;
if (isBuiltin(descriptor)) return Namer.KOTLIN_LOWER_NAME;
PsiElement element = descriptorToDeclaration(descriptor);
if (element == null && descriptor instanceof PropertyAccessorDescriptor) {
+9 -3
View File
@@ -1,13 +1,19 @@
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define('Kotlin', [], factory);
define('kotlin', [], factory);
} else if (typeof exports === 'object') {
module.exports = factory();
} else {
root.Kotlin = factory();
root.kotlin = factory();
}
}(this, function () {
var Kotlin = {};
var kotlin = Kotlin;
function require() {
return Kotlin;
}
var module = {};
%output%
return Kotlin;
Kotlin.modules.kotlin = mergedRoot;
return mergedRoot;
}));
+1 -1
View File
@@ -32,7 +32,7 @@ var JsTests = (function () {
var init = function () {
init = function() {};
Kotlin.modules["JS_TESTS"].kotlin.test.init();
kotlin.modules.JS_TESTS.kotlin.test.init();
};
var test = function (testName, testFun) {
+18 -14
View File
@@ -274,7 +274,7 @@
*/
lazyInitClasses.ArrayIterator = Kotlin.createClass(
function () {
return [Kotlin.modules['builtins'].kotlin.collections.MutableIterator];
return [Kotlin.kotlin.collections.MutableIterator];
},
/** @constructs */
function (array) {
@@ -306,7 +306,7 @@
*/
lazyInitClasses.ListIterator = Kotlin.createClass(
function () {
return [Kotlin.modules['builtins'].kotlin.collections.ListIterator]; // TODO: MutableListIterator
return [Kotlin.kotlin.collections.ListIterator]; // TODO: MutableListIterator
},
/** @constructs */
function (list, index) {
@@ -340,6 +340,8 @@
}
});
Kotlin.Annotation = Kotlin.createTraitNow(null);
Kotlin.Enum = Kotlin.createClassNow(null,
function () {
this.name$ = void 0;
@@ -380,7 +382,7 @@
lazyInitClasses.AbstractCollection = Kotlin.createClass(
function () {
return [Kotlin.modules['builtins'].kotlin.collections.MutableCollection];
return [Kotlin.kotlin.collections.MutableCollection];
}, null, {
addAll_wtfk93$: function (collection) {
var modified = false;
@@ -474,7 +476,7 @@
*/
lazyInitClasses.AbstractList = Kotlin.createClass(
function () {
return [Kotlin.modules['builtins'].kotlin.collections.MutableList, Kotlin.AbstractCollection];
return [Kotlin.kotlin.collections.MutableList, Kotlin.AbstractCollection];
}, null, {
iterator: function () {
return new Kotlin.ListIterator(this);
@@ -792,7 +794,7 @@
lazyInitClasses.RangeIterator = Kotlin.createClass(
function () {
return [Kotlin.modules['builtins'].kotlin.collections.Iterator];
return [Kotlin.kotlin.collections.Iterator];
},
function (start, end, step) {
this.start = start;
@@ -878,7 +880,7 @@
lazyInitClasses.NumberProgression = Kotlin.createClass(
function () {
return [Kotlin.modules['builtins'].kotlin.collections.Iterable];
return [Kotlin.kotlin.collections.Iterable];
},
function (start, end, step) {
this.first = start;
@@ -904,7 +906,7 @@
lazyInitClasses.NumberRange = Kotlin.createClass(
function() {
return [Kotlin.modules['builtins'].kotlin.ranges.ClosedRange, Kotlin.NumberProgression]
return [Kotlin.kotlin.ranges.ClosedRange, Kotlin.NumberProgression]
},
function $fun(start, endInclusive) {
$fun.baseInitializer.call(this, start, endInclusive, 1);
@@ -934,7 +936,7 @@
lazyInitClasses.LongRangeIterator = Kotlin.createClass(
function () {
return [Kotlin.modules['builtins'].kotlin.collections.Iterator];
return [Kotlin.kotlin.collections.Iterator];
},
function (start, end, step) {
this.start = start;
@@ -957,7 +959,7 @@
lazyInitClasses.LongProgression = Kotlin.createClass(
function () {
return [Kotlin.modules['builtins'].kotlin.collections.Iterable];
return [Kotlin.kotlin.collections.Iterable];
},
function (start, end, step) {
this.first = start;
@@ -983,7 +985,7 @@
lazyInitClasses.LongRange = Kotlin.createClass(
function () {
return [Kotlin.modules['builtins'].kotlin.ranges.ClosedRange, Kotlin.LongProgression];
return [Kotlin.kotlin.ranges.ClosedRange, Kotlin.LongProgression];
},
function $fun(start, endInclusive) {
$fun.baseInitializer.call(this, start, endInclusive, Kotlin.Long.ONE);
@@ -1027,7 +1029,7 @@
lazyInitClasses.CharProgression = Kotlin.createClassNow(
function () {
return [Kotlin.modules['builtins'].kotlin.collections.Iterable];
return [Kotlin.kotlin.collections.Iterable];
},
function (start, end, step) {
this.first = start;
@@ -1056,7 +1058,7 @@
lazyInitClasses.CharRange = Kotlin.createClass(
function() {
return [Kotlin.modules['builtins'].kotlin.ranges.ClosedRange, Kotlin.CharProgression]
return [Kotlin.kotlin.ranges.ClosedRange, Kotlin.CharProgression]
},
function $fun(start, endInclusive) {
$fun.baseInitializer.call(this, start, endInclusive, 1);
@@ -1238,6 +1240,8 @@
}
return obj1;
};
Kotlin.createDefinition(lazyInitClasses, Kotlin);
Kotlin.lazyInitClasses = Kotlin.lazyInitClasses || [];
Kotlin.lazyInitClasses.push(lazyInitClasses);
})(Kotlin);
+12 -11
View File
@@ -186,7 +186,8 @@
//noinspection JSUnfilteredForInLoop
Object.defineProperty(constructor, innerTypeName, {
get: innerType,
configurable: true
configurable: true,
enumerable: true
});
}
}
@@ -225,7 +226,7 @@
Kotlin.createClass = function (basesFun, constructor, properties, staticProperties) {
function $o() {
var klass = Kotlin.createClassNow(getBases(basesFun), constructor, properties, staticProperties);
Object.defineProperty(this, $o.className, {value: klass});
Object.defineProperty(this, $o.className, {value: klass, enumerable: true});
if (staticProperties && staticProperties.object_initializer$) {
staticProperties.object_initializer$(klass);
}
@@ -301,7 +302,7 @@
Kotlin.createTrait = function (basesFun, properties, staticProperties) {
function $o() {
var klass = Kotlin.createTraitNow(getBases(basesFun), properties, staticProperties);
Object.defineProperty(this, $o.className, {value: klass});
Object.defineProperty(this, $o.className, {value: klass, enumerable: true});
return klass;
}
@@ -324,7 +325,7 @@
var obj = new klass();
var metadata = klass.$metadata$;
metadata.type = Kotlin.TYPE.OBJECT;
Object.defineProperty(this, $o.className, {value: obj});
Object.defineProperty(this, $o.className, {value: obj, enumerable: true});
defineNestedTypes(obj, klass.$metadata$.types);
copyProperties(obj, metadata.staticMembers);
if (metadata.baseClass != null) {
@@ -511,7 +512,8 @@
members[p].className = p;
Object.defineProperty(definition, p, {
get: members[p],
configurable: true
configurable: true,
enumerable: true
});
}
else {
@@ -536,11 +538,11 @@
Kotlin.definePackage = function (initializer, members) {
var definition = createDefinition(members);
if (initializer === null) {
return {value: definition};
return {value: definition, enumerable: true};
}
else {
var getter = createPackageGetter(definition, initializer);
return {get: getter};
return {get: getter, enumerable: true};
}
};
@@ -561,11 +563,10 @@
* @param {Object} declaration
*/
Kotlin.defineModule = function (id, declaration) {
if (id in Kotlin.modules) {
throw new Error("Module " + id + " is already defined");
if (typeof declaration.$initializer$ === "function") {
declaration.$initializer$.call(declaration); // TODO: temporary hack
}
declaration.$initializer$.call(declaration); // TODO: temporary hack
Object.defineProperty(Kotlin.modules, id, {value: declaration});
Kotlin.modules[id] = declaration;
};
Kotlin.defineInlineFunction = function(tag, fun) {
+7 -8
View File
@@ -14,8 +14,6 @@
* limitations under the License.
*/
var Kotlin = Kotlin || {};
(function (Kotlin) {
"use strict";
@@ -523,7 +521,7 @@ var Kotlin = Kotlin || {};
lazyInitClasses.HashMap = Kotlin.createClass(
function () {
return [Kotlin.HashTable, Kotlin.modules['builtins'].kotlin.collections.MutableMap];
return [Kotlin.HashTable, Kotlin.kotlin.collections.MutableMap];
},
function () {
Kotlin.HashTable.call(this);
@@ -543,7 +541,7 @@ var Kotlin = Kotlin || {};
*/
lazyInitClasses.PrimitiveHashMapValuesIterator = Kotlin.createClass(
function () {
return [Kotlin.modules['builtins'].kotlin.collections.Iterator];
return [Kotlin.kotlin.collections.Iterator];
},
function (map, keys) {
this.map = map;
@@ -828,7 +826,7 @@ var Kotlin = Kotlin || {};
lazyInitClasses.LinkedHashSet = Kotlin.createClass(
function () {
return [Kotlin.modules['builtins'].kotlin.collections.MutableSet, Kotlin.HashSet];
return [Kotlin.kotlin.collections.MutableSet, Kotlin.HashSet];
},
/** @constructs */
function () {
@@ -870,7 +868,7 @@ var Kotlin = Kotlin || {};
*/
lazyInitClasses.SetIterator = Kotlin.createClass(
function () {
return [Kotlin.modules['builtins'].kotlin.collections.MutableIterator];
return [Kotlin.kotlin.collections.MutableIterator];
},
function (set) {
this.set = set;
@@ -1117,7 +1115,7 @@ var Kotlin = Kotlin || {};
lazyInitClasses.HashSet = Kotlin.createClass(
function () {
return [Kotlin.modules['builtins'].kotlin.collections.MutableSet, Kotlin.AbstractCollection];
return [Kotlin.kotlin.collections.MutableSet, Kotlin.AbstractCollection];
},
function () {
HashSet.call(this);
@@ -1126,5 +1124,6 @@ var Kotlin = Kotlin || {};
Object.defineProperty(Kotlin, "ComplexHashSet", { get : function () { return Kotlin.HashSet; }});
Kotlin.createDefinition(lazyInitClasses, Kotlin);
Kotlin.lazyInitClasses = Kotlin.lazyInitClasses || [];
Kotlin.lazyInitClasses.push(lazyInitClasses);
}(Kotlin));
+9
View File
@@ -0,0 +1,9 @@
var mergedRoot = Kotlin;
for (var propertyName in stdlib) {
Kotlin[propertyName] = stdlib[propertyName];
}
(function () {
for (var i = 0; i < Kotlin.lazyInitClasses.length; ++i) {
Kotlin.createDefinition(Kotlin.lazyInitClasses[i], mergedRoot);
}
})();
+1 -1
View File
@@ -9,7 +9,7 @@ fun box(): String {
assertEquals(5, eval("3 + 2"))
val PACKAGE = "Kotlin.modules.JS_TESTS.foo"
val PACKAGE = "kotlin.modules.JS_TESTS.foo"
assertEquals(top, eval("$PACKAGE.top"))
return "OK"
@@ -1,6 +1,6 @@
package foo
internal val PACKAGE = "Kotlin.modules.JS_TESTS.foo"
internal val PACKAGE = "kotlin.modules.JS_TESTS.foo"
internal fun funToString(name: String) = eval("$PACKAGE.$name.toString()") as String
+6 -6
View File
@@ -23,7 +23,7 @@ var buffer: String = noImpl
fun test(expected: String, initCode: String, getResult: () -> String) {
buffer = ""
eval("Kotlin.out = new $initCode")
eval("kotlin.out = new $initCode")
print("Hello")
print(", World")
@@ -40,19 +40,19 @@ fun test(expected: String, initCode: String, getResult: () -> String) {
}
fun box(): String {
test(EXPECTED, "Kotlin.NodeJsOutput(outputStream)") {
test(EXPECTED, "kotlin.NodeJsOutput(outputStream)") {
buffer
}
test(EXPECTED_NEWLINE_FOR_EACH, "Kotlin.OutputToConsoleLog()") {
test(EXPECTED_NEWLINE_FOR_EACH, "kotlin.OutputToConsoleLog()") {
buffer
}
test(EXPECTED, "Kotlin.BufferedOutput()") {
eval("Kotlin.out.buffer") as String
test(EXPECTED, "kotlin.BufferedOutput()") {
eval("kotlin.out.buffer") as String
}
test(EXPECTED, "Kotlin.BufferedOutputToConsoleLog()") {
test(EXPECTED, "kotlin.BufferedOutputToConsoleLog()") {
buffer
}
+2 -2
View File
@@ -1,7 +1,7 @@
(function () {
var c = 0;
Kotlin.A = Kotlin.createClassNow(null,
kotlin.A = kotlin.createClassNow(null,
function () {
this.f = function (i) {
if (i === undefined && c === 0) {
@@ -13,7 +13,7 @@
}
}
);
Kotlin.getResult = function () {
kotlin.getResult = function () {
return c === 2;
};
})();
@@ -1,6 +1,6 @@
package foo
val PACKAGE = "Kotlin.modules.JS_TESTS.foo"
val PACKAGE = "kotlin.modules.JS_TESTS.foo"
class A
@native val Any.__proto__: String get() = noImpl
+2
View File
@@ -0,0 +1,2 @@
var builtins = module.exports;
delete Kotlin.modules.kotlin;
+2
View File
@@ -0,0 +1,2 @@
var stdlib = module.exports;
delete Kotlin.modules.kotlin;
@@ -15,7 +15,7 @@ fun box(): String {
test("byteArrayOf", byteArrayOf(0, 1, 2, 3, 4), "0, 1, 2, 3, 4")
test("shortArrayOf", shortArrayOf(0, 1, 2, 3, 4), "0, 1, 2, 3, 4")
test("intArray,", intArrayOf(0, 1, 2, 3, 4), "0, 1, 2, 3, 4")
test("longArrayOf", longArrayOf(0, 1, 2, 3, 4), "Kotlin.Long.fromInt(0), Kotlin.Long.fromInt(1), Kotlin.Long.fromInt(2), Kotlin.Long.fromInt(3), Kotlin.Long.fromInt(4)")
test("longArrayOf", longArrayOf(0, 1, 2, 3, 4), "kotlin.Long.fromInt(0), kotlin.Long.fromInt(1), kotlin.Long.fromInt(2), kotlin.Long.fromInt(3), kotlin.Long.fromInt(4)")
test("floatArrayOf", floatArrayOf(0.0f, 1.0f, 2.0f, 3.0f, 4.0f), "0.0, 1.0, 2.0, 3.0, 4.0")
test("doubleArrayOf", doubleArrayOf(0.0, 1.1, 2.2, 3.3, 4.4), "0.0, 1.1, 2.2, 3.3, 4.4")
}
+3 -5
View File
@@ -1,13 +1,11 @@
<!-- for debugging tests in browser -->
<html>
<head>
<script type="application/javascript" src="kotlin_lib_ecma5.js"></script>
<script type="application/javascript" src="kotlin_lib.js"></script>
<script type="application/javascript" src="webDemoExamples2/out/life_v5.js"></script>
<script type="application/javascript" src="../../../dist/js/kotlin.js"></script>
<script type="application/javascript" src="native/out/eval_v5.js"></script>
<script type="application/javascript">
console.log(Kotlin.modules.JS_TESTS.foo.box());
console.log(JS_TESTS.foo.box());
</script>
</head>
<body>
@@ -25,7 +25,7 @@ fun box(): String {
if (!hasProp(b, "foo")) return "B hasn't foo"
if (!hasProp(b, "boo")) return "B hasn't boo"
val PREFIX = "Kotlin.modules.JS_TESTS.foo"
val PREFIX = "kotlin.modules.JS_TESTS.foo"
if (eval("$PREFIX.A") == null) return "$PREFIX.A not found"
if (eval("$PREFIX.B") == null) return "$PREFIX.B not found"
if (eval("$PREFIX.A === $PREFIX.B") as Boolean) return "A and B refer to the same object"