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

Side by Side Diff: test/mjsunit/harmony/debug-stepin-collections-foreach.js

Issue 427723002: Enable ES6 Map and Set by default (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Remove old test, fix BUILD.gn Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « test/mjsunit/harmony/collections.js ('k') | test/mjsunit/harmony/mirror-collections.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 2014 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: --expose-debug-as debug --harmony-collections
6
7 Debug = debug.Debug
8
9 var exception = false;
10
11 function listener(event, exec_state, event_data, data) {
12 try {
13 if (event == Debug.DebugEvent.Break) {
14 if (breaks == 0) {
15 exec_state.prepareStep(Debug.StepAction.StepIn, 2);
16 breaks = 1;
17 } else if (breaks <= 3) {
18 breaks++;
19 // Check whether we break at the expected line.
20 print(event_data.sourceLineText());
21 assertTrue(event_data.sourceLineText().indexOf("Expected to step") > 0);
22 exec_state.prepareStep(Debug.StepAction.StepIn, 3);
23 }
24 }
25 } catch (e) {
26 exception = true;
27 }
28 }
29
30 function cb_set(num) {
31 print("element " + num); // Expected to step to this point.
32 return true;
33 }
34
35 function cb_map(key, val) {
36 print("key " + key + ", value " + val); // Expected to step to this point.
37 return true;
38 }
39
40 var s = new Set();
41 s.add(1);
42 s.add(2);
43 s.add(3);
44 s.add(4);
45
46 var m = new Map();
47 m.set('foo', 1);
48 m.set('bar', 2);
49 m.set('baz', 3);
50 m.set('bat', 4);
51
52 Debug.setListener(listener);
53
54 var breaks = 0;
55 debugger;
56 s.forEach(cb_set);
57 assertFalse(exception);
58 assertEquals(4, breaks);
59
60 breaks = 0;
61 debugger;
62 m.forEach(cb_map);
63 assertFalse(exception);
64 assertEquals(4, breaks);
65
66 Debug.setListener(null);
67
68
69 // Test two levels of builtin callbacks:
70 // Array.forEach calls a callback function, which by itself uses
71 // Array.forEach with another callback function.
72
73 function second_level_listener(event, exec_state, event_data, data) {
74 try {
75 if (event == Debug.DebugEvent.Break) {
76 if (breaks == 0) {
77 exec_state.prepareStep(Debug.StepAction.StepIn, 3);
78 breaks = 1;
79 } else if (breaks <= 16) {
80 breaks++;
81 // Check whether we break at the expected line.
82 assertTrue(event_data.sourceLineText().indexOf("Expected to step") > 0);
83 // Step two steps further every four breaks to skip the
84 // forEach call in the first level of recurision.
85 var step = (breaks % 4 == 1) ? 6 : 3;
86 exec_state.prepareStep(Debug.StepAction.StepIn, step);
87 }
88 }
89 } catch (e) {
90 exception = true;
91 }
92 }
93
94 function cb_set_foreach(num) {
95 s.forEach(cb_set);
96 print("back to the first level of recursion.");
97 }
98
99 function cb_map_foreach(key, val) {
100 m.forEach(cb_set);
101 print("back to the first level of recursion.");
102 }
103
104 Debug.setListener(second_level_listener);
105
106 breaks = 0;
107 debugger;
108 s.forEach(cb_set_foreach);
109 assertFalse(exception);
110 assertEquals(17, breaks);
111
112 breaks = 0;
113 debugger;
114 m.forEach(cb_map_foreach);
115 assertFalse(exception);
116 assertEquals(17, breaks);
117
118 Debug.setListener(null);
OLDNEW
« no previous file with comments | « test/mjsunit/harmony/collections.js ('k') | test/mjsunit/harmony/mirror-collections.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698