summaryrefslogtreecommitdiff
path: root/deps/v8/test/mjsunit/mjsunit.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/test/mjsunit/mjsunit.js')
-rw-r--r--deps/v8/test/mjsunit/mjsunit.js49
1 files changed, 33 insertions, 16 deletions
diff --git a/deps/v8/test/mjsunit/mjsunit.js b/deps/v8/test/mjsunit/mjsunit.js
index bef1b0b59f..754dcbb3de 100644
--- a/deps/v8/test/mjsunit/mjsunit.js
+++ b/deps/v8/test/mjsunit/mjsunit.js
@@ -123,6 +123,9 @@ var assertMatches;
// Assert the result of a promise.
var assertPromiseResult;
+var promiseTestChain;
+var promiseTestCount = 0;
+
// These bits must be in sync with bits defined in Runtime_GetOptimizationStatus
var V8OptimizationStatus = {
kIsFunction: 1 << 0,
@@ -134,7 +137,7 @@ var V8OptimizationStatus = {
kInterpreted: 1 << 6
};
-// Returns true if --no-crankshaft mode is on.
+// Returns true if --no-opt mode is on.
var isNeverOptimize;
// Returns true if --always-opt mode is on.
@@ -499,21 +502,35 @@ var failWithMessage;
// We have to patch mjsunit because normal assertion failures just throw
// exceptions which are swallowed in a then clause.
// We use eval here to avoid parsing issues with the natives syntax.
+ if (!success) success = () => {};
+
failWithMessage = (msg) => eval("%AbortJS(msg)");
- if (!fail)
+ if (!fail) {
fail = result => failWithMessage("assertPromiseResult failed: " + result);
+ }
- eval("%IncrementWaitCount()");
- promise.then(
- result => {
- eval("%DecrementWaitCount()");
- success(result);
- },
- result => {
- eval("%DecrementWaitCount()");
- fail(result);
- }
- );
+ var test_promise =
+ promise.then(
+ result => {
+ try {
+ success(result);
+ } catch (e) {
+ failWithMessage(e);
+ }
+ },
+ result => {
+ fail(result);
+ }
+ )
+ .then((x)=> {
+ if (--promiseTestCount == 0) testRunner.notifyDone();
+ });
+
+ if (!promiseTestChain) promiseTestChain = Promise.resolve();
+ // waitUntilDone is idempotent.
+ testRunner.waitUntilDone();
+ ++promiseTestCount;
+ return promiseTestChain.then(test_promise);
};
var OptimizationStatusImpl = undefined;
@@ -550,10 +567,10 @@ var failWithMessage;
assertOptimized = function assertOptimized(fun, sync_opt, name_opt) {
if (sync_opt === undefined) sync_opt = "";
var opt_status = OptimizationStatus(fun, sync_opt);
- // Tests that use assertOptimized() do not make sense if --no-crankshaft
- // option is provided. Such tests must add --crankshaft to flags comment.
+ // Tests that use assertOptimized() do not make sense if --no-opt
+ // option is provided. Such tests must add --opt to flags comment.
assertFalse((opt_status & V8OptimizationStatus.kNeverOptimize) !== 0,
- "test does not make sense with --no-crankshaft");
+ "test does not make sense with --no-opt");
assertTrue((opt_status & V8OptimizationStatus.kIsFunction) !== 0, name_opt);
if ((opt_status & V8OptimizationStatus.kMaybeDeopted) !== 0) {
// When --deopt-every-n-times flag is specified it's no longer guaranteed