OLD | NEW |
---|---|
(Empty) | |
1 // 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.
| |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 // Flags: --harmony | |
6 'use strict'; | |
7 description('Test Promise-like objects'); | |
8 | |
9 var called1 = false; | |
10 var called2 = false; | |
11 var called3 = false; | |
12 var called4 = false; | |
13 var value1 = 0; | |
14 var value2 = 0; | |
15 var value3 = 0; | |
16 var value4 = 0; | |
17 Promise.resolve().then(function() { | |
18 var y = Promise.resolve(11); | |
19 y.then = function() { | |
20 called1 = true; | |
21 return Promise.prototype.then.apply(y, arguments); | |
22 }; | |
23 return y; | |
24 }).then(function(v) { | |
25 value1 = v; | |
26 | |
27 var y = Promise.resolve(43); | |
28 return { | |
29 then: function() { | |
30 called2 = true; | |
31 return Promise.prototype.then.apply(y, arguments); | |
32 } | |
33 }; | |
34 }).then(function(v) { | |
35 value2 = v; | |
36 | |
37 var y = Promise.resolve(91); | |
38 return Promise.resolve({ | |
39 then: function() { | |
40 called3 = true; | |
41 return Promise.prototype.then.apply(y, arguments); | |
42 } | |
43 }); | |
44 }).then(function(v) { | |
45 value3 = v; | |
46 | |
47 var y = Promise.resolve(98); | |
48 y.then = function() { | |
49 called4 = true; | |
50 return Promise.prototype.then.apply(y, arguments); | |
51 }; | |
52 return new Promise(function(r) {r(y);}); | |
53 }).then(function(v) { | |
54 value4 = v; | |
55 }).then(function(v) { | |
56 shouldBeTrue('called1'); | |
57 shouldBeTrue('called2'); | |
58 shouldBeTrue('called3'); | |
59 shouldBeTrue('called4'); | |
60 shouldBe('value1', '11'); | |
61 shouldBe('value2', '43'); | |
62 shouldBe('value3', '91'); | |
63 shouldBe('value4', '98'); | |
64 }).then(finishJSTest, finishJSTest); | |
OLD | NEW |