v8/test/mjsunit/harmony/logical-assignment.js
Gus Caplan b151d8db22 Implement logical assignment
https://tc39.es/proposal-logical-assignment/

Bug: v8:10372
Change-Id: I538d54af6b4b24d450d1398c74f76dd57fdb0147
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2158119
Reviewed-by: Shu-yu Guo <syg@chromium.org>
Reviewed-by: Marja Hölttä <marja@chromium.org>
Reviewed-by: Mythri Alle <mythria@chromium.org>
Commit-Queue: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67330}
2020-04-23 07:23:58 +00:00

43 lines
586 B
JavaScript

// Copyright 2020 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --harmony-logical-assignment
{
let x = null;
let y = 0;
x ??= y ||= 5;
assertEquals(x, 5);
assertEquals(y, 5);
}
{
let x = null;
let y = 4;
x ??= y ||= 5;
assertEquals(x, 4);
assertEquals(y, 4);
}
{
let x = 1;
let y = 0;
x &&= y ||= 5;
assertEquals(x, 5);
assertEquals(y, 5);
}
{
let x = 0;
let y = 0;
x &&= y ||= 5;
assertEquals(x, 0);
assertEquals(y, 0);
}