Chromium Code Reviews| Index: test/webkit/fast/js/Promise-coerce.js |
| diff --git a/test/webkit/fast/js/Promise-coerce.js b/test/webkit/fast/js/Promise-coerce.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..a58ad6dd54281d69b093c5c2a92c30e1eccd0e83 |
| --- /dev/null |
| +++ b/test/webkit/fast/js/Promise-coerce.js |
| @@ -0,0 +1,64 @@ |
| +// Copyright 2015 the V8 project authors. All rights reserved. |
|
yhirano
2015/04/17 08:01:35
I don't know what license header I should use. Can
arv (Not doing code reviews)
2015/04/17 14:32:06
test/webkit/ is for tests imported from webkit. Ne
yhirano
2015/04/30 05:05:16
Done.
|
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +// Flags: --harmony |
| +'use strict'; |
| +description('Test Promise-like objects'); |
| + |
| +var called1 = false; |
| +var called2 = false; |
| +var called3 = false; |
| +var called4 = false; |
| +var value1 = 0; |
| +var value2 = 0; |
| +var value3 = 0; |
| +var value4 = 0; |
| +Promise.resolve().then(function() { |
| + var y = Promise.resolve(11); |
| + y.then = function() { |
| + called1 = true; |
| + return Promise.prototype.then.apply(y, arguments); |
| + }; |
| + return y; |
| +}).then(function(v) { |
| + value1 = v; |
| + |
| + var y = Promise.resolve(43); |
| + return { |
| + then: function() { |
| + called2 = true; |
| + return Promise.prototype.then.apply(y, arguments); |
| + } |
| + }; |
| +}).then(function(v) { |
| + value2 = v; |
| + |
| + var y = Promise.resolve(91); |
| + return Promise.resolve({ |
| + then: function() { |
| + called3 = true; |
| + return Promise.prototype.then.apply(y, arguments); |
| + } |
| + }); |
| +}).then(function(v) { |
| + value3 = v; |
| + |
| + var y = Promise.resolve(98); |
| + y.then = function() { |
| + called4 = true; |
| + return Promise.prototype.then.apply(y, arguments); |
| + }; |
| + return new Promise(function(r) {r(y);}); |
| +}).then(function(v) { |
| + value4 = v; |
| +}).then(function(v) { |
| + shouldBeTrue('called1'); |
| + shouldBeTrue('called2'); |
| + shouldBeTrue('called3'); |
| + shouldBeTrue('called4'); |
| + shouldBe('value1', '11'); |
| + shouldBe('value2', '43'); |
| + shouldBe('value3', '91'); |
| + shouldBe('value4', '98'); |
| +}).then(finishJSTest, finishJSTest); |