JS backend: dropped unnecessary tests which checked implementation details of kotlin js runtime.
This commit is contained in:
@@ -1,76 +0,0 @@
|
||||
/*
|
||||
* 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.semantics;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.k2js.config.EcmaVersion;
|
||||
import org.jetbrains.k2js.test.SingleFileTranslationTest;
|
||||
import org.jetbrains.k2js.test.rhino.RhinoFunctionResultChecker;
|
||||
|
||||
import static org.jetbrains.k2js.test.rhino.RhinoUtils.runRhinoTest;
|
||||
|
||||
public final class KotlinLibTest extends SingleFileTranslationTest {
|
||||
|
||||
public KotlinLibTest() {
|
||||
super("kotlinLib/");
|
||||
}
|
||||
|
||||
public void testPackageHasDeclaredFunction() throws Exception {
|
||||
runJavascriptTest("package.js");
|
||||
}
|
||||
|
||||
|
||||
public void testPackageHasDeclaredClasses() throws Exception {
|
||||
runJavascriptTest("packageWithClasses.js");
|
||||
}
|
||||
|
||||
|
||||
public void testIsSameType() throws Exception {
|
||||
runJavascriptTest("isSameType.js");
|
||||
}
|
||||
|
||||
|
||||
public void testIsAncestorType() throws Exception {
|
||||
runJavascriptTest("isAncestorType.js");
|
||||
}
|
||||
|
||||
|
||||
public void testIsComplexTest() throws Exception {
|
||||
runJavascriptTest("isComplexTest.js");
|
||||
}
|
||||
|
||||
public void testArray() throws Exception {
|
||||
runJavascriptTest("array.js");
|
||||
}
|
||||
|
||||
|
||||
public void testHashMap() throws Exception {
|
||||
runJavascriptTest("hashMap.js");
|
||||
}
|
||||
|
||||
|
||||
private void runJavascriptTest(@NotNull String filename) throws Exception {
|
||||
runRhinoTest(withAdditionalFiles(cases(filename), EcmaVersion.defaultVersion()),
|
||||
new RhinoFunctionResultChecker("test", true));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean shouldCreateOut() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
function test() {
|
||||
var a = Kotlin.arrayFromFun(3, function () {
|
||||
return 3
|
||||
});
|
||||
return (a[0] == 3) && (a[2] == 3) && (a[1] == 3);
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
var map = new Kotlin.HashMap();
|
||||
|
||||
map.put_5yfy9u$(3, 4);
|
||||
map.put_5yfy9u$(6, 3);
|
||||
|
||||
function test() {
|
||||
if (map.containsKey(4) || map.containsKey(5)) return false;
|
||||
if (map.containsKey({}) || map.containsKey(11)) return false;
|
||||
if (!map.containsKey(3) || !map.containsKey(6)) return false;
|
||||
var obj = map.get(3);
|
||||
if (obj !== 4) return false;
|
||||
obj = map.get(6);
|
||||
if (obj !== 3) return false;
|
||||
if (map.size() !== 2) return false;
|
||||
map.put_5yfy9u$(2, 3);
|
||||
if (map.size() !== 3) return false;
|
||||
if (!map.containsKey(2) || !map.containsKey(3) || !map.containsKey(6)) return false;
|
||||
if (!map.containsValue(4) || !map.containsValue(3)) return false;
|
||||
map.put_5yfy9u$(2, 1000);
|
||||
if (map.size() !== 3) return false;
|
||||
if (map.get(2)!== 1000) return false;
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
var A = Kotlin.createClassNow();
|
||||
var B = Kotlin.createClassNow(A);
|
||||
var b = new B;
|
||||
|
||||
function test() {
|
||||
return (Kotlin.isType(b, A) && Kotlin.isType(b, B));
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
var A = Kotlin.createClassNow();
|
||||
var B = Kotlin.createClassNow(A);
|
||||
var b = new B;
|
||||
var C = Kotlin.createClassNow(B);
|
||||
var c = new C;
|
||||
var E = Kotlin.createClassNow(A);
|
||||
var e = new E;
|
||||
|
||||
var test1 = function() {
|
||||
var b2 = b;
|
||||
return (Kotlin.isType(b, A) && Kotlin.isType(b, B));
|
||||
};
|
||||
|
||||
var test2 = function() {
|
||||
return (Kotlin.isType(c, C) && Kotlin.isType(c, B) && Kotlin.isType(c, A) && (!Kotlin.isType(c, E)));
|
||||
};
|
||||
|
||||
var test3 = function() {
|
||||
return Kotlin.isType(e, E) && !Kotlin.isType(e, B) && !Kotlin.isType(e, C) && Kotlin.isType(e, A)
|
||||
};
|
||||
|
||||
var test = function() {
|
||||
return test1() && test2() && test3()
|
||||
};
|
||||
@@ -1,24 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
var A = Kotlin.createClassNow();
|
||||
var B = Kotlin.createClassNow(A);
|
||||
var C = Kotlin.createClassNow();
|
||||
var c = new C;
|
||||
|
||||
test = function() {
|
||||
return ((!Kotlin.isType(c, A)) && !Kotlin.isType(c, B));
|
||||
};
|
||||
@@ -1,22 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
var A = Kotlin.createClassNow();
|
||||
var a = new A();
|
||||
|
||||
function test() {
|
||||
return Kotlin.isType(a, A);
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
var foo = Kotlin.defineRootPackage(null, {
|
||||
box: function () {
|
||||
return !false;
|
||||
}
|
||||
});
|
||||
|
||||
function test() {
|
||||
return foo.box()
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
{
|
||||
var items = function () {
|
||||
var A = Kotlin.createClassNow(null,
|
||||
function $fun() {
|
||||
this.$order = '';
|
||||
{
|
||||
this.set_order(this.get_order() + 'A');
|
||||
}
|
||||
},
|
||||
{
|
||||
set_order: function (tmp$0) {
|
||||
this.$order = tmp$0;
|
||||
},
|
||||
get_order: function () {
|
||||
return this.$order;
|
||||
}
|
||||
});
|
||||
var B = Kotlin.createClassNow(A, function $fun() {
|
||||
$fun.baseInitializer.call(this);
|
||||
{
|
||||
this.set_order(this.get_order() + 'B');
|
||||
}
|
||||
});
|
||||
var C = Kotlin.createClassNow(B, function $fun() {
|
||||
$fun.baseInitializer.call(this);
|
||||
{
|
||||
this.set_order(this.get_order() + 'C');
|
||||
}
|
||||
});
|
||||
return {A: A, B: B, C: C};
|
||||
}();
|
||||
|
||||
items.box = function () {
|
||||
return (new foo.C).get_order() === 'ABC' && (new foo.B).get_order() === 'AB' && (new foo.A).get_order() === 'A';
|
||||
};
|
||||
|
||||
var foo = Kotlin.defineRootPackage(null, items);
|
||||
}
|
||||
|
||||
function test() {
|
||||
return foo.box()
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
foo = {};
|
||||
(function(foo){
|
||||
foo.Test = Kotlin.createTrait({addFoo:function(s){
|
||||
return s + 'FOO';
|
||||
}
|
||||
});
|
||||
foo.ExtendedTest = Kotlin.createTrait(foo.Test, {hooray:function(){
|
||||
return 'hooray';
|
||||
}
|
||||
});
|
||||
}
|
||||
(foo));
|
||||
Reference in New Issue
Block a user