OLD | NEW |
---|---|
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 11 matching lines...) Expand all Loading... | |
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 // Flags: --allow-natives-syntax --harmony-tostring | 28 // Flags: --allow-natives-syntax --harmony-tostring |
29 | 29 |
30 // Make sure we don't rely on functions patchable by monkeys. | 30 // Make sure we don't rely on functions patchable by monkeys. |
31 var call = Function.prototype.call.call.bind(Function.prototype.call) | 31 var call = Function.prototype.call.call.bind(Function.prototype.call) |
32 var observe = Object.observe; | |
33 var getOwnPropertyNames = Object.getOwnPropertyNames; | 32 var getOwnPropertyNames = Object.getOwnPropertyNames; |
34 var defineProperty = Object.defineProperty; | 33 var defineProperty = Object.defineProperty; |
35 var numberPrototype = Number.prototype; | 34 var numberPrototype = Number.prototype; |
36 var symbolIterator = Symbol.iterator; | 35 var symbolIterator = Symbol.iterator; |
37 | 36 |
38 | 37 |
39 (function() { | 38 (function() { |
40 // Test before clearing global (fails otherwise) | 39 // Test before clearing global (fails otherwise) |
41 assertEquals("[object Promise]", | 40 assertEquals("[object Promise]", |
42 Object.prototype.toString.call(new Promise(function() {}))); | 41 Object.prototype.toString.call(new Promise(function() {}))); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
81 if (b) { | 80 if (b) { |
82 print(s, "succeeded") | 81 print(s, "succeeded") |
83 } else { | 82 } else { |
84 %AbortJS(s + " FAILED!") // Simply throwing here will have no effect. | 83 %AbortJS(s + " FAILED!") // Simply throwing here will have no effect. |
85 } | 84 } |
86 --asyncAssertsExpected | 85 --asyncAssertsExpected |
87 } | 86 } |
88 | 87 |
89 function assertAsyncDone(iteration) { | 88 function assertAsyncDone(iteration) { |
90 var iteration = iteration || 0 | 89 var iteration = iteration || 0 |
91 var dummy = {} | 90 Promise.resolve().then( |
rossberg
2015/07/21 10:25:37
Some of the tests now become a bit circular (relyi
adamk
2015/07/21 16:18:08
I could switch them all to use %EnqueueMicrotask,
rossberg
2015/07/21 16:28:43
Aw, of course. For some reason I though that can't
| |
92 observe(dummy, | |
93 function() { | 91 function() { |
94 if (asyncAssertsExpected === 0) | 92 if (asyncAssertsExpected === 0) |
95 assertAsync(true, "all") | 93 assertAsync(true, "all") |
96 else if (iteration > 10) // Shouldn't take more. | 94 else if (iteration > 10) // Shouldn't take more. |
97 assertAsync(false, "all") | 95 assertAsync(false, "all") |
98 else | 96 else |
99 assertAsyncDone(iteration + 1) | 97 assertAsyncDone(iteration + 1) |
100 } | 98 } |
101 ) | 99 ) |
102 dummy.dummy = dummy | |
103 } | 100 } |
104 | 101 |
105 | 102 |
106 (function() { | 103 (function() { |
107 assertThrows(function() { Promise(function() {}) }, TypeError) | 104 assertThrows(function() { Promise(function() {}) }, TypeError) |
108 })(); | 105 })(); |
109 | 106 |
110 (function() { | 107 (function() { |
111 assertTrue(new Promise(function() {}) instanceof Promise) | 108 assertTrue(new Promise(function() {}) instanceof Promise) |
112 })(); | 109 })(); |
(...skipping 915 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1028 Promise.all([11, Promise.accept(12), 13, MyPromise.accept(14), 15, 16]) | 1025 Promise.all([11, Promise.accept(12), 13, MyPromise.accept(14), 15, 16]) |
1029 assertTrue(log === "nx14n", "subclass/all/arg") | 1026 assertTrue(log === "nx14n", "subclass/all/arg") |
1030 | 1027 |
1031 log = "" | 1028 log = "" |
1032 MyPromise.all([21, Promise.accept(22), 23, MyPromise.accept(24), 25, 26]) | 1029 MyPromise.all([21, Promise.accept(22), 23, MyPromise.accept(24), 25, 26]) |
1033 assertTrue(log === "nx24nnx21nnx23nnnx25nnx26n", "subclass/all/self") | 1030 assertTrue(log === "nx24nnx21nnx23nnnx25nnx26n", "subclass/all/self") |
1034 })(); | 1031 })(); |
1035 | 1032 |
1036 | 1033 |
1037 assertAsyncDone() | 1034 assertAsyncDone() |
OLD | NEW |