Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(54)

Side by Side Diff: test/debugger/debug/debug-evaluate-no-side-effect-builtins.js

Issue 2634523002: [debugger] whitelist some builtins as side-effect free. (Closed)
Patch Set: fix Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/debug/debug-evaluate.cc ('k') | test/debugger/test-api.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Flags: --ignition --side-effect-free-debug-evaluate
6
7 Debug = debug.Debug
8
9 var exception = null;
10
11 function listener(event, exec_state, event_data, data) {
12 if (event != Debug.DebugEvent.Break) return;
13 try {
14 function success(expectation, source) {
15 assertEquals(expectation, exec_state.frame(0).evaluate(source).value());
16 }
17 function fail(source) {
18 assertThrows(() => exec_state.frame(0).evaluate(source), EvalError);
19 }
20
21 // Test Math functions.
22 for (f of Object.getOwnPropertyNames(Math)) {
23 if (typeof Math[f] === "function") {
24 var result = exec_state.frame(0).evaluate(
25 `Math.${f}(0.5, -0.5);`).value();
26 if (f != "random") assertEquals(Math[f](0.5, -0.5), result);
27 }
28 }
29
30 // Test Number functions.
31 for (f of Object.getOwnPropertyNames(Number)) {
32 if (typeof Number[f] === "function") {
33 success(Number[f](0.5), `Number.${f}(0.5);`);
34 }
35 }
36 for (f of Object.getOwnPropertyNames(Number.prototype)) {
37 if (typeof Number.prototype[f] === "function") {
38 if (f == "toLocaleString") continue;
39 success(Number(0.5)[f](5), `Number(0.5).${f}(5);`);
40 }
41 }
42
43 // Test String functions.
44 success(" ", "String.fromCodePoint(0x20)");
45 success(" ", "String.fromCharCode(0x20)");
46 for (f of Object.getOwnPropertyNames(String.prototype)) {
47 if (typeof String.prototype[f] === "function") {
48 // Do not expect locale-specific or regexp-related functions to work.
49 if (f.indexOf("locale") >= 0) continue;
50 if (f == "normalize") continue;
51 if (f == "match") continue;
52 if (f == "search") continue;
53 if (f == "split") continue;
54 success("abcd"[f](2), `"abcd".${f}(2);`);
55 }
56 }
57 fail("'abcd'.match(/a/)");
58 fail("'abcd'.replace(/a/)");
59 fail("'abcd'.search(/a/)");
60 fail("'abcd'.split(/a/)");
61
62 // Test JSON functions.
63 success('{"abc":[1,2]}', "JSON.stringify(JSON.parse('{\"abc\":[1,2]}'))");
64 } catch (e) {
65 exception = e;
66 print(e, e.stack);
67 };
68 };
69
70 // Add the debug event listener.
71 Debug.setListener(listener);
72
73 function f() {
74 debugger;
75 };
76
77 f();
78
79 assertNull(exception);
OLDNEW
« no previous file with comments | « src/debug/debug-evaluate.cc ('k') | test/debugger/test-api.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698