[K/JS] Optimize logical operators generating
This commit is contained in:
+2
-2
@@ -7,7 +7,7 @@ function box() {
|
||||
if (!(flag1 === 0)) {
|
||||
var tmp;
|
||||
var tmp_0;
|
||||
if (equals(OK, 'OK') ? flag1 === 1 : false) {
|
||||
if (equals(OK, 'OK') && flag1 === 1) {
|
||||
var tmp_1 = flag2;
|
||||
tmp_0 = typeof tmp_1 === 'number';
|
||||
} else {
|
||||
@@ -26,7 +26,7 @@ function box() {
|
||||
if (!(flag1 === 0)) {
|
||||
var tmp_2;
|
||||
var tmp_3;
|
||||
if (equals(OK, 'OK') ? flag1 === 1 : false) {
|
||||
if (equals(OK, 'OK') && flag1 === 1) {
|
||||
var tmp_4 = flag2;
|
||||
tmp_3 = typeof tmp_4 === 'number';
|
||||
} else {
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
function test() {
|
||||
return (!a || (b && c)) && foo() || bar();
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
val a = true
|
||||
val b = true
|
||||
val c = true
|
||||
|
||||
fun foo() = true
|
||||
fun bar() = true
|
||||
|
||||
// EXPECT_GENERATED_JS: function=test expect=logicalOperators.js
|
||||
fun test(): Boolean = (!a || (b && c)) && foo() || bar()
|
||||
|
||||
fun box(): String {
|
||||
return if (test()) "OK" else "FAILED"
|
||||
}
|
||||
Reference in New Issue
Block a user