diff options
Diffstat (limited to 'js/src/tests/test262/built-ins/WeakMap/iterator-items-are-not-object.js')
-rw-r--r-- | js/src/tests/test262/built-ins/WeakMap/iterator-items-are-not-object.js | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/WeakMap/iterator-items-are-not-object.js b/js/src/tests/test262/built-ins/WeakMap/iterator-items-are-not-object.js new file mode 100644 index 0000000000..1f057feb21 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakMap/iterator-items-are-not-object.js @@ -0,0 +1,52 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-weakmap-iterable +description: > + Throws a TypeError if iterable itens are not Objects. +info: | + WeakMap ( [ iterable ] ) + + ... + 9. Repeat + ... + d. Let nextItem be IteratorValue(next). + e. ReturnIfAbrupt(nextItem). + f. If Type(nextItem) is not Object, + i. Let error be Completion{[[type]]: throw, [[value]]: a newly created + TypeError object, [[target]]:empty}. + ii. Return IteratorClose(iter, error). +features: [Symbol] +---*/ + +assert.throws(TypeError, function() { + new WeakMap([1, 1]); +}); + +assert.throws(TypeError, function() { + new WeakMap(['', 1]); +}); + +assert.throws(TypeError, function() { + new WeakMap([true, 1]); +}); + +assert.throws(TypeError, function() { + new WeakMap([null, 1]); +}); + +assert.throws(TypeError, function() { + new WeakMap([Symbol('a'), 1]); +}); + +assert.throws(TypeError, function() { + new WeakMap([undefined, 1]); +}); + +assert.throws(TypeError, function() { + new WeakMap([ + ['a', 1], 2 + ]); +}); + +reportCompare(0, 0); |