test262/test/built-ins/Map/map-no-iterable.js

33 lines
1.0 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 23.1.1.1
description: >
Returns the new Map object with the new empty list if the iterable argument is
undefined.
info: >
Map ( [ iterable ] )
...
2. Let map be OrdinaryCreateFromConstructor(NewTarget, "%MapPrototype%",
«‍[[MapData]]» ).
...
4. Map maps [[MapData]] internal slot to a new empty List.
5. If iterable is not present, let iterable be undefined.
6. If iterable is either undefined or null, let iter be undefined.
...
8. If iter is undefined, return map.
---*/
var m1 = new Map();
var m2 = new Map(undefined);
var m3 = new Map(null);
assert.sameValue(m1.size, 0, 'The value of `new Map().size` is `0`');
assert.sameValue(m2.size, 0, 'The value of `new Map(undefined).size` is `0`');
assert.sameValue(m3.size, 0, 'The value of `new Map(null).size` is `0`');
assert(m1 instanceof Map);
assert(m2 instanceof Map);
assert(m3 instanceof Map);