| // Copyright 2017 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: --allow-natives-syntax |
| // We have to patch mjsunit because normal assertion failures just throw |
| // exceptions which are swallowed in a then clause. |
| failWithMessage = (msg) => %AbortJS(msg); |
| let promise = new Promise((resolve, reject) => { |
| Promise.resolve(promise); |
| then: (f, g) => promise.then(f, g) |
| let promise = newPromise(); |
| promise.then(msg => {print("resolved: " + msg); assertEquals("ok", msg); }, |
| ex => {print("rejected: " + ex); %AbortJS("" + ex); }); |
| promise.reject(11); // ignored |
| let promise = newPromise(); |
| promise.then(msg => {print("resolved: " + msg); %AbortJS("fail"); }, |
| ex => {print("rejected: " + ex); assertEquals(42, ex); }); |
| promise.resolve("fail"); // ignored |