Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(269)

Side by Side Diff: test/mjsunit/harmony/promises.js

Issue 182613003: Promise.all and Promise.race reject non-array parameter. (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/promise.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 541 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 var p = deferred.promise 552 var p = deferred.promise
553 deferred.resolve(p) 553 deferred.resolve(p)
554 p.then( 554 p.then(
555 assertUnreachable, 555 assertUnreachable,
556 function(r) { assertAsync(r instanceof TypeError, "cyclic/deferred/then") } 556 function(r) { assertAsync(r instanceof TypeError, "cyclic/deferred/then") }
557 ) 557 )
558 assertAsyncRan() 558 assertAsyncRan()
559 })(); 559 })();
560 560
561 (function() { 561 (function() {
562 Promise.all({get length() { throw 666 }}).chain( 562 Promise.all({}).chain(
563 assertUnreachable, 563 assertUnreachable,
564 function(r) { assertAsync(r === 666, "all/no-array") } 564 function(r) { assertAsync(r instanceof TypeError, "all/no-array") }
565 ) 565 )
566 assertAsyncRan() 566 assertAsyncRan()
567 })(); 567 })();
568 568
569 (function() { 569 (function() {
570 Promise.all([]).chain( 570 Promise.all([]).chain(
571 function(x) { assertAsync(x.length === 0, "all/resolve/empty") }, 571 function(x) { assertAsync(x.length === 0, "all/resolve/empty") },
572 assertUnreachable 572 assertUnreachable
573 ) 573 )
574 assertAsyncRan() 574 assertAsyncRan()
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 var p2 = Promise.resolve(2) 651 var p2 = Promise.resolve(2)
652 var p3 = Promise.resolve(3) 652 var p3 = Promise.resolve(3)
653 Promise.race([0, p1, p2, p3]).chain( 653 Promise.race([0, p1, p2, p3]).chain(
654 function(x) { assertAsync(x === 0, "resolved-const/one") }, 654 function(x) { assertAsync(x === 0, "resolved-const/one") },
655 assertUnreachable 655 assertUnreachable
656 ) 656 )
657 assertAsyncRan() 657 assertAsyncRan()
658 })(); 658 })();
659 659
660 (function() { 660 (function() {
661 Promise.race({get length() { throw 666 }}).chain( 661 Promise.race({}).chain(
662 assertUnreachable, 662 assertUnreachable,
663 function(r) { assertAsync(r === 666, "one/no-array") } 663 function(r) { assertAsync(r instanceof TypeError, "one/no-array") }
664 ) 664 )
665 assertAsyncRan() 665 assertAsyncRan()
666 })(); 666 })();
667 667
668 (function() { 668 (function() {
669 var deferred1 = Promise.defer() 669 var deferred1 = Promise.defer()
670 var p1 = deferred1.promise 670 var p1 = deferred1.promise
671 var deferred2 = Promise.defer() 671 var deferred2 = Promise.defer()
672 var p2 = deferred2.promise 672 var p2 = deferred2.promise
673 var deferred3 = Promise.defer() 673 var deferred3 = Promise.defer()
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
782 Promise.all([11, Promise.resolve(12), 13, MyPromise.resolve(14), 15, 16]) 782 Promise.all([11, Promise.resolve(12), 13, MyPromise.resolve(14), 15, 16])
783 assertTrue(log === "nx14cn", "subclass/all/arg") 783 assertTrue(log === "nx14cn", "subclass/all/arg")
784 784
785 log = "" 785 log = ""
786 MyPromise.all([21, Promise.resolve(22), 23, MyPromise.resolve(24), 25, 26]) 786 MyPromise.all([21, Promise.resolve(22), 23, MyPromise.resolve(24), 25, 26])
787 assertTrue(log === "nx24nnx21cnnx23cncnnx25cnnx26cn", "subclass/all/self") 787 assertTrue(log === "nx24nnx21cnnx23cncnnx25cnnx26cn", "subclass/all/self")
788 })(); 788 })();
789 789
790 790
791 assertAsyncDone() 791 assertAsyncDone()
OLDNEW
« no previous file with comments | « src/promise.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698