JS backend: remove dangerous package, correct translation for call, assignments, binary operations, support try...catch as expression
#KT-5576 Fixed #KT-5594 Fixed #KT-3166 Fixed #KT-5545 Fixed #KT-5594 Fixed #KT-5258 Fixed JS backend: fix KT-4879: extra side effect when use when in default arguments #KT-4879 Fixed JS backend: improve and fix WhenTranslator, fix order of evaluation for condtitions, fix KT-5263 (JS: extra tmp when initialize val in when by expression with if) #KT-5263 Fixed
This commit is contained in:
@@ -1,54 +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.k2js.test.SingleFileTranslationTest;
|
||||
|
||||
public final class DangerousTest extends SingleFileTranslationTest {
|
||||
|
||||
public DangerousTest() {
|
||||
super("dangerous/");
|
||||
}
|
||||
|
||||
public void testIfAsFunArgument() throws Exception {
|
||||
fooBoxTest();
|
||||
}
|
||||
|
||||
public void testIfAsPlusArgument() throws Exception {
|
||||
fooBoxTest();
|
||||
}
|
||||
|
||||
public void testWhenAsMinusArgument() throws Exception {
|
||||
fooBoxTest();
|
||||
}
|
||||
|
||||
public void testEvaluationOrder() throws Exception {
|
||||
fooBoxTest();
|
||||
}
|
||||
|
||||
public void testDangerousInsideDangerous() throws Exception {
|
||||
fooBoxTest();
|
||||
}
|
||||
|
||||
public void test2dangerousInExpression() throws Exception {
|
||||
fooBoxTest();
|
||||
}
|
||||
|
||||
public void testDangerousInline() throws Exception {
|
||||
fooBoxTest();
|
||||
}
|
||||
}
|
||||
@@ -68,6 +68,7 @@ public class DefaultArgumentsTest extends SingleFileTranslationTest {
|
||||
checkFooBoxIsOk();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void testComplexExpressionAsDefaultArgument() throws Exception {
|
||||
checkFooBoxIsOk();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* Copyright 2010-2014 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;
|
||||
|
||||
public class EvaluationOrderTest extends AbstractExpressionTest {
|
||||
public EvaluationOrderTest() {
|
||||
super("evaluationOrder/");
|
||||
}
|
||||
|
||||
public void test2dangerousInExpression() throws Exception {
|
||||
fooBoxTest();
|
||||
}
|
||||
|
||||
public void testAndAndWithSideEffect() throws Exception {
|
||||
checkFooBoxIsOk();
|
||||
}
|
||||
|
||||
public void testOrOrWithSideEffect() throws Exception {
|
||||
checkFooBoxIsOk();
|
||||
}
|
||||
|
||||
public void testAssignToDotQualifiedWithSideEffect() throws Exception {
|
||||
checkFooBoxIsOk();
|
||||
}
|
||||
|
||||
public void testAssignToArrayElementWithSideEffect() throws Exception {
|
||||
checkFooBoxIsOk();
|
||||
}
|
||||
|
||||
public void testCallArgs() throws Exception {
|
||||
checkFooBoxIsOk();
|
||||
}
|
||||
|
||||
public void testCallVarargs() throws Exception {
|
||||
checkFooBoxIsOk();
|
||||
}
|
||||
|
||||
public void testCompareToIntrinsicWithSideEffect() throws Exception {
|
||||
checkFooBoxIsOk();
|
||||
}
|
||||
|
||||
public void testDangerousInsideDangerous() throws Exception {
|
||||
fooBoxTest();
|
||||
}
|
||||
|
||||
public void testDangerousInline() throws Exception {
|
||||
fooBoxTest();
|
||||
}
|
||||
|
||||
public void testElvisComplex() throws Exception {
|
||||
checkFooBoxIsOk();
|
||||
}
|
||||
|
||||
public void testEvaluationOrder1() throws Exception {
|
||||
fooBoxTest();
|
||||
}
|
||||
|
||||
public void testEqualsIntrinsicWithSideEffect() throws Exception {
|
||||
checkFooBoxIsOk();
|
||||
}
|
||||
|
||||
public void testEvaluationOrder2() throws Exception {
|
||||
checkFooBoxIsOk();
|
||||
}
|
||||
|
||||
public void testIfAsFunArgument() throws Exception {
|
||||
fooBoxTest();
|
||||
}
|
||||
|
||||
public void testIfAsPlusArgument() throws Exception {
|
||||
fooBoxTest();
|
||||
}
|
||||
|
||||
public void testIfWithComplex() throws Exception {
|
||||
checkFooBoxIsOk();
|
||||
}
|
||||
|
||||
public void testIntrinsicComplex() throws Exception {
|
||||
checkFooBoxIsOk();
|
||||
}
|
||||
|
||||
public void testWhenAsMinusArgument() throws Exception {
|
||||
fooBoxTest();
|
||||
}
|
||||
|
||||
public void testWhenWithComplexConditions() throws Exception {
|
||||
checkFooBoxIsOk();
|
||||
}
|
||||
}
|
||||
@@ -33,4 +33,8 @@ public final class ForeachTest extends AbstractExpressionTest {
|
||||
public void testLabeledFor() throws Exception {
|
||||
fooBoxTest();
|
||||
}
|
||||
|
||||
public void testForWithComplexOneStatement() throws Exception {
|
||||
checkFooBoxIsOk();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright 2010-2014 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.mozilla.javascript.JavaScriptException;
|
||||
|
||||
public class IfExpressionTest extends AbstractExpressionTest {
|
||||
|
||||
public IfExpressionTest() {
|
||||
super("if/");
|
||||
}
|
||||
|
||||
public void testIfElseAsExpressionWithThrow() throws Exception {
|
||||
try {
|
||||
fooBoxTest();
|
||||
fail();
|
||||
}
|
||||
catch (JavaScriptException e) {
|
||||
}
|
||||
}
|
||||
|
||||
public void testIfInsideLambda() throws Exception {
|
||||
checkFooBoxIsOk();
|
||||
}
|
||||
|
||||
public void testNestedIf() throws Exception {
|
||||
checkFooBoxIsOk();
|
||||
}
|
||||
}
|
||||
@@ -45,15 +45,6 @@ public final class MiscTest extends AbstractExpressionTest {
|
||||
runFunctionOutputTest("classWithoutPackage.kt", Namer.getRootPackageName(), TEST_FUNCTION, true);
|
||||
}
|
||||
|
||||
public void testIfElseAsExpressionWithThrow() throws Exception {
|
||||
try {
|
||||
fooBoxTest();
|
||||
fail();
|
||||
}
|
||||
catch (JavaScriptException e) {
|
||||
}
|
||||
}
|
||||
|
||||
public void testKt1052_2() throws Exception {
|
||||
checkFooBoxIsTrue("KT-1052-2.kt");
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright 2010-2014 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;
|
||||
|
||||
public class TryCatchTest extends AbstractExpressionTest {
|
||||
|
||||
public TryCatchTest() {
|
||||
super("try/");
|
||||
}
|
||||
|
||||
public void testTryCatchExpr() throws Exception {
|
||||
checkFooBoxIsOk();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright 2010-2014 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;
|
||||
|
||||
public class WhileTest extends AbstractExpressionTest {
|
||||
|
||||
public WhileTest() {
|
||||
super("while/");
|
||||
}
|
||||
|
||||
public void testWhileWithComplexOneStatement() throws Exception {
|
||||
checkFooBoxIsOk();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user