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

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: 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 log.push(match[1]);
19 } catch (e) {
20 exception = e;
21 }
22 }
23
24
25 function* g() {
26 try {
27 throw 0; // Ordinary throw. Exception a
28 } catch (e) {}
29 try {
30 yield 1; // Caught internally. Exception b
31 } catch (e) {}
32 yield 2;
33 yield 3; // Caught externally. Exception c
34 yield 4;
35 }
36
37 Debug.setListener(listener);
38 Debug.setBreakOnException();
39 var g_obj = g();
40 assertEquals(1, g_obj.next().value);
41 assertEquals(2, g_obj.throw("a").value);
neis 2016/07/05 09:30:51 The arguments to throw are a little confusing. May
42 assertEquals(3, g_obj.next().value);
43 assertThrows(() => g_obj.throw("b"));
44 assertThrows(() => g_obj.throw("c")); // Closed generator. Exception d
45 Debug.setListener(null);
46 Debug.clearBreakOnException();
47 assertEquals(["a", "b", "c", "d"], log);
48 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