Added tests and support for binary with type RHS expressions.
This commit is contained in:
@@ -394,4 +394,12 @@ public final class ExpressionVisitor extends TranslatorVisitor<JsNode> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@NotNull
|
||||||
|
public JsNode visitBinaryWithTypeRHSExpression(@NotNull JetBinaryExpressionWithTypeRHS expression,
|
||||||
|
@NotNull TranslationContext context) {
|
||||||
|
return Translation.translateExpression(expression.getLeft(), context);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,6 +44,11 @@ public final class OperatorTable {
|
|||||||
binaryOperatorsMap.put(JetTokens.ANDAND, JsBinaryOperator.AND);
|
binaryOperatorsMap.put(JetTokens.ANDAND, JsBinaryOperator.AND);
|
||||||
binaryOperatorsMap.put(JetTokens.EXCLEQ, JsBinaryOperator.NEQ);
|
binaryOperatorsMap.put(JetTokens.EXCLEQ, JsBinaryOperator.NEQ);
|
||||||
binaryOperatorsMap.put(JetTokens.PERC, JsBinaryOperator.MOD);
|
binaryOperatorsMap.put(JetTokens.PERC, JsBinaryOperator.MOD);
|
||||||
|
binaryOperatorsMap.put(JetTokens.PLUSEQ, JsBinaryOperator.ASG_ADD);
|
||||||
|
binaryOperatorsMap.put(JetTokens.MINUSEQ, JsBinaryOperator.ASG_SUB);
|
||||||
|
binaryOperatorsMap.put(JetTokens.DIVEQ, JsBinaryOperator.ASG_DIV);
|
||||||
|
binaryOperatorsMap.put(JetTokens.MULTEQ, JsBinaryOperator.ASG_MUL);
|
||||||
|
binaryOperatorsMap.put(JetTokens.PERCEQ, JsBinaryOperator.ASG_MOD);
|
||||||
}
|
}
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
|||||||
@@ -34,4 +34,14 @@ public final class PatternMatchingTest extends IncludeLibraryTest {
|
|||||||
testFooBoxIsTrue("whenValue.kt");
|
testFooBoxIsTrue("whenValue.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenNotValue() throws Exception {
|
||||||
|
testFooBoxIsTrue("whenNotValue.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenValueOrType() throws Exception {
|
||||||
|
testFooBoxIsTrue("whenValueOrType.kt");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
namespace foo
|
||||||
|
|
||||||
|
fun box() : Boolean {
|
||||||
|
var a = 4
|
||||||
|
when(a) {
|
||||||
|
!is 3 => a = 10;
|
||||||
|
!is 4 => a = 20;
|
||||||
|
}
|
||||||
|
return (a == 10)
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
namespace foo
|
||||||
|
|
||||||
|
class A() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class B() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box() : Boolean {
|
||||||
|
var c : Int = 0
|
||||||
|
var a = A() : Any?
|
||||||
|
var b = null : Any?
|
||||||
|
when(a) {
|
||||||
|
is null => c = 10;
|
||||||
|
is B => c = 10000
|
||||||
|
is A => c = 20;
|
||||||
|
}
|
||||||
|
when(b) {
|
||||||
|
is null => c += 5
|
||||||
|
is B => c += 100
|
||||||
|
}
|
||||||
|
return (c == 25)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user