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

Unified Diff: test/mjsunit/harmony/mirror-async-function-promise.js

Issue 2082023002: [test] add FunctionMirror and PromiseMirror tests for async functions (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: add Promise tests and fix copyright Created 4 years, 6 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/harmony/mirror-async-function.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/harmony/mirror-async-function-promise.js
diff --git a/test/mjsunit/es6/mirror-promises.js b/test/mjsunit/harmony/mirror-async-function-promise.js
similarity index 78%
copy from test/mjsunit/es6/mirror-promises.js
copy to test/mjsunit/harmony/mirror-async-function-promise.js
index deeba8f549f2619b4960c4f6b8835058f34c6d3f..966b0ce26743e4297d26d8e9e29c6f81732ef6a8 100644
--- a/test/mjsunit/es6/mirror-promises.js
+++ b/test/mjsunit/harmony/mirror-async-function-promise.js
@@ -1,10 +1,12 @@
-// Copyright 2014 the V8 project authors. All rights reserved.
+// Copyright 2016 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
+// Flags: --expose-debug-as debug --harmony-async-await --allow-natives-syntax
// Test the mirror object for promises.
+var AsyncFunction = (async function() {}).constructor;
+
function MirrorRefCache(json_refs) {
var tmp = eval('(' + json_refs + ')');
this.refs_ = [];
@@ -53,25 +55,24 @@ function testPromiseMirror(promise, status, value) {
}
// Test a number of different promises.
-var resolved = new Promise(function(resolve, reject) { resolve() });
-var rejected = new Promise(function(resolve, reject) { reject() });
-var pending = new Promise(function(resolve, reject) {});
+var resolved = (async function() {})();
+var rejected = (async function() { throw undefined; })();
+var pending = (async function() { await 1; })();
testPromiseMirror(resolved, "resolved", undefined);
testPromiseMirror(rejected, "rejected", undefined);
testPromiseMirror(pending, "pending", undefined);
-var resolvedv = new Promise(function(resolve, reject) { resolve('resolve') });
-var rejectedv = new Promise(function(resolve, reject) { reject('reject') });
-var thrownv = new Promise(function(resolve, reject) { throw 'throw' });
+var resolvedv = (async function() { return "resolve"; })();
+var rejectedv = (async function() { return Promise.reject("reject"); })();
+var thrownv = (async function() { throw "throw"; })();
testPromiseMirror(resolvedv, "resolved", 'resolve');
testPromiseMirror(rejectedv, "rejected", 'reject');
testPromiseMirror(thrownv, "rejected", 'throw');
// Test internal properties of different promises.
-var m1 = debug.MakeMirror(new Promise(
- function(resolve, reject) { resolve(1) }));
+var m1 = debug.MakeMirror((async function() { return 1; })());
var ip = m1.internalProperties();
assertEquals(2, ip.length);
assertEquals("[[PromiseStatus]]", ip[0].name());
@@ -79,12 +80,14 @@ assertEquals("[[PromiseValue]]", ip[1].name());
assertEquals("resolved", ip[0].value().value());
assertEquals(1, ip[1].value().value());
-var m2 = debug.MakeMirror(new Promise(function(resolve, reject) { reject(2) }));
+var m2 = debug.MakeMirror((async function() { throw 2; })());
ip = m2.internalProperties();
assertEquals("rejected", ip[0].value().value());
assertEquals(2, ip[1].value().value());
-var m3 = debug.MakeMirror(new Promise(function(resolve, reject) { }));
+var m3 = debug.MakeMirror((async function() { await 1; })());
ip = m3.internalProperties();
assertEquals("pending", ip[0].value().value());
assertEquals("undefined", typeof(ip[1].value().value()));
+
+%RunMicrotasks();
« no previous file with comments | « test/mjsunit/harmony/mirror-async-function.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698