v8/test/debugger/debug/debug-evaluate-no-side-effect-ops.js
Adam Klein c9efff3fcd [bigint] Add bytecodes for unary-minus and bitwise-not
This continues to move the "desugaring" of unary operators further
down the pipeline, in this case into the bytecode handlers for new
bytecodes `Negate` and `BitwiseNot` and the corresponding TF code
in BytecodeGraphBuilder.

Bug: v8:6971
Tbr: yangguo@chromium.org
Change-Id: If6b5d6b239a09ef8b4dbde49321614503c0f5beb
Reviewed-on: https://chromium-review.googlesource.com/661146
Commit-Queue: Adam Klein <adamk@chromium.org>
Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
Reviewed-by: Georg Neis <neis@chromium.org>
Reviewed-by: Ross McIlroy <rmcilroy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47980}
2017-09-12 19:07:59 +00:00

98 lines
2.4 KiB
JavaScript

// Copyright 2017 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.
Debug = debug.Debug
var exception = null;
var date = new Date();
var T = true;
var F = false;
var one = 1;
var two = 2;
var string = "s";
var array = [1, 2, 3];
function max(...rest) {
return Math.max(...rest);
}
function def(a = 1) {
return a;
}
function d1([a, b = 'b']) {
return a + b;
}
function d2({ x: c, y, z = 'z' } = {x: 'x', y: 'y' }) {
return c + y + z;
}
function listener(event, exec_state, event_data, data) {
if (event != Debug.DebugEvent.Break) return;
try {
function success(expectation, source) {
var result = exec_state.frame(0).evaluate(source, true).value();
if (expectation !== undefined) assertEquals(expectation, result);
}
function fail(source) {
assertThrows(() => exec_state.frame(0).evaluate(source, true),
EvalError);
}
success(false, `Object == {}`);
success(false, `Object === {}`);
success(true, `Object != {}`);
success(true, `Object !== {}`);
success(true, `'s' == string`);
success(true, `'s' === string`);
success(true, `1 < Math.cos(0) * 2`);
success(false, `1 < string`);
success(true, `'a' < string`);
success("s", `string[0]`);
success(0, `[0][0]`);
success(1, `T^F`);
success(0, `T&F`);
success(1, `T|F`);
success(false, `T&&F`);
success(true, `T||F`);
success(false, `T?F:T`);
success(false, `!T`);
success(1, `+one`);
success(-1, `-one`);
success(-2, `~one`);
success(4, `one << two`);
success(1, `two >> one`);
success(1, `two >>> one`);
success(3, `two + one`);
success(2, `two * one`);
success(0.5, `one / two`);
success(0, `(one / two) | 0`);
success(1, `one ** two`);
success(NaN, `string * two`);
success("s2", `string + two`);
success("s2", `string + two`);
fail(`[...array]`);
success(3, `max(...array)`);
fail(`({[string]:1})`);
fail(`[a, b] = [1, 2]`);
success(2, `def(2)`);
success(1, `def()`);
fail(`d1(['a'])`); // Iterator.prototype.next performs stores.
success("XYz", `d2({x:'X', y:'Y'})`);
} catch (e) {
exception = e;
print(e, e.stack);
};
};
// Add the debug event listener.
Debug.setListener(listener);
function f() {
debugger;
};
f();
assertNull(exception);