diff options
author | Sam Mikes <smikes@cubane.com> | 2014-07-17 11:49:35 -0600 |
---|---|---|
committer | Sam Mikes <smikes@cubane.com> | 2014-07-18 05:37:08 +0100 |
commit | 7e07cc138d043ffdd0e6730d51d83914dfe6958f (patch) | |
tree | 0cf749f20a915c3fefbd8c880fb627653b830606 /test/suite | |
parent | 880a7e93164f159eeb2657657074488c78f4a302 (diff) | |
download | qtdeclarative-testsuites-7e07cc138d043ffdd0e6730d51d83914dfe6958f.tar.gz |
async,promises: initial tests of Promises
doneprintHandle.js: make $DONE accept any falsy argument as meaning 'pass'
PromiseHelper.js: checkSequence: new helper fn for async tests
.gitignore: port .hgignore to .gitignore syntax
test262.py: support $INCLUDE directive in python test runner
S25.4.4.1*: tests to cover Section 25.4.4.1, Promise.all( iterable )
A1.1: Promise.all is callable
A1.2: Promise.all expects 1 argument
A2.1: Promise.all([]) is a Promise
A2.2: Promise.all([]) is resolved immediately
A2.3: Promise.all([]) is resolved with a new empty array
A3.1: Promise.all expects an iterable argument
Diffstat (limited to 'test/suite')
8 files changed, 159 insertions, 0 deletions
diff --git a/test/suite/es6/ch25/25.4/25.4.4/25.4.4.1/S25.4.4.1_A1.1_T1.js b/test/suite/es6/ch25/25.4/25.4.4/25.4.4.1/S25.4.4.1_A1.1_T1.js new file mode 100644 index 000000000..0f7c216a5 --- /dev/null +++ b/test/suite/es6/ch25/25.4/25.4.4/25.4.4.1/S25.4.4.1_A1.1_T1.js @@ -0,0 +1,17 @@ +// Copyright 2014 Ecma International. All rights reserved. +/// Ecma International makes this code available under the terms and conditions set +/// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the +/// "Use Terms"). Any redistribution of this code must retain the above +/// copyright and this notice and otherwise comply with the Use Terms. + +/** + * Promise.all is callable + * + * @author Sam Mikes + */ + +// CHECK#1 +var x = typeof Promise.all; +if (x !== "function") { + $ERROR('#1: x = typeof Promise.all; x === "function". Actual: ' + (x)); +} diff --git a/test/suite/es6/ch25/25.4/25.4.4/25.4.4.1/S25.4.4.1_A1.2_T1.js b/test/suite/es6/ch25/25.4/25.4.4/25.4.4.1/S25.4.4.1_A1.2_T1.js new file mode 100644 index 000000000..49b563e1c --- /dev/null +++ b/test/suite/es6/ch25/25.4/25.4.4/25.4.4.1/S25.4.4.1_A1.2_T1.js @@ -0,0 +1,17 @@ +/// Copyright 2012 Ecma International. All rights reserved. +/// Ecma International makes this code available under the terms and conditions set +/// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the +/// "Use Terms"). Any redistribution of this code must retain the above +/// copyright and this notice and otherwise comply with the Use Terms. + +/** + * Promise.all expects 1 argument + * + * @author Sam Mikes + */ + +// CHECK#1 +var x = Promise.all.length; +if (x !== 1) { + $ERROR('#1: x = Promise.all.length; x === 1. Actual: ' + (x)); +} diff --git a/test/suite/es6/ch25/25.4/25.4.4/25.4.4.1/S25.4.4.1_A2.1_T1.js b/test/suite/es6/ch25/25.4/25.4.4/25.4.4.1/S25.4.4.1_A2.1_T1.js new file mode 100644 index 000000000..f73d5b21a --- /dev/null +++ b/test/suite/es6/ch25/25.4/25.4.4/25.4.4.1/S25.4.4.1_A2.1_T1.js @@ -0,0 +1,17 @@ +// Copyright 2014 Ecma International. All rights reserved. +/// Ecma International makes this code available under the terms and conditions set +/// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the +/// "Use Terms"). Any redistribution of this code must retain the above +/// copyright and this notice and otherwise comply with the Use Terms. + +/** + * Promise.all([]) is a Promise + * + * @author Sam Mikes + */ + +// CHECK#1 +var x = (Promise.all([]) instanceof Promise); +if (x !== true) { + $ERROR('#1: x (Promise.all([]) instanceof Promise); x === true. Actual: ' + (x)); +} diff --git a/test/suite/es6/ch25/25.4/25.4.4/25.4.4.1/S25.4.4.1_A2.2_T1.js b/test/suite/es6/ch25/25.4/25.4.4/25.4.4.1/S25.4.4.1_A2.2_T1.js new file mode 100644 index 000000000..2f07cd192 --- /dev/null +++ b/test/suite/es6/ch25/25.4/25.4.4/25.4.4.1/S25.4.4.1_A2.2_T1.js @@ -0,0 +1,25 @@ +// Copyright 2014 Ecma International. All rights reserved. +/// Ecma International makes this code available under the terms and conditions set +/// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the +/// "Use Terms"). Any redistribution of this code must retain the above +/// copyright and this notice and otherwise comply with the Use Terms. + +/** + * Promise.all([]) is resolved immediately + * + * @author Sam Mikes + */ + +$INCLUDE("PromiseHelper.js"); +var sequence = []; + +Promise.all([]).then(function () { + sequence.push(1); +}).catch($DONE); + +Promise.resolve().then(function() { + sequence.push(2); +}).then(function () { + sequence.push(3); + checkSequence(sequence, "Promises resolved in unexpected sequence"); +}).then($DONE,$DONE); diff --git a/test/suite/es6/ch25/25.4/25.4.4/25.4.4.1/S25.4.4.1_A2.3_T1.js b/test/suite/es6/ch25/25.4/25.4.4/25.4.4.1/S25.4.4.1_A2.3_T1.js new file mode 100644 index 000000000..3ef289912 --- /dev/null +++ b/test/suite/es6/ch25/25.4/25.4.4/25.4.4.1/S25.4.4.1_A2.3_T1.js @@ -0,0 +1,20 @@ + +// Copyright 2014 Ecma International. All rights reserved. +/// Ecma International makes this code available under the terms and conditions set +/// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the +/// "Use Terms"). Any redistribution of this code must retain the above +/// copyright and this notice and otherwise comply with the Use Terms. + +/** + * Promise.all is resolved with a new empty array + * + * @author Sam Mikes + */ + +var arg = []; + +Promise.all(arg).then(function (result) { + if((result instanceof Array) !== true) { + $ERROR("expected an array from Promise.all, got " + result); + } +}).then($DONE,$DONE); diff --git a/test/suite/es6/ch25/25.4/25.4.4/25.4.4.1/S25.4.4.1_A2.3_T2.js b/test/suite/es6/ch25/25.4/25.4.4/25.4.4.1/S25.4.4.1_A2.3_T2.js new file mode 100644 index 000000000..4615e1dae --- /dev/null +++ b/test/suite/es6/ch25/25.4/25.4.4/25.4.4.1/S25.4.4.1_A2.3_T2.js @@ -0,0 +1,20 @@ + +// Copyright 2014 Ecma International. All rights reserved. +/// Ecma International makes this code available under the terms and conditions set +/// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the +/// "Use Terms"). Any redistribution of this code must retain the above +/// copyright and this notice and otherwise comply with the Use Terms. + +/** + * Promise.all is resolved with a new empty array + * + * @author Sam Mikes + */ + +var arg = []; + +Promise.all(arg).then(function (result) { + if(result.length !== 0) { + $ERROR("expected an empty array from Promise.all([]), got " + result); + } +}).then($DONE,$DONE); diff --git a/test/suite/es6/ch25/25.4/25.4.4/25.4.4.1/S25.4.4.1_A2.3_T3.js b/test/suite/es6/ch25/25.4/25.4.4/25.4.4.1/S25.4.4.1_A2.3_T3.js new file mode 100644 index 000000000..264208e34 --- /dev/null +++ b/test/suite/es6/ch25/25.4/25.4.4/25.4.4.1/S25.4.4.1_A2.3_T3.js @@ -0,0 +1,20 @@ + +// Copyright 2014 Ecma International. All rights reserved. +/// Ecma International makes this code available under the terms and conditions set +/// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the +/// "Use Terms"). Any redistribution of this code must retain the above +/// copyright and this notice and otherwise comply with the Use Terms. + +/** + * Promise.all is resolved with a new empty array + * + * @author Sam Mikes + */ + +var arg = []; + +Promise.all(arg).then(function (result) { + if(result === arg) { + $ERROR("expected a new array from Promise.all but argument was re-used"); + } +}).then($DONE,$DONE); diff --git a/test/suite/es6/ch25/25.4/25.4.4/25.4.4.1/S25.4.4.1_A3.1_T1.js b/test/suite/es6/ch25/25.4/25.4.4/25.4.4.1/S25.4.4.1_A3.1_T1.js new file mode 100644 index 000000000..1f755760b --- /dev/null +++ b/test/suite/es6/ch25/25.4/25.4.4/25.4.4.1/S25.4.4.1_A3.1_T1.js @@ -0,0 +1,23 @@ +// Copyright 2014 Ecma International. All rights reserved. +/// Ecma International makes this code available under the terms and conditions set +/// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the +/// "Use Terms"). Any redistribution of this code must retain the above +/// copyright and this notice and otherwise comply with the Use Terms. + +/** + * Promise.all expects an iterable argument; + * ref 7.4.1 non-Object fails CheckIterable + * ref 7.4.2 GetIterator throws TypeError if CheckIterable fails + * + * @author Sam Mikes + */ + +var nonIterable = 3; + +Promise.all(nonIterable).then(function () { + $ERROR('Promise unexpectedly resolved: Promise.all(nonIterable) should throw TypeError'); +},function (err) { + if (!(err instanceof TypeError)) { + $ERROR('Expected TypeError, got ' + err); + } +}).then($DONE,$DONE); |