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

Side by Side Diff: test/mjsunit/es6/debug-exception-generators.js

Issue 2117303003: [debugger] add test case for throwing in generators. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix Created 4 years, 5 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 | « no previous file | no next file » | 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 2016 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
6
7 Debug = debug.Debug
8
9 var exception = null;
10 var log = [];
11
12 function listener(event, exec_state, event_data, data) {
13 if (event != Debug.DebugEvent.Exception) return;
14 try {
15 var line = exec_state.frame(0).sourceLineText();
16 var match = /Exception (\w)/.exec(line);
17 assertNotNull(match);
18 assertEquals(match[1], event_data.exception());
19 log.push(match[1]);
20 } catch (e) {
21 exception = e;
22 }
23 }
24
25
26 function* g() {
27 try {
28 throw "a"; // Ordinary throw. Exception a
29 } catch (e) {}
30 try {
31 yield 1; // Caught internally. Exception b
32 } catch (e) {}
33 yield 2;
34 yield 3; // Caught externally. Exception c
35 yield 4;
36 }
37
38 Debug.setListener(listener);
39 Debug.setBreakOnException();
40 var g_obj = g();
41 assertEquals(1, g_obj.next().value);
42 assertEquals(2, g_obj.throw("b").value);
43 assertEquals(3, g_obj.next().value);
44 assertThrows(() => g_obj.throw("c"));
45 assertThrows(() => g_obj.throw("d")); // Closed generator. Exception d
46 Debug.setListener(null);
47 Debug.clearBreakOnException();
48 assertEquals(["a", "b", "c", "d"], log);
49 assertNull(exception);
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698