-
Notifications
You must be signed in to change notification settings - Fork 850
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement logical assigment operators
||=
and &&=
- Loading branch information
1 parent
650ec29
commit 75c8b71
Showing
8 changed files
with
169 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
tests/src/test/java/org/mozilla/javascript/tests/es6/LogicalOrAndAssignmentTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
package org.mozilla.javascript.tests.es6; | ||
|
||
import org.mozilla.javascript.Context; | ||
import org.mozilla.javascript.drivers.LanguageVersion; | ||
import org.mozilla.javascript.drivers.RhinoTest; | ||
import org.mozilla.javascript.drivers.ScriptTestsBase; | ||
|
||
@RhinoTest("testsrc/jstests/es6/logical-or-and-assignment.js") | ||
@LanguageVersion(Context.VERSION_ES6) | ||
public class LogicalOrAndAssignmentTest extends ScriptTestsBase {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
load('testsrc/assert.js'); | ||
|
||
(function basicTests() { | ||
var a = false; | ||
var b = true; | ||
a ||= b; | ||
assertTrue(a); | ||
|
||
var c = false; | ||
a &&= c; | ||
assertFalse(a); | ||
})(); | ||
|
||
(function shortCircuits() { | ||
var counter = 0; | ||
function incCounter() { ++ counter; return true; } | ||
|
||
var a = true; | ||
counter = 0; | ||
a ||= incCounter(); | ||
assertEquals(0, counter); | ||
|
||
a = false; | ||
counter = 0; | ||
a ||= incCounter(); | ||
assertEquals(1, counter); | ||
|
||
a = true; | ||
counter = 0; | ||
a &&= incCounter(); | ||
assertEquals(1, counter); | ||
|
||
a = false; | ||
counter = 0; | ||
a &&= incCounter(); | ||
assertEquals(0, counter); | ||
})(); | ||
|
||
"success"; |
Oops, something went wrong.