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

Unified Diff: test/mjsunit/es6/debug-promises-update-status-event.js

Issue 393283007: Introduce more debug events for promises. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Check result length in the test as well Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/mjsunit/es6/debug-promises-update-parent-event.js ('k') | tools/generate-runtime-tests.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/es6/debug-promises-update-status-event.js
diff --git a/test/mjsunit/es6/debug-promises-update-status-event.js b/test/mjsunit/es6/debug-promises-update-status-event.js
new file mode 100644
index 0000000000000000000000000000000000000000..7f7950ed4c987d42ee4c4cb194493b8590af318f
--- /dev/null
+++ b/test/mjsunit/es6/debug-promises-update-status-event.js
@@ -0,0 +1,50 @@
+// Copyright 2014 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.
+
+// Flags: --expose-debug-as debug
+
+Debug = debug.Debug;
+
+var exception = null;
+var promise, status, value;
+var newPromise = 0, updatePromise = 0, counter = 0;
+
+function listener(event, exec_state, event_data, data) {
+ if (event_data instanceof debug.NewPromiseEvent) {
+ newPromise = counter;
+ counter++;
+ return;
+ }
+ if (!(event_data instanceof debug.UpdatePromiseStatusEvent)) return;
+ try {
+ updatePromise = counter;
+ assertTrue(newPromise < updatePromise);
+ counter++;
+
+ assertTrue(event_data.promise().isPromise());
+ promise = event_data.promise().value();
+
+ status = event_data.status();
+
+ value = event_data.value().value();
+ } catch (e) {
+ print(e + e.stack);
+ exception = e;
+ }
+}
+
+Debug.setListener(listener);
+
+var p1 = new Promise(function(resolve, reject) { resolve(1) });
+assertSame(promise, p1);
+assertEquals(status, 1);
+assertEquals(value, 1);
+
+var p2 = new Promise(function(resolve, reject) { reject(2) });
+assertSame(promise, p2);
+assertEquals(status, -1);
+assertEquals(value, 2);
+
+assertNull(exception);
+Debug.setListener(null);
« no previous file with comments | « test/mjsunit/es6/debug-promises-update-parent-event.js ('k') | tools/generate-runtime-tests.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698