mirror of
https://github.com/tc39/test262.git
synced 2025-07-29 08:54:35 +02:00
commit
6b6c3ada8a
10
test/built-ins/Map/constructor.js
Normal file
10
test/built-ins/Map/constructor.js
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
// 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
|
||||||
|
description: >
|
||||||
|
The Map constructor is the %Map% intrinsic object and the initial value of the
|
||||||
|
Map property of the global object.
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.sameValue(typeof Map, 'function', 'typeof Map is "function"');
|
@ -0,0 +1,29 @@
|
|||||||
|
// 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: >
|
||||||
|
Creating a new Map object without arguments doesn't throw if `set` is not
|
||||||
|
callable
|
||||||
|
info: >
|
||||||
|
Map ( [ iterable ] )
|
||||||
|
|
||||||
|
When the Set function is called with optional argument iterable the following steps are taken:
|
||||||
|
|
||||||
|
...
|
||||||
|
5. If iterable is not present, let iterable be undefined.
|
||||||
|
6. If iterable is either undefined or null, let iter be undefined.
|
||||||
|
7. Else,
|
||||||
|
a. Let adder be Get(map, "set").
|
||||||
|
b. ReturnIfAbrupt(adder).
|
||||||
|
c. If IsCallable(adder) is false, throw a TypeError exception.
|
||||||
|
...
|
||||||
|
8. If iter is undefined, return map.
|
||||||
|
...
|
||||||
|
---*/
|
||||||
|
|
||||||
|
Map.prototype.set = null;
|
||||||
|
|
||||||
|
var m = new Map();
|
||||||
|
|
||||||
|
assert.sameValue(m.size, 0, 'The value of `m.size` is `0`');
|
26
test/built-ins/Map/get-set-method-failure.js
Normal file
26
test/built-ins/Map/get-set-method-failure.js
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
// 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: >
|
||||||
|
new Map returns abrupt from getting Map.prototype.set.
|
||||||
|
description: >
|
||||||
|
Map ( [ iterable ] )
|
||||||
|
|
||||||
|
...
|
||||||
|
7. Else,
|
||||||
|
a. Let adder be Get(map, "add").
|
||||||
|
b. ReturnIfAbrupt(adder).
|
||||||
|
---*/
|
||||||
|
|
||||||
|
Object.defineProperty(Map.prototype, 'set', {
|
||||||
|
get: function() {
|
||||||
|
throw new Test262Error();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
new Map();
|
||||||
|
|
||||||
|
assert.throws(Test262Error, function() {
|
||||||
|
new Map([]);
|
||||||
|
});
|
39
test/built-ins/Map/iterable-calls-set.js
Normal file
39
test/built-ins/Map/iterable-calls-set.js
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
// 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: >
|
||||||
|
new Map calls `set` for each item on the iterable argument in order.
|
||||||
|
info: >
|
||||||
|
Map ( [ iterable ] )
|
||||||
|
|
||||||
|
...
|
||||||
|
9. Repeat
|
||||||
|
...
|
||||||
|
k. Let status be Call(adder, map, «k.[[value]], v.[[value]]»).
|
||||||
|
...
|
||||||
|
includes: [compareArray.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var mapSet = Map.prototype.set;
|
||||||
|
var counter = 0;
|
||||||
|
|
||||||
|
var iterable = [["foo", 1], ["bar", 2]];
|
||||||
|
var results = [];
|
||||||
|
var _this = [];
|
||||||
|
|
||||||
|
Map.prototype.set = function(k, v) {
|
||||||
|
counter++;
|
||||||
|
results.push([k, v]);
|
||||||
|
_this.push(this);
|
||||||
|
mapSet.call(this, k, v);
|
||||||
|
};
|
||||||
|
|
||||||
|
var map = new Map(iterable);
|
||||||
|
|
||||||
|
assert.sameValue(counter, 2, "`Map.prototype.set` called twice.");
|
||||||
|
|
||||||
|
assert(compareArray(results[0], iterable[0]));
|
||||||
|
assert(compareArray(results[1], iterable[1]));
|
||||||
|
assert.sameValue(_this[0], map);
|
||||||
|
assert.sameValue(_this[1], map);
|
36
test/built-ins/Map/iterator-close-after-set-failure.js
Normal file
36
test/built-ins/Map/iterator-close-after-set-failure.js
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
// 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: >
|
||||||
|
The iterator is closed when `Map.prototype.set` throws an error.
|
||||||
|
info: >
|
||||||
|
Map ( [ iterable ] )
|
||||||
|
|
||||||
|
...
|
||||||
|
9. Repeat
|
||||||
|
...
|
||||||
|
k. Let status be Call(adder, map, «k.[[value]], v.[[value]]»).
|
||||||
|
l. If status is an abrupt completion, return IteratorClose(iter, status).
|
||||||
|
features: [Symbol.iterator]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var count = 0;
|
||||||
|
var iterable = {};
|
||||||
|
iterable[Symbol.iterator] = function() {
|
||||||
|
return {
|
||||||
|
next: function() {
|
||||||
|
return { value: [], done: false };
|
||||||
|
},
|
||||||
|
return: function() {
|
||||||
|
count += 1;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
Map.prototype.set = function() { throw new Test262Error(); }
|
||||||
|
|
||||||
|
assert.throws(Test262Error, function() {
|
||||||
|
new Map(iterable);
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.sameValue(count, 1);
|
@ -0,0 +1,47 @@
|
|||||||
|
// 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: >
|
||||||
|
Closes iterator if item first entry completes abruptly.
|
||||||
|
info: >
|
||||||
|
Map ( [ iterable ] )
|
||||||
|
|
||||||
|
...
|
||||||
|
9. Repeat
|
||||||
|
...
|
||||||
|
d. Let nextItem be IteratorValue(next).
|
||||||
|
...
|
||||||
|
g. Let k be Get(nextItem, "0").
|
||||||
|
h. If k is an abrupt completion, return IteratorClose(iter, k).
|
||||||
|
...
|
||||||
|
features: [Symbol.iterator]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var count = 0;
|
||||||
|
var item = ['foo', 'bar'];
|
||||||
|
Object.defineProperty(item, 0, {
|
||||||
|
get: function() {
|
||||||
|
throw new Test262Error();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
var iterable = {};
|
||||||
|
iterable[Symbol.iterator] = function() {
|
||||||
|
return {
|
||||||
|
next: function() {
|
||||||
|
return {
|
||||||
|
value: item,
|
||||||
|
done: false
|
||||||
|
};
|
||||||
|
},
|
||||||
|
return: function() {
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
assert.throws(Test262Error, function() {
|
||||||
|
new Map(iterable);
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.sameValue(count, 1, 'The get error closed the iterator');
|
@ -0,0 +1,47 @@
|
|||||||
|
// 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: >
|
||||||
|
Closes iterator if item second entry completes abruptly.
|
||||||
|
info: >
|
||||||
|
Map ( [ iterable ] )
|
||||||
|
|
||||||
|
...
|
||||||
|
9. Repeat
|
||||||
|
...
|
||||||
|
d. Let nextItem be IteratorValue(next).
|
||||||
|
...
|
||||||
|
i. Let v be Get(nextItem, "1").
|
||||||
|
j. If v is an abrupt completion, return IteratorClose(iter, v).
|
||||||
|
...
|
||||||
|
features: [Symbol.iterator]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var count = 0;
|
||||||
|
var item = ['foo', 'bar'];
|
||||||
|
Object.defineProperty(item, 1, {
|
||||||
|
get: function() {
|
||||||
|
throw new Test262Error();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
var iterable = {};
|
||||||
|
iterable[Symbol.iterator] = function() {
|
||||||
|
return {
|
||||||
|
next: function() {
|
||||||
|
return {
|
||||||
|
value: item,
|
||||||
|
done: false
|
||||||
|
};
|
||||||
|
},
|
||||||
|
return: function() {
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
assert.throws(Test262Error, function() {
|
||||||
|
new Map(iterable);
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.sameValue(count, 1, 'The get error closed the iterator');
|
@ -0,0 +1,72 @@
|
|||||||
|
// 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: >
|
||||||
|
Closes the iterator after `not Object` error.
|
||||||
|
info: >
|
||||||
|
Map ( [ 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
|
||||||
|
- Symbol.iterator
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var count = 0;
|
||||||
|
var nextItem;
|
||||||
|
var iterable = {};
|
||||||
|
iterable[Symbol.iterator] = function() {
|
||||||
|
return {
|
||||||
|
next: function() {
|
||||||
|
return { value: nextItem, done: false };
|
||||||
|
},
|
||||||
|
return: function() {
|
||||||
|
count += 1;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
nextItem = 1;
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
new Map(iterable);
|
||||||
|
});
|
||||||
|
assert.sameValue(count, 1);
|
||||||
|
|
||||||
|
nextItem = true;
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
new Map(iterable);
|
||||||
|
});
|
||||||
|
assert.sameValue(count, 2);
|
||||||
|
|
||||||
|
nextItem = '';
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
new Map(iterable);
|
||||||
|
});
|
||||||
|
assert.sameValue(count, 3);
|
||||||
|
|
||||||
|
nextItem = null;
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
new Map(iterable);
|
||||||
|
});
|
||||||
|
assert.sameValue(count, 4);
|
||||||
|
|
||||||
|
nextItem = undefined;
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
new Map(iterable);
|
||||||
|
});
|
||||||
|
assert.sameValue(count, 5);
|
||||||
|
|
||||||
|
nextItem = Symbol('a');
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
new Map(iterable);
|
||||||
|
});
|
||||||
|
assert.sameValue(count, 6);
|
48
test/built-ins/Map/iterator-items-are-not-object.js
Normal file
48
test/built-ins/Map/iterator-items-are-not-object.js
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
// 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: >
|
||||||
|
Throws a TypeError if iterable itens are not Objects.
|
||||||
|
info: >
|
||||||
|
Map ( [ 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 Map([1]);
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
new Map(['']);
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
new Map([true]);
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
new Map([null]);
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
new Map([Symbol('a')]);
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
new Map([undefined]);
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
new Map([['a', 1], 2]);
|
||||||
|
});
|
28
test/built-ins/Map/iterator-next-failure.js
Normal file
28
test/built-ins/Map/iterator-next-failure.js
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
// 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: >
|
||||||
|
The iterator is closed when iterable `next` throws an error.
|
||||||
|
info: >
|
||||||
|
Map ( [ iterable ] )
|
||||||
|
|
||||||
|
...
|
||||||
|
9. Repeat
|
||||||
|
a. Let next be IteratorStep(iter).
|
||||||
|
b. ReturnIfAbrupt(next).
|
||||||
|
features: [Symbol.iterator]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var iterable = {};
|
||||||
|
iterable[Symbol.iterator] = function() {
|
||||||
|
return {
|
||||||
|
next: function() {
|
||||||
|
throw new Test262Error();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
assert.throws(Test262Error, function() {
|
||||||
|
new Map(iterable);
|
||||||
|
});
|
34
test/built-ins/Map/iterator-value-failure.js
Normal file
34
test/built-ins/Map/iterator-value-failure.js
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
// 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: >
|
||||||
|
The iterator is closed when iterable `next` value throws an error.
|
||||||
|
info: >
|
||||||
|
Map ( [ iterable ] )
|
||||||
|
|
||||||
|
...
|
||||||
|
9. Repeat
|
||||||
|
...
|
||||||
|
d. Let nextItem be IteratorValue(next).
|
||||||
|
e. ReturnIfAbrupt(nextItem).
|
||||||
|
features: [Symbol.iterator]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var iterable = {};
|
||||||
|
iterable[Symbol.iterator] = function() {
|
||||||
|
return {
|
||||||
|
next: function() {
|
||||||
|
return {
|
||||||
|
get value() {
|
||||||
|
throw new Test262Error();
|
||||||
|
},
|
||||||
|
done: false
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
assert.throws(Test262Error, function() {
|
||||||
|
new Map(iterable);
|
||||||
|
});
|
17
test/built-ins/Map/length.js
Normal file
17
test/built-ins/Map/length.js
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
// 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.2
|
||||||
|
description: Map.length is 0.
|
||||||
|
info: >
|
||||||
|
Properties of the Map Constructor
|
||||||
|
|
||||||
|
Besides the length property (whose value is 0)
|
||||||
|
includes: [propertyHelper.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.sameValue(Map.length, 0, 'The value of Map.length is 0');
|
||||||
|
|
||||||
|
verifyNotEnumerable(Map, 'length');
|
||||||
|
verifyNotWritable(Map, 'length');
|
||||||
|
verifyConfigurable(Map, 'length');
|
31
test/built-ins/Map/map-iterable-empty-does-not-call-set.js
Normal file
31
test/built-ins/Map/map-iterable-empty-does-not-call-set.js
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
// 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: >
|
||||||
|
A Map constructed with an empty iterable argument does not call set.
|
||||||
|
info: >
|
||||||
|
Map ( [ iterable ] )
|
||||||
|
|
||||||
|
When the Map function is called with optional argument the following steps are
|
||||||
|
taken:
|
||||||
|
|
||||||
|
...
|
||||||
|
8. If iter is undefined, return map.
|
||||||
|
9. Repeat
|
||||||
|
a. Let next be IteratorStep(iter).
|
||||||
|
b. ReturnIfAbrupt(next).
|
||||||
|
c. If next is false, return map.
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var set = Map.prototype.set;
|
||||||
|
var counter = 0;
|
||||||
|
|
||||||
|
Map.prototype.set = function(value) {
|
||||||
|
counter++;
|
||||||
|
set.call(this, value);
|
||||||
|
};
|
||||||
|
|
||||||
|
new Map([]);
|
||||||
|
|
||||||
|
assert.sameValue(counter, 0, '`Map.prototype.set` was not called.');
|
@ -0,0 +1,27 @@
|
|||||||
|
// 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: >
|
||||||
|
Throws a TypeError if `set` is not callable on Map constructor with a
|
||||||
|
iterable argument.
|
||||||
|
info: >
|
||||||
|
Map ( [ iterable ] )
|
||||||
|
|
||||||
|
When the Map function is called with optional argument the following steps are
|
||||||
|
taken:
|
||||||
|
|
||||||
|
...
|
||||||
|
5. If iterable is not present, let iterable be undefined.
|
||||||
|
6. If iterable is either undefined or null, let iter be undefined.
|
||||||
|
7. Else,
|
||||||
|
a. Let adder be Get(map, "set").
|
||||||
|
b. ReturnIfAbrupt(adder).
|
||||||
|
c. If IsCallable(adder) is false, throw a TypeError exception.
|
||||||
|
---*/
|
||||||
|
|
||||||
|
Map.prototype.set = null;
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
new Map([[1,1], [2,2]]);
|
||||||
|
});
|
26
test/built-ins/Map/map-iterable.js
Normal file
26
test/built-ins/Map/map-iterable.js
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
// 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: >
|
||||||
|
Contructor returns a map object set with the elements from the iterable
|
||||||
|
argument.
|
||||||
|
info: >
|
||||||
|
Map ( [ iterable ] )
|
||||||
|
|
||||||
|
...
|
||||||
|
9. Repeat
|
||||||
|
a. Let next be IteratorStep(iter).
|
||||||
|
b. ReturnIfAbrupt(next).
|
||||||
|
c. If next is false, return map.
|
||||||
|
...
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var m = new Map([
|
||||||
|
[ "attr", 1 ],
|
||||||
|
[ "foo", 2 ]
|
||||||
|
]);
|
||||||
|
|
||||||
|
assert.sameValue(m.size, 2, 'The value of `m.size` is `2`');
|
||||||
|
assert.sameValue(m.get("attr"), 1);
|
||||||
|
assert.sameValue(m.get("foo"), 2);
|
35
test/built-ins/Map/map-no-iterable-does-not-call-set.js
Normal file
35
test/built-ins/Map/map-no-iterable-does-not-call-set.js
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
// 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: >
|
||||||
|
A Map constructed without a iterable argument does not call set.
|
||||||
|
info: >
|
||||||
|
Map ( [ iterable ] )
|
||||||
|
|
||||||
|
When the Map function is called with optional argument the following steps are
|
||||||
|
taken:
|
||||||
|
|
||||||
|
...
|
||||||
|
5. If iterable is not present, let iterable be undefined.
|
||||||
|
6. If iterable is either undefined or null, let iter be undefined.
|
||||||
|
7. Else,
|
||||||
|
a. Let adder be Get(map, "set").
|
||||||
|
b. ReturnIfAbrupt(adder).
|
||||||
|
c. If IsCallable(adder) is false, throw a TypeError exception.
|
||||||
|
d. Let iter be GetIterator(iterable).
|
||||||
|
e. ReturnIfAbrupt(iter).
|
||||||
|
8. If iter is undefined, return map.
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var set = Map.prototype.set;
|
||||||
|
var counter = 0;
|
||||||
|
|
||||||
|
Map.prototype.set = function(value) {
|
||||||
|
counter++;
|
||||||
|
set.call(this, value);
|
||||||
|
};
|
||||||
|
|
||||||
|
new Map();
|
||||||
|
|
||||||
|
assert.sameValue(counter, 0, '`Map.prototype.set` was not called.');
|
32
test/built-ins/Map/map-no-iterable.js
Normal file
32
test/built-ins/Map/map-no-iterable.js
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
// 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 map’s [[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);
|
17
test/built-ins/Map/map.js
Normal file
17
test/built-ins/Map/map.js
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
// 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: >
|
||||||
|
Map descriptor as a standard built-in object.
|
||||||
|
info: >
|
||||||
|
Map ( [ iterable ] )
|
||||||
|
|
||||||
|
17 ECMAScript Standard Built-in Objects
|
||||||
|
|
||||||
|
includes: [propertyHelper.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
verifyNotEnumerable(this, 'Map');
|
||||||
|
verifyWritable(this, 'Map');
|
||||||
|
verifyConfigurable(this, 'Map');
|
18
test/built-ins/Map/name.js
Normal file
18
test/built-ins/Map/name.js
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
// 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: Map.name value and descriptor.
|
||||||
|
info: >
|
||||||
|
Map ( [ iterable ] )
|
||||||
|
|
||||||
|
17 ECMAScript Standard Built-in Objects
|
||||||
|
|
||||||
|
includes: [propertyHelper.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.sameValue(Map.name, 'Map', 'The value of Map.name is "Map"');
|
||||||
|
|
||||||
|
verifyNotEnumerable(Map, 'name');
|
||||||
|
verifyNotWritable(Map, 'name');
|
||||||
|
verifyConfigurable(Map, 'name');
|
34
test/built-ins/Map/newtarget.js
Normal file
34
test/built-ins/Map/newtarget.js
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
// 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: >
|
||||||
|
The new Map object's prototype is Map.prototype
|
||||||
|
info: >
|
||||||
|
Map ( [ iterable ] )
|
||||||
|
|
||||||
|
When the Map function is called with optional argument the following steps
|
||||||
|
are taken:
|
||||||
|
|
||||||
|
...
|
||||||
|
2. Let map be OrdinaryCreateFromConstructor(NewTarget, "%MapPrototype%",
|
||||||
|
«[[MapData]]» ).
|
||||||
|
...
|
||||||
|
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var m1 = new Map();
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
Object.getPrototypeOf(m1),
|
||||||
|
Map.prototype,
|
||||||
|
"`Object.getPrototypeOf(m1)` returns `Map.prototype`"
|
||||||
|
);
|
||||||
|
|
||||||
|
var m2 = new Map([[1, 1], [2, 2]]);
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
Object.getPrototypeOf(m2),
|
||||||
|
Map.prototype,
|
||||||
|
"`Object.getPrototypeOf(m2)` returns `Map.prototype`"
|
||||||
|
);
|
14
test/built-ins/Map/properties-of-map-instances.js
Normal file
14
test/built-ins/Map/properties-of-map-instances.js
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
// 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.4
|
||||||
|
description: >
|
||||||
|
Map instances are ordinary objects that inherit properties from the Map
|
||||||
|
prototype.
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
Object.getPrototypeOf(new Map()),
|
||||||
|
Map.prototype,
|
||||||
|
'`Object.getPrototypeOf(new Map())` returns `Map.prototype`'
|
||||||
|
);
|
18
test/built-ins/Map/properties-of-the-map-prototype-object.js
Normal file
18
test/built-ins/Map/properties-of-the-map-prototype-object.js
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
// 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.3
|
||||||
|
description: >
|
||||||
|
The prototype of Map.prototype is Object.prototype.
|
||||||
|
info: >
|
||||||
|
The Map prototype object is the intrinsic object %MapPrototype%. The value
|
||||||
|
of the [[Prototype]] internal slot of the Map prototype object is the
|
||||||
|
intrinsic object %ObjectPrototype% (19.1.3). The Map prototype object is an
|
||||||
|
ordinary object. It does not have a [[MapData]] internal slot.
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
Object.getPrototypeOf(Map.prototype),
|
||||||
|
Object.prototype,
|
||||||
|
'Object.getPrototypeOf(Map.prototype) returns Object.prototype'
|
||||||
|
);
|
16
test/built-ins/Map/prototype-of-map.js
vendored
Normal file
16
test/built-ins/Map/prototype-of-map.js
vendored
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
// 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.2
|
||||||
|
description: >
|
||||||
|
The prototype of Map is the intrinsic FunctionPrototype.
|
||||||
|
info: >
|
||||||
|
The value of the [[Prototype]] internal slot of the Map constructor is the
|
||||||
|
intrinsic object %FunctionPrototype% (19.2.3).
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
Object.getPrototypeOf(Map),
|
||||||
|
Function.prototype,
|
||||||
|
'`Object.getPrototypeOf(Map)` returns `Function.prototype`'
|
||||||
|
);
|
12
test/built-ins/Map/prototype/Symbol.iterator.js
vendored
12
test/built-ins/Map/prototype/Symbol.iterator.js
vendored
@ -1,19 +1,19 @@
|
|||||||
// Copyright (C) 2014 the V8 project authors. All rights reserved.
|
// Copyright (C) 2014 the V8 project authors. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
|
es6id: 23.1.3.12
|
||||||
description: Initial state of the Symbol.iterator property
|
description: Initial state of the Symbol.iterator property
|
||||||
info: >
|
info: >
|
||||||
The initial value of the @@iterator property is the same function object as
|
The initial value of the @@iterator property is the same function object as
|
||||||
the initial value of the entries property.
|
the initial value of the entries property.
|
||||||
|
|
||||||
Per ES6 section 17, the method should exist on the Array prototype, and it
|
Per ES6 section 17, the method should exist on the Array prototype, and it
|
||||||
should be writable and configurable, but not enumerable.
|
should be writable and configurable, but not enumerable.
|
||||||
includes: [propertyHelper.js]
|
includes: [propertyHelper.js]
|
||||||
features: [Symbol.iterator]
|
features: [Symbol.iterator]
|
||||||
es6id: 23.1.3.12
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
|
assert.sameValue(Map.prototype[Symbol.iterator], Map.prototype.entries);
|
||||||
verifyNotEnumerable(Map.prototype, Symbol.iterator);
|
verifyNotEnumerable(Map.prototype, Symbol.iterator);
|
||||||
verifyWritable(Map.prototype, Symbol.iterator);
|
verifyWritable(Map.prototype, Symbol.iterator);
|
||||||
verifyConfigurable(Map.prototype, Symbol.iterator);
|
verifyConfigurable(Map.prototype, Symbol.iterator);
|
||||||
|
21
test/built-ins/Map/prototype/Symbol.toStringTag/property-descriptor.js
vendored
Normal file
21
test/built-ins/Map/prototype/Symbol.toStringTag/property-descriptor.js
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
// 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.3.13
|
||||||
|
description: >
|
||||||
|
Map.prototype[ @@toStringTag ] value and descriptor.
|
||||||
|
includes: [propertyHelper.js]
|
||||||
|
features: [Symbol.toStringTag]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var MapProto = Object.getPrototypeOf(new Map());
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
MapProto[Symbol.toStringTag],
|
||||||
|
'Map',
|
||||||
|
'The value of MapProto[Symbol.toStringTag] is Map'
|
||||||
|
);
|
||||||
|
|
||||||
|
verifyNotEnumerable(MapProto, Symbol.toStringTag);
|
||||||
|
verifyNotWritable(MapProto, Symbol.toStringTag);
|
||||||
|
verifyConfigurable(MapProto, Symbol.toStringTag);
|
33
test/built-ins/Map/prototype/clear/clear-map.js
vendored
Normal file
33
test/built-ins/Map/prototype/clear/clear-map.js
vendored
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
// 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.3.1
|
||||||
|
description: >
|
||||||
|
Clears a Map.
|
||||||
|
info: >
|
||||||
|
Map.prototype.clear ( )
|
||||||
|
|
||||||
|
...
|
||||||
|
4. Let entries be the List that is the value of M’s [[MapData]] internal slot.
|
||||||
|
5. Repeat for each Record {[[key]], [[value]]} p that is an element of
|
||||||
|
entries,
|
||||||
|
a. Set p.[[key]] to empty.
|
||||||
|
b. Set p.[[value]] to empty.
|
||||||
|
6. Return undefined.
|
||||||
|
features: [Symbol]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var m1 = new Map([['foo', 'bar'], [1, 1]]);
|
||||||
|
var m2 = new Map();
|
||||||
|
var m3 = new Map();
|
||||||
|
m2.set('foo', 'bar');
|
||||||
|
m2.set(1,1);
|
||||||
|
m2.set(Symbol('a'), Symbol('a'));
|
||||||
|
|
||||||
|
m1.clear();
|
||||||
|
m2.clear();
|
||||||
|
m3.clear();
|
||||||
|
|
||||||
|
assert.sameValue(m1.size, 0);
|
||||||
|
assert.sameValue(m2.size, 0);
|
||||||
|
assert.sameValue(m3.size, 0);
|
21
test/built-ins/Map/prototype/clear/clear.js
vendored
Normal file
21
test/built-ins/Map/prototype/clear/clear.js
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
// 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.3.1
|
||||||
|
description: >
|
||||||
|
Map.prototype.clear ( )
|
||||||
|
|
||||||
|
17 ECMAScript Standard Built-in Objects
|
||||||
|
|
||||||
|
includes: [propertyHelper.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
typeof Map.prototype.clear,
|
||||||
|
'function',
|
||||||
|
'typeof Map.prototype.clear is "function"'
|
||||||
|
);
|
||||||
|
|
||||||
|
verifyNotEnumerable(Map.prototype, 'clear');
|
||||||
|
verifyWritable(Map.prototype, 'clear');
|
||||||
|
verifyConfigurable(Map.prototype, 'clear');
|
23
test/built-ins/Map/prototype/clear/context-is-not-map-object.js
vendored
Normal file
23
test/built-ins/Map/prototype/clear/context-is-not-map-object.js
vendored
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
// 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.3.1
|
||||||
|
description: >
|
||||||
|
Throws a TypeError if `this` does not have a [[MapData]] internal slot.
|
||||||
|
info: >
|
||||||
|
Map.prototype.clear ( )
|
||||||
|
|
||||||
|
1. Let M be the this value.
|
||||||
|
2. If Type(M) is not Object, throw a TypeError exception.
|
||||||
|
3. If M does not have a [[MapData]] internal slot, throw a TypeError
|
||||||
|
exception.
|
||||||
|
...
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.clear.call({});
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.clear.call([]);
|
||||||
|
});
|
38
test/built-ins/Map/prototype/clear/context-is-not-object.js
vendored
Normal file
38
test/built-ins/Map/prototype/clear/context-is-not-object.js
vendored
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
// 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.3.1
|
||||||
|
description: >
|
||||||
|
Throws a TypeError if `this` is not an Object.
|
||||||
|
info: >
|
||||||
|
Map.prototype.clear ( )
|
||||||
|
|
||||||
|
1. Let M be the this value.
|
||||||
|
2. If Type(M) is not Object, throw a TypeError exception.
|
||||||
|
...
|
||||||
|
features: [Symbol]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.clear.call(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.clear.call(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.clear.call('');
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.clear.call(null);
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.clear.call(undefined);
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.clear.call(Symbol());
|
||||||
|
});
|
20
test/built-ins/Map/prototype/clear/context-is-set-object-throws.js
vendored
Normal file
20
test/built-ins/Map/prototype/clear/context-is-set-object-throws.js
vendored
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
// 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.3.1
|
||||||
|
description: >
|
||||||
|
Throws a TypeError if `this` is a Set object.
|
||||||
|
info: >
|
||||||
|
Map.prototype.clear ( )
|
||||||
|
|
||||||
|
1. Let M be the this value.
|
||||||
|
2. If Type(M) is not Object, throw a TypeError exception.
|
||||||
|
3. If M does not have a [[MapData]] internal slot, throw a TypeError
|
||||||
|
exception.
|
||||||
|
...
|
||||||
|
features: [Set]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.clear.call(new Set());
|
||||||
|
});
|
20
test/built-ins/Map/prototype/clear/context-is-weakmap-object-throws.js
vendored
Normal file
20
test/built-ins/Map/prototype/clear/context-is-weakmap-object-throws.js
vendored
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
// 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.3.1
|
||||||
|
description: >
|
||||||
|
Throws a TypeError if `this` is a WeakMap object.
|
||||||
|
info: >
|
||||||
|
Map.prototype.clear ( )
|
||||||
|
|
||||||
|
1. Let M be the this value.
|
||||||
|
2. If Type(M) is not Object, throw a TypeError exception.
|
||||||
|
3. If M does not have a [[MapData]] internal slot, throw a TypeError
|
||||||
|
exception.
|
||||||
|
...
|
||||||
|
features: [WeakMap]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.clear.call(new WeakMap());
|
||||||
|
});
|
22
test/built-ins/Map/prototype/clear/length.js
vendored
Normal file
22
test/built-ins/Map/prototype/clear/length.js
vendored
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// 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.3.1
|
||||||
|
description: >
|
||||||
|
Map.prototype.clear.length value and descriptor.
|
||||||
|
info: >
|
||||||
|
Map.prototype.clear ( )
|
||||||
|
|
||||||
|
17 ECMAScript Standard Built-in Objects
|
||||||
|
|
||||||
|
includes: [propertyHelper.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
Map.prototype.clear.length, 0,
|
||||||
|
'The value of `Map.prototype.clear.length` is `0`'
|
||||||
|
);
|
||||||
|
|
||||||
|
verifyNotEnumerable(Map.prototype.clear, 'length');
|
||||||
|
verifyNotWritable(Map.prototype.clear, 'length');
|
||||||
|
verifyConfigurable(Map.prototype.clear, 'length');
|
31
test/built-ins/Map/prototype/clear/map-data-list-is-preserved.js
vendored
Normal file
31
test/built-ins/Map/prototype/clear/map-data-list-is-preserved.js
vendored
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
// 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.3.1
|
||||||
|
description: >
|
||||||
|
The existing [[MapData]] List is preserved.
|
||||||
|
info: >
|
||||||
|
The existing [[MapData]] List is preserved because there may be existing
|
||||||
|
MapIterator objects that are suspended midway through iterating over that
|
||||||
|
List.
|
||||||
|
|
||||||
|
Map.prototype.clear ( )
|
||||||
|
|
||||||
|
...
|
||||||
|
4. Let entries be the List that is the value of M’s [[MapData]] internal slot.
|
||||||
|
5. Repeat for each Record {[[key]], [[value]]} p that is an element of
|
||||||
|
entries,
|
||||||
|
a. Set p.[[key]] to empty.
|
||||||
|
b. Set p.[[value]] to empty.
|
||||||
|
6. Return undefined.
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var m = new Map([[1,1], [2,2], [3,3]]);
|
||||||
|
var e = m.entries();
|
||||||
|
|
||||||
|
e.next();
|
||||||
|
m.clear();
|
||||||
|
|
||||||
|
var n = e.next();
|
||||||
|
assert.sameValue(n.value, undefined);
|
||||||
|
assert.sameValue(n.done, true);
|
22
test/built-ins/Map/prototype/clear/name.js
vendored
Normal file
22
test/built-ins/Map/prototype/clear/name.js
vendored
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// 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.3.1
|
||||||
|
description: >
|
||||||
|
Map.prototype.entries.name value and descriptor.
|
||||||
|
info: >
|
||||||
|
Map.prototype.clear ( )
|
||||||
|
|
||||||
|
17 ECMAScript Standard Built-in Objects
|
||||||
|
|
||||||
|
includes: [propertyHelper.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
Map.prototype.clear.name, 'clear',
|
||||||
|
'The value of `Map.prototype.clear.name` is `"clear"`'
|
||||||
|
);
|
||||||
|
|
||||||
|
verifyNotEnumerable(Map.prototype.clear, 'name');
|
||||||
|
verifyNotWritable(Map.prototype.clear, 'name');
|
||||||
|
verifyConfigurable(Map.prototype.clear, 'name');
|
22
test/built-ins/Map/prototype/clear/returns-undefined.js
vendored
Normal file
22
test/built-ins/Map/prototype/clear/returns-undefined.js
vendored
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// 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.3.1
|
||||||
|
description: >
|
||||||
|
Returns undefined.
|
||||||
|
info: >
|
||||||
|
Map.prototype.clear ( )
|
||||||
|
|
||||||
|
...
|
||||||
|
4. Let entries be the List that is the value of M’s [[MapData]] internal slot.
|
||||||
|
5. Repeat for each Record {[[key]], [[value]]} p that is an element of
|
||||||
|
entries,
|
||||||
|
a. Set p.[[key]] to empty.
|
||||||
|
b. Set p.[[value]] to empty.
|
||||||
|
6. Return undefined.
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var m1 = new Map([['foo', 'bar'], [1, 1]]);
|
||||||
|
|
||||||
|
assert.sameValue(m1.clear(), undefined, 'clears a map and returns undefined');
|
||||||
|
assert.sameValue(m1.clear(), undefined, 'returns undefined on an empty map');
|
16
test/built-ins/Map/prototype/constructor.js
vendored
Normal file
16
test/built-ins/Map/prototype/constructor.js
vendored
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
// 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.3.2
|
||||||
|
description: Map.prototype.constructor value and descriptor
|
||||||
|
info: >
|
||||||
|
The initial value of Map.prototype.constructor is the intrinsic object %Map%.
|
||||||
|
includes: [propertyHelper.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.sameValue(Map.prototype.constructor, Map);
|
||||||
|
assert.sameValue((new Map()).constructor, Map);
|
||||||
|
|
||||||
|
verifyNotEnumerable(Map.prototype, 'constructor');
|
||||||
|
verifyWritable(Map.prototype, 'constructor');
|
||||||
|
verifyConfigurable(Map.prototype, 'constructor');
|
23
test/built-ins/Map/prototype/delete/context-is-not-map-object.js
vendored
Normal file
23
test/built-ins/Map/prototype/delete/context-is-not-map-object.js
vendored
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
// 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.3.3
|
||||||
|
description: >
|
||||||
|
Throws a TypeError if `this` does not have a [[MapData]] internal slot.
|
||||||
|
info: >
|
||||||
|
Map.prototype.delete ( key )
|
||||||
|
|
||||||
|
1. Let M be the this value.
|
||||||
|
2. If Type(M) is not Object, throw a TypeError exception.
|
||||||
|
3. If M does not have a [[MapData]] internal slot, throw a TypeError
|
||||||
|
exception.
|
||||||
|
...
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.delete.call({}, 'attr');
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.delete.call([], 'attr');
|
||||||
|
});
|
38
test/built-ins/Map/prototype/delete/context-is-not-object.js
vendored
Normal file
38
test/built-ins/Map/prototype/delete/context-is-not-object.js
vendored
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
// 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.3.3
|
||||||
|
description: >
|
||||||
|
Throws a TypeError if `this` is not an Object.
|
||||||
|
info: >
|
||||||
|
Map.prototype.delete ( key )
|
||||||
|
|
||||||
|
1. Let M be the this value.
|
||||||
|
2. If Type(M) is not Object, throw a TypeError exception.
|
||||||
|
...
|
||||||
|
features: [Symbol]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.delete.call(1, 'attr');
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.delete.call(true, 'attr');
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.delete.call('', 'attr');
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.delete.call(null, 'attr');
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.delete.call(undefined, 'attr');
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.delete.call(Symbol(), 'attr');
|
||||||
|
});
|
20
test/built-ins/Map/prototype/delete/context-is-set-object-throws.js
vendored
Normal file
20
test/built-ins/Map/prototype/delete/context-is-set-object-throws.js
vendored
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
// 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.3.3
|
||||||
|
description: >
|
||||||
|
Throws a TypeError if `this` is a Set object.
|
||||||
|
info: >
|
||||||
|
Map.prototype.delete ( key )
|
||||||
|
|
||||||
|
1. Let M be the this value.
|
||||||
|
2. If Type(M) is not Object, throw a TypeError exception.
|
||||||
|
3. If M does not have a [[MapData]] internal slot, throw a TypeError
|
||||||
|
exception.
|
||||||
|
...
|
||||||
|
features: [Set]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.delete.call(new Set(), 'attr');
|
||||||
|
});
|
20
test/built-ins/Map/prototype/delete/context-is-weakmap-object-throws.js
vendored
Normal file
20
test/built-ins/Map/prototype/delete/context-is-weakmap-object-throws.js
vendored
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
// 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.3.3
|
||||||
|
description: >
|
||||||
|
Throws a TypeError if `this` is a WeakMap object.
|
||||||
|
info: >
|
||||||
|
Map.prototype.delete ( key )
|
||||||
|
|
||||||
|
1. Let M be the this value.
|
||||||
|
2. If Type(M) is not Object, throw a TypeError exception.
|
||||||
|
3. If M does not have a [[MapData]] internal slot, throw a TypeError
|
||||||
|
exception.
|
||||||
|
...
|
||||||
|
features: [WeakMap]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.delete.call(new WeakMap(), 'attr');
|
||||||
|
});
|
21
test/built-ins/Map/prototype/delete/delete.js
vendored
Normal file
21
test/built-ins/Map/prototype/delete/delete.js
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
// 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.3.3
|
||||||
|
description: >
|
||||||
|
Map.prototype.delete ( )
|
||||||
|
|
||||||
|
17 ECMAScript Standard Built-in Objects
|
||||||
|
|
||||||
|
includes: [propertyHelper.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
typeof Map.prototype.delete,
|
||||||
|
'function',
|
||||||
|
'typeof Map.prototype.delete is "function"'
|
||||||
|
);
|
||||||
|
|
||||||
|
verifyNotEnumerable(Map.prototype, 'delete');
|
||||||
|
verifyWritable(Map.prototype, 'delete');
|
||||||
|
verifyConfigurable(Map.prototype, 'delete');
|
32
test/built-ins/Map/prototype/delete/does-not-break-iterators.js
vendored
Normal file
32
test/built-ins/Map/prototype/delete/does-not-break-iterators.js
vendored
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
// 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.3.3
|
||||||
|
description: >
|
||||||
|
Deleting an entry does not break a [[MapData]] List.
|
||||||
|
info: >
|
||||||
|
Map.prototype.delete ( key )
|
||||||
|
|
||||||
|
4. Let entries be the List that is the value of M’s [[MapData]] internal slot.
|
||||||
|
5. Repeat for each Record {[[key]], [[value]]} p that is an element of entries,
|
||||||
|
a. If p.[[key]] is not empty and SameValueZero(p.[[key]], key) is true, then
|
||||||
|
i. Set p.[[key]] to empty.
|
||||||
|
ii. Set p.[[value]] to empty.
|
||||||
|
iii. Return true.
|
||||||
|
...
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var m = new Map([['a',1], ['b', 2], ['c', 3]]);
|
||||||
|
var e = m.entries();
|
||||||
|
|
||||||
|
e.next();
|
||||||
|
m.delete('b');
|
||||||
|
|
||||||
|
var n = e.next();
|
||||||
|
|
||||||
|
assert.sameValue(n.value[0], 'c');
|
||||||
|
assert.sameValue(n.value[1], 3);
|
||||||
|
|
||||||
|
n = e.next();
|
||||||
|
assert.sameValue(n.value, undefined);
|
||||||
|
assert.sameValue(n.done, true);
|
22
test/built-ins/Map/prototype/delete/length.js
vendored
Normal file
22
test/built-ins/Map/prototype/delete/length.js
vendored
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// 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.3.3
|
||||||
|
description: >
|
||||||
|
Map.prototype.delete.length value and descriptor.
|
||||||
|
info: >
|
||||||
|
Map.prototype.delete ( key )
|
||||||
|
|
||||||
|
17 ECMAScript Standard Built-in Objects
|
||||||
|
|
||||||
|
includes: [propertyHelper.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
Map.prototype.delete.length, 1,
|
||||||
|
'The value of `Map.prototype.delete.length` is `1`'
|
||||||
|
);
|
||||||
|
|
||||||
|
verifyNotEnumerable(Map.prototype.delete, 'length');
|
||||||
|
verifyNotWritable(Map.prototype.delete, 'length');
|
||||||
|
verifyConfigurable(Map.prototype.delete, 'length');
|
22
test/built-ins/Map/prototype/delete/name.js
vendored
Normal file
22
test/built-ins/Map/prototype/delete/name.js
vendored
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// 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.3.3
|
||||||
|
description: >
|
||||||
|
Map.prototype.delete.name value and descriptor.
|
||||||
|
info: >
|
||||||
|
Map.prototype.delete ( key )
|
||||||
|
|
||||||
|
17 ECMAScript Standard Built-in Objects
|
||||||
|
|
||||||
|
includes: [propertyHelper.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
Map.prototype.delete.name, 'delete',
|
||||||
|
'The value of `Map.prototype.delete.name` is `"delete"`'
|
||||||
|
);
|
||||||
|
|
||||||
|
verifyNotEnumerable(Map.prototype.delete, 'name');
|
||||||
|
verifyNotWritable(Map.prototype.delete, 'name');
|
||||||
|
verifyConfigurable(Map.prototype.delete, 'name');
|
23
test/built-ins/Map/prototype/delete/returns-false.js
vendored
Normal file
23
test/built-ins/Map/prototype/delete/returns-false.js
vendored
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
// 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.3.3
|
||||||
|
description: >
|
||||||
|
Returns false when it does not delete an entry.
|
||||||
|
info: >
|
||||||
|
Map.prototype.delete ( key )
|
||||||
|
|
||||||
|
4. Let entries be the List that is the value of M’s [[MapData]] internal slot.
|
||||||
|
5. Repeat for each Record {[[key]], [[value]]} p that is an element of entries,
|
||||||
|
a. If p.[[key]] is not empty and SameValueZero(p.[[key]], key) is true, then
|
||||||
|
...
|
||||||
|
iii. Return true.
|
||||||
|
6. Return false.
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var m = new Map([['a',1], ['b', 2]]);
|
||||||
|
|
||||||
|
assert.sameValue(m.delete('not-in-the-map'), false);
|
||||||
|
|
||||||
|
m.delete('a');
|
||||||
|
assert.sameValue(m.delete('a'), false);
|
24
test/built-ins/Map/prototype/delete/returns-true-for-deleted-entry.js
vendored
Normal file
24
test/built-ins/Map/prototype/delete/returns-true-for-deleted-entry.js
vendored
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
// 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.3.3
|
||||||
|
description: >
|
||||||
|
Returns true when deletes an entry.
|
||||||
|
info: >
|
||||||
|
Map.prototype.delete ( key )
|
||||||
|
|
||||||
|
4. Let entries be the List that is the value of M’s [[MapData]] internal slot.
|
||||||
|
5. Repeat for each Record {[[key]], [[value]]} p that is an element of entries,
|
||||||
|
a. If p.[[key]] is not empty and SameValueZero(p.[[key]], key) is true, then
|
||||||
|
i. Set p.[[key]] to empty.
|
||||||
|
ii. Set p.[[value]] to empty.
|
||||||
|
iii. Return true.
|
||||||
|
...
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var m = new Map([['a',1], ['b', 2]]);
|
||||||
|
|
||||||
|
var result = m.delete('a');
|
||||||
|
|
||||||
|
assert(result);
|
||||||
|
assert.sameValue(m.size, 1);
|
14
test/built-ins/Map/prototype/descriptor.js
vendored
Normal file
14
test/built-ins/Map/prototype/descriptor.js
vendored
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
// 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.2.1
|
||||||
|
description: Map.prototype property attributes.
|
||||||
|
info: >
|
||||||
|
This property has the attributes { [[Writable]]: false, [[Enumerable]]: false,
|
||||||
|
[[Configurable]]: false }.
|
||||||
|
includes: [propertyHelper.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
verifyNotEnumerable(Map, 'prototype');
|
||||||
|
verifyNotWritable(Map, 'prototype');
|
||||||
|
verifyNotConfigurable(Map, 'prototype');
|
@ -1,13 +0,0 @@
|
|||||||
// Copyright (C) 2014 the V8 project authors. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
description: >
|
|
||||||
If the context does not have a [[MapData]] internal slot, throw a
|
|
||||||
TypeError exception as per 23.1.5.1.
|
|
||||||
es6id: 23.1.3.4
|
|
||||||
---*/
|
|
||||||
|
|
||||||
assert.throws(TypeError, function() {
|
|
||||||
Map.prototype.entries.call({});
|
|
||||||
});
|
|
29
test/built-ins/Map/prototype/entries/does-not-have-mapdata-internal-slot-set.js
vendored
Normal file
29
test/built-ins/Map/prototype/entries/does-not-have-mapdata-internal-slot-set.js
vendored
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
// 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.3.4
|
||||||
|
description: >
|
||||||
|
Throws a TypeError if `this` is a Set object.
|
||||||
|
info: >
|
||||||
|
Map.prototype.entries ( )
|
||||||
|
|
||||||
|
1. Let M be the this value.
|
||||||
|
2. Return CreateMapIterator(M, "key+value").
|
||||||
|
|
||||||
|
23.1.5.1 CreateMapIterator Abstract Operation
|
||||||
|
|
||||||
|
...
|
||||||
|
2. If map does not have a [[MapData]] internal slot, throw a TypeError
|
||||||
|
exception.
|
||||||
|
...
|
||||||
|
features: [Set]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.entries.call(new Set());
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
var m = new Map();
|
||||||
|
m.entries.call(new Set());
|
||||||
|
});
|
29
test/built-ins/Map/prototype/entries/does-not-have-mapdata-internal-slot-weakmap.js
vendored
Normal file
29
test/built-ins/Map/prototype/entries/does-not-have-mapdata-internal-slot-weakmap.js
vendored
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
// 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.3.4
|
||||||
|
description: >
|
||||||
|
Throws a TypeError if `this` is a WeakMap object.
|
||||||
|
info: >
|
||||||
|
Map.prototype.entries ( )
|
||||||
|
|
||||||
|
1. Let M be the this value.
|
||||||
|
2. Return CreateMapIterator(M, "key+value").
|
||||||
|
|
||||||
|
23.1.5.1 CreateMapIterator Abstract Operation
|
||||||
|
|
||||||
|
...
|
||||||
|
2. If map does not have a [[MapData]] internal slot, throw a TypeError
|
||||||
|
exception.
|
||||||
|
...
|
||||||
|
features: [WeakMap]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.entries.call(new WeakMap());
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
var m = new Map();
|
||||||
|
m.entries.call(new WeakMap());
|
||||||
|
});
|
38
test/built-ins/Map/prototype/entries/does-not-have-mapdata-internal-slot.js
vendored
Normal file
38
test/built-ins/Map/prototype/entries/does-not-have-mapdata-internal-slot.js
vendored
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
// 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.3.4
|
||||||
|
description: >
|
||||||
|
Throws a TypeError if `this` object does not have a [[MapData]] internal slot.
|
||||||
|
info: >
|
||||||
|
Map.prototype.entries ( )
|
||||||
|
|
||||||
|
1. Let M be the this value.
|
||||||
|
2. Return CreateMapIterator(M, "key+value").
|
||||||
|
|
||||||
|
23.1.5.1 CreateMapIterator Abstract Operation
|
||||||
|
|
||||||
|
...
|
||||||
|
2. If map does not have a [[MapData]] internal slot, throw a TypeError
|
||||||
|
exception.
|
||||||
|
...
|
||||||
|
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var m = new Map();
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.entries.call([]);
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
m.entries.call([]);
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.entries.call({});
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
m.entries.call({});
|
||||||
|
});
|
22
test/built-ins/Map/prototype/entries/entries.js
vendored
Normal file
22
test/built-ins/Map/prototype/entries/entries.js
vendored
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// 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.3.4
|
||||||
|
description: >
|
||||||
|
Property type and descriptor.
|
||||||
|
info: >
|
||||||
|
Map.prototype.entries ( )
|
||||||
|
|
||||||
|
17 ECMAScript Standard Built-in Objects
|
||||||
|
includes: [propertyHelper.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
typeof Map.prototype.entries,
|
||||||
|
'function',
|
||||||
|
'`typeof Map.prototype.entries` is `function`'
|
||||||
|
);
|
||||||
|
|
||||||
|
verifyNotEnumerable(Map.prototype, 'entries');
|
||||||
|
verifyWritable(Map.prototype, 'entries');
|
||||||
|
verifyConfigurable(Map.prototype, 'entries');
|
22
test/built-ins/Map/prototype/entries/length.js
vendored
Normal file
22
test/built-ins/Map/prototype/entries/length.js
vendored
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// 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.3.4
|
||||||
|
description: >
|
||||||
|
Map.prototype.entries.length value and descriptor.
|
||||||
|
info: >
|
||||||
|
Map.prototype.entries ( )
|
||||||
|
|
||||||
|
17 ECMAScript Standard Built-in Objects
|
||||||
|
|
||||||
|
includes: [propertyHelper.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
Map.prototype.entries.length, 0,
|
||||||
|
'The value of `Map.prototype.entries.length` is `0`'
|
||||||
|
);
|
||||||
|
|
||||||
|
verifyNotEnumerable(Map.prototype.entries, 'length');
|
||||||
|
verifyNotWritable(Map.prototype.entries, 'length');
|
||||||
|
verifyConfigurable(Map.prototype.entries, 'length');
|
22
test/built-ins/Map/prototype/entries/name.js
vendored
Normal file
22
test/built-ins/Map/prototype/entries/name.js
vendored
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// 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.3.4
|
||||||
|
description: >
|
||||||
|
Map.prototype.entries.name value and descriptor.
|
||||||
|
info: >
|
||||||
|
Map.prototype.entries ( )
|
||||||
|
|
||||||
|
17 ECMAScript Standard Built-in Objects
|
||||||
|
|
||||||
|
includes: [propertyHelper.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
Map.prototype.entries.name, 'entries',
|
||||||
|
'The value of `Map.prototype.entries.name` is `"entries"`'
|
||||||
|
);
|
||||||
|
|
||||||
|
verifyNotEnumerable(Map.prototype.entries, 'name');
|
||||||
|
verifyNotWritable(Map.prototype.entries, 'name');
|
||||||
|
verifyConfigurable(Map.prototype.entries, 'name');
|
27
test/built-ins/Map/prototype/entries/returns-iterator-empty.js
vendored
Normal file
27
test/built-ins/Map/prototype/entries/returns-iterator-empty.js
vendored
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
// 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.3.4
|
||||||
|
description: >
|
||||||
|
Returns an iterator on an empty Map object.
|
||||||
|
info: >
|
||||||
|
Map.prototype.entries ( )
|
||||||
|
|
||||||
|
...
|
||||||
|
2. Return CreateMapIterator(M, "key+value").
|
||||||
|
|
||||||
|
23.1.5.1 CreateMapIterator Abstract Operation
|
||||||
|
|
||||||
|
...
|
||||||
|
7. Return iterator.
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var map = new Map();
|
||||||
|
var iterator = map.entries();
|
||||||
|
var result = iterator.next();
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
result.value, undefined,
|
||||||
|
'The value of `result.value` is `undefined`'
|
||||||
|
);
|
||||||
|
assert.sameValue(result.done, true, 'The value of `result.done` is `true`');
|
@ -1,36 +1,44 @@
|
|||||||
// Copyright (C) 2014 the V8 project authors. All rights reserved.
|
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
description: >
|
es6id: 23.1.3.4
|
||||||
The method should return a valid iterator with the context as the
|
description: >
|
||||||
IteratedObject.
|
Returns an iterator.
|
||||||
es6id: 23.1.3.4
|
info: >
|
||||||
---*/
|
Map.prototype.entries ( )
|
||||||
|
|
||||||
|
...
|
||||||
|
2. Return CreateMapIterator(M, "key+value").
|
||||||
|
|
||||||
|
23.1.5.1 CreateMapIterator Abstract Operation
|
||||||
|
|
||||||
|
...
|
||||||
|
7. Return iterator.
|
||||||
|
---*/
|
||||||
|
|
||||||
var map = new Map();
|
var map = new Map();
|
||||||
map.set(1, 11);
|
map.set('a',1);
|
||||||
map.set(2, 22);
|
map.set('b',2);
|
||||||
map.set(3, 33);
|
map.set('c',3);
|
||||||
|
|
||||||
var iterator = map.entries();
|
var iterator = map.entries();
|
||||||
var result;
|
var result;
|
||||||
|
|
||||||
result = iterator.next();
|
result = iterator.next();
|
||||||
assert.sameValue(result.value[0], 1, 'First result `value` (map key)');
|
assert.sameValue(result.value[0], 'a', 'First result `value` ("key")');
|
||||||
assert.sameValue(result.value[1], 11, 'First result `value` (map value)');
|
assert.sameValue(result.value[1], 1, 'First result `value` ("value")');
|
||||||
assert.sameValue(result.value.length, 2, 'First result `value` (length)');
|
assert.sameValue(result.value.length, 2, 'First result `value` (length)');
|
||||||
assert.sameValue(result.done, false, 'First result `done` flag');
|
assert.sameValue(result.done, false, 'First result `done` flag');
|
||||||
|
|
||||||
result = iterator.next();
|
result = iterator.next();
|
||||||
assert.sameValue(result.value[0], 2, 'Second result `value` (map key)');
|
assert.sameValue(result.value[0], 'b', 'Second result `value` ("key")');
|
||||||
assert.sameValue(result.value[1], 22, 'Second result `value` (map value)');
|
assert.sameValue(result.value[1], 2, 'Second result `value` ("value")');
|
||||||
assert.sameValue(result.value.length, 2, 'Second result `value` (length)');
|
assert.sameValue(result.value.length, 2, 'Second result `value` (length)');
|
||||||
assert.sameValue(result.done, false, 'Second result `done` flag');
|
assert.sameValue(result.done, false, 'Second result `done` flag');
|
||||||
|
|
||||||
result = iterator.next();
|
result = iterator.next();
|
||||||
assert.sameValue(result.value[0], 3, 'Third result `value` (map key)');
|
assert.sameValue(result.value[0], 'c', 'Third result `value` ("key")');
|
||||||
assert.sameValue(result.value[1], 33, 'Third result `value` (map value)');
|
assert.sameValue(result.value[1], 3, 'Third result `value` ("value")');
|
||||||
assert.sameValue(result.value.length, 2, 'Third result `value` (length)');
|
assert.sameValue(result.value.length, 2, 'Third result `value` (length)');
|
||||||
assert.sameValue(result.done, false, 'Third result `done` flag');
|
assert.sameValue(result.done, false, 'Third result `done` flag');
|
||||||
|
|
47
test/built-ins/Map/prototype/entries/this-not-object-throw.js
vendored
Normal file
47
test/built-ins/Map/prototype/entries/this-not-object-throw.js
vendored
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
// 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.3.4
|
||||||
|
description: >
|
||||||
|
Throws a TypeError if `this` is not an Object.
|
||||||
|
info: >
|
||||||
|
Map.prototype.entries ( )
|
||||||
|
|
||||||
|
...
|
||||||
|
2. Return CreateSetIterator(M, "key+value").
|
||||||
|
|
||||||
|
23.1.5.1 CreateSetIterator Abstract Operation
|
||||||
|
|
||||||
|
1. If Type(map) is not Object, throw a TypeError exception.
|
||||||
|
...
|
||||||
|
features: [Symbol]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.entries.call(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.entries.call(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.entries.call('');
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.entries.call(undefined);
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.entries.call(null);
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.entries.call(Symbol());
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
var map = new Map();
|
||||||
|
map.entries.call(false);
|
||||||
|
});
|
44
test/built-ins/Map/prototype/forEach/callback-parameters.js
vendored
Normal file
44
test/built-ins/Map/prototype/forEach/callback-parameters.js
vendored
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
// 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.3.5
|
||||||
|
description: >
|
||||||
|
Verify the parameters order on the given callback.
|
||||||
|
info: >
|
||||||
|
Map.prototype.forEach ( callbackfn [ , thisArg ] )
|
||||||
|
|
||||||
|
...
|
||||||
|
5. If thisArg was supplied, let T be thisArg; else let T be undefined.
|
||||||
|
6. Let entries be the List that is the value of M’s [[MapData]] internal slot.
|
||||||
|
7. Repeat for each Record {[[key]], [[value]]} e that is an element of
|
||||||
|
entries, in original key insertion order
|
||||||
|
a. If e.[[key]] is not empty, then
|
||||||
|
i. Let funcResult be Call(callbackfn, T, «e.[[value]], e.[[key]], M»).
|
||||||
|
...
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var map = new Map();
|
||||||
|
map.set('foo', 42);
|
||||||
|
map.set('bar', 'baz');
|
||||||
|
|
||||||
|
var results = [];
|
||||||
|
|
||||||
|
var callback = function(value, key, thisArg) {
|
||||||
|
results.push({
|
||||||
|
value: value,
|
||||||
|
key: key,
|
||||||
|
thisArg: thisArg
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
map.forEach(callback);
|
||||||
|
|
||||||
|
assert.sameValue(results[0].value, 42);
|
||||||
|
assert.sameValue(results[0].key, 'foo');
|
||||||
|
assert.sameValue(results[0].thisArg, map);
|
||||||
|
|
||||||
|
assert.sameValue(results[1].value, 'baz');
|
||||||
|
assert.sameValue(results[1].key, 'bar');
|
||||||
|
assert.sameValue(results[1].thisArg, map);
|
||||||
|
|
||||||
|
assert.sameValue(results.length, 2);
|
28
test/built-ins/Map/prototype/forEach/callback-result-is-abrupt.js
vendored
Normal file
28
test/built-ins/Map/prototype/forEach/callback-result-is-abrupt.js
vendored
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
// 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.3.5
|
||||||
|
description: >
|
||||||
|
Returns error from callback result is abrupt.
|
||||||
|
info: >
|
||||||
|
Map.prototype.forEach ( callbackfn [ , thisArg ] )
|
||||||
|
|
||||||
|
...
|
||||||
|
5. If thisArg was supplied, let T be thisArg; else let T be undefined.
|
||||||
|
6. Let entries be the List that is the value of M’s [[MapData]] internal slot.
|
||||||
|
7. Repeat for each Record {[[key]], [[value]]} e that is an element of
|
||||||
|
entries, in original key insertion order
|
||||||
|
a. If e.[[key]] is not empty, then
|
||||||
|
i. Let funcResult be Call(callbackfn, T, «e.[[value]], e.[[key]], M»).
|
||||||
|
ii. ReturnIfAbrupt(funcResult).
|
||||||
|
...
|
||||||
|
flags: [noStrict]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var map = new Map([[0, 0]]);
|
||||||
|
|
||||||
|
assert.throws(Test262Error, function() {
|
||||||
|
map.forEach(function() {
|
||||||
|
throw new Test262Error();
|
||||||
|
});
|
||||||
|
});
|
35
test/built-ins/Map/prototype/forEach/callback-this-non-strict.js
vendored
Normal file
35
test/built-ins/Map/prototype/forEach/callback-this-non-strict.js
vendored
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
// 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.3.5
|
||||||
|
description: >
|
||||||
|
If a thisArg is not provided, undefined will be used as the this value for
|
||||||
|
each invocation of callbackfn.
|
||||||
|
info: >
|
||||||
|
Map.prototype.forEach ( callbackfn [ , thisArg ] )
|
||||||
|
|
||||||
|
...
|
||||||
|
5. If thisArg was supplied, let T be thisArg; else let T be undefined.
|
||||||
|
6. Let entries be the List that is the value of M’s [[MapData]] internal slot.
|
||||||
|
7. Repeat for each Record {[[key]], [[value]]} e that is an element of
|
||||||
|
entries, in original key insertion order
|
||||||
|
a. If e.[[key]] is not empty, then
|
||||||
|
i. Let funcResult be Call(callbackfn, T, «e.[[value]], e.[[key]], M»).
|
||||||
|
...
|
||||||
|
flags: [noStrict]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var _this = [];
|
||||||
|
var map = new Map();
|
||||||
|
|
||||||
|
map.set(0, 0);
|
||||||
|
map.set(1, 1);
|
||||||
|
map.set(2, 2);
|
||||||
|
|
||||||
|
map.forEach(function() {
|
||||||
|
_this.push(this);
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.sameValue(_this[0], this);
|
||||||
|
assert.sameValue(_this[1], this);
|
||||||
|
assert.sameValue(_this[2], this);
|
35
test/built-ins/Map/prototype/forEach/callback-this-strict.js
vendored
Normal file
35
test/built-ins/Map/prototype/forEach/callback-this-strict.js
vendored
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
// 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.3.5
|
||||||
|
description: >
|
||||||
|
If a thisArg is not provided, undefined will be used as the this value for
|
||||||
|
each invocation of callbackfn.
|
||||||
|
info: >
|
||||||
|
Map.prototype.forEach ( callbackfn [ , thisArg ] )
|
||||||
|
|
||||||
|
...
|
||||||
|
5. If thisArg was supplied, let T be thisArg; else let T be undefined.
|
||||||
|
6. Let entries be the List that is the value of M’s [[MapData]] internal slot.
|
||||||
|
7. Repeat for each Record {[[key]], [[value]]} e that is an element of
|
||||||
|
entries, in original key insertion order
|
||||||
|
a. If e.[[key]] is not empty, then
|
||||||
|
i. Let funcResult be Call(callbackfn, T, «e.[[value]], e.[[key]], M»).
|
||||||
|
...
|
||||||
|
flags: [onlyStrict]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var _this = [];
|
||||||
|
var map = new Map();
|
||||||
|
|
||||||
|
map.set(0, 0);
|
||||||
|
map.set(1, 1);
|
||||||
|
map.set(2, 2);
|
||||||
|
|
||||||
|
map.forEach(function() {
|
||||||
|
_this.push(this);
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.sameValue(_this[0], undefined);
|
||||||
|
assert.sameValue(_this[1], undefined);
|
||||||
|
assert.sameValue(_this[2], undefined);
|
41
test/built-ins/Map/prototype/forEach/deleted-values-during-foreach.js
vendored
Normal file
41
test/built-ins/Map/prototype/forEach/deleted-values-during-foreach.js
vendored
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
// 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.3.5
|
||||||
|
description: >
|
||||||
|
Map state with deleted values during forEach.
|
||||||
|
info: >
|
||||||
|
Map.prototype.forEach ( callbackfn [ , thisArg ] )
|
||||||
|
|
||||||
|
...
|
||||||
|
5. If thisArg was supplied, let T be thisArg; else let T be undefined.
|
||||||
|
6. Let entries be the List that is the value of M’s [[MapData]] internal slot.
|
||||||
|
7. Repeat for each Record {[[key]], [[value]]} e that is an element of
|
||||||
|
entries, in original key insertion order
|
||||||
|
a. If e.[[key]] is not empty, then
|
||||||
|
i. Let funcResult be Call(callbackfn, T, «e.[[value]], e.[[key]], M»).
|
||||||
|
ii. ReturnIfAbrupt(funcResult).
|
||||||
|
...
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var map = new Map();
|
||||||
|
map.set('foo', 0);
|
||||||
|
map.set('bar', 1);
|
||||||
|
|
||||||
|
var count = 0;
|
||||||
|
var results = [];
|
||||||
|
|
||||||
|
map.forEach(function(value, key) {
|
||||||
|
if (count === 0) {
|
||||||
|
map.delete('bar');
|
||||||
|
}
|
||||||
|
results.push({
|
||||||
|
value: value,
|
||||||
|
key: key
|
||||||
|
});
|
||||||
|
count++;
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.sameValue(results.length, 1);
|
||||||
|
assert.sameValue(results[0].key, 'foo');
|
||||||
|
assert.sameValue(results[0].value, 0);
|
24
test/built-ins/Map/prototype/forEach/does-not-have-mapdata-internal-slot-set.js
vendored
Normal file
24
test/built-ins/Map/prototype/forEach/does-not-have-mapdata-internal-slot-set.js
vendored
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
// 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.3.5
|
||||||
|
description: >
|
||||||
|
Throws a TypeError if `this` is a Set object.
|
||||||
|
info: >
|
||||||
|
Map.prototype.forEach ( callbackfn [ , thisArg ] )
|
||||||
|
|
||||||
|
...
|
||||||
|
3. If M does not have a [[MapData]] internal slot, throw a TypeError
|
||||||
|
exception.
|
||||||
|
...
|
||||||
|
features: [Set]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.forEach.call(new Set(), function() {});
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
var m = new Map();
|
||||||
|
m.forEach.call(new Set(), function() {});
|
||||||
|
});
|
24
test/built-ins/Map/prototype/forEach/does-not-have-mapdata-internal-slot-weakmap.js
vendored
Normal file
24
test/built-ins/Map/prototype/forEach/does-not-have-mapdata-internal-slot-weakmap.js
vendored
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
// 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.3.5
|
||||||
|
description: >
|
||||||
|
Throws a TypeError if `this` is a WeakMap object.
|
||||||
|
info: >
|
||||||
|
Map.prototype.forEach ( callbackfn [ , thisArg ] )
|
||||||
|
|
||||||
|
...
|
||||||
|
3. If M does not have a [[MapData]] internal slot, throw a TypeError
|
||||||
|
exception.
|
||||||
|
...
|
||||||
|
features: [WeakMap]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.forEach.call(new WeakMap(), function() {});
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
var m = new Map();
|
||||||
|
m.forEach.call(new WeakMap(), function() {});
|
||||||
|
});
|
32
test/built-ins/Map/prototype/forEach/does-not-have-mapdata-internal-slot.js
vendored
Normal file
32
test/built-ins/Map/prototype/forEach/does-not-have-mapdata-internal-slot.js
vendored
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
// 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.3.5
|
||||||
|
description: >
|
||||||
|
Throws a TypeError if `this` object does not have a [[MapData]] internal slot.
|
||||||
|
info: >
|
||||||
|
Map.prototype.forEach ( callbackfn [ , thisArg ] )
|
||||||
|
|
||||||
|
...
|
||||||
|
3. If M does not have a [[MapData]] internal slot, throw a TypeError
|
||||||
|
exception.
|
||||||
|
...
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var m = new Map();
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.forEach.call([], function() {});
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
m.forEach.call([], function() {});
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.forEach.call({}, function() {});
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
m.forEach.call({}, function() {});
|
||||||
|
});
|
43
test/built-ins/Map/prototype/forEach/first-argument-is-not-callable.js
vendored
Normal file
43
test/built-ins/Map/prototype/forEach/first-argument-is-not-callable.js
vendored
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
// 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.3.5
|
||||||
|
description: >
|
||||||
|
Throws a TypeError if first argument is not callable.
|
||||||
|
info: >
|
||||||
|
Map.prototype.forEach ( callbackfn [ , thisArg ] )
|
||||||
|
|
||||||
|
4. If IsCallable(callbackfn) is false, throw a TypeError exception.
|
||||||
|
...
|
||||||
|
features: [Symbol]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var map = new Map();
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
map.forEach({});
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
map.forEach([]);
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
map.forEach(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
map.forEach('');
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
map.forEach(null);
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
map.forEach(undefined);
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
map.forEach(Symbol());
|
||||||
|
});
|
22
test/built-ins/Map/prototype/forEach/forEach.js
vendored
Normal file
22
test/built-ins/Map/prototype/forEach/forEach.js
vendored
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// 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.3.5
|
||||||
|
description: >
|
||||||
|
Property type and descriptor.
|
||||||
|
info: >
|
||||||
|
Map.prototype.forEach ( callbackfn [ , thisArg ] )
|
||||||
|
|
||||||
|
17 ECMAScript Standard Built-in Objects
|
||||||
|
includes: [propertyHelper.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
typeof Map.prototype.forEach,
|
||||||
|
'function',
|
||||||
|
'`typeof Map.prototype.forEach` is `function`'
|
||||||
|
);
|
||||||
|
|
||||||
|
verifyNotEnumerable(Map.prototype, 'forEach');
|
||||||
|
verifyWritable(Map.prototype, 'forEach');
|
||||||
|
verifyConfigurable(Map.prototype, 'forEach');
|
51
test/built-ins/Map/prototype/forEach/iterates-in-key-insertion-order.js
vendored
Normal file
51
test/built-ins/Map/prototype/forEach/iterates-in-key-insertion-order.js
vendored
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
// 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.3.5
|
||||||
|
description: >
|
||||||
|
Repeats for each non-empty record, in original key insertion order.
|
||||||
|
info: >
|
||||||
|
Map.prototype.forEach ( callbackfn [ , thisArg ] )
|
||||||
|
|
||||||
|
...
|
||||||
|
5. If thisArg was supplied, let T be thisArg; else let T be undefined.
|
||||||
|
6. Let entries be the List that is the value of M’s [[MapData]] internal slot.
|
||||||
|
7. Repeat for each Record {[[key]], [[value]]} e that is an element of
|
||||||
|
entries, in original key insertion order
|
||||||
|
a. If e.[[key]] is not empty, then
|
||||||
|
i. Let funcResult be Call(callbackfn, T, «e.[[value]], e.[[key]], M»).
|
||||||
|
...
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var map = new Map([
|
||||||
|
['foo', 'valid foo'],
|
||||||
|
['bar', false],
|
||||||
|
['baz', 'valid baz']
|
||||||
|
]);
|
||||||
|
map.set(0, false);
|
||||||
|
map.set(1, false);
|
||||||
|
map.set(2, 'valid 2');
|
||||||
|
map.delete(1);
|
||||||
|
map.delete('bar');
|
||||||
|
|
||||||
|
// Not setting a new key, just changing the value
|
||||||
|
map.set(0, 'valid 0');
|
||||||
|
|
||||||
|
var results = [];
|
||||||
|
var callback = function(value) {
|
||||||
|
results.push(value);
|
||||||
|
};
|
||||||
|
|
||||||
|
map.forEach(callback);
|
||||||
|
|
||||||
|
assert.sameValue(results[0], 'valid foo');
|
||||||
|
assert.sameValue(results[1], 'valid baz');
|
||||||
|
assert.sameValue(results[2], 'valid 0');
|
||||||
|
assert.sameValue(results[3], 'valid 2');
|
||||||
|
assert.sameValue(results.length, 4);
|
||||||
|
|
||||||
|
map.clear();
|
||||||
|
results = [];
|
||||||
|
|
||||||
|
map.forEach(callback);
|
||||||
|
assert.sameValue(results.length, 0);
|
49
test/built-ins/Map/prototype/forEach/iterates-values-added-after-foreach-begins.js
vendored
Normal file
49
test/built-ins/Map/prototype/forEach/iterates-values-added-after-foreach-begins.js
vendored
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
// 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.3.5
|
||||||
|
description: >
|
||||||
|
New keys are visited if created during forEach execution.
|
||||||
|
info: >
|
||||||
|
Map.prototype.forEach ( callbackfn [ , thisArg ] )
|
||||||
|
|
||||||
|
...
|
||||||
|
5. If thisArg was supplied, let T be thisArg; else let T be undefined.
|
||||||
|
6. Let entries be the List that is the value of M’s [[MapData]] internal slot.
|
||||||
|
7. Repeat for each Record {[[key]], [[value]]} e that is an element of
|
||||||
|
entries, in original key insertion order
|
||||||
|
a. If e.[[key]] is not empty, then
|
||||||
|
i. Let funcResult be Call(callbackfn, T, «e.[[value]], e.[[key]], M»).
|
||||||
|
ii. ReturnIfAbrupt(funcResult).
|
||||||
|
...
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var map = new Map();
|
||||||
|
map.set('foo', 0);
|
||||||
|
map.set('bar', 1);
|
||||||
|
|
||||||
|
var count = 0;
|
||||||
|
var results = [];
|
||||||
|
|
||||||
|
map.forEach(function(value, key) {
|
||||||
|
if (count === 0) {
|
||||||
|
map.set('baz', 2);
|
||||||
|
}
|
||||||
|
results.push({
|
||||||
|
value: value,
|
||||||
|
key: key
|
||||||
|
});
|
||||||
|
count++;
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.sameValue(count, 3);
|
||||||
|
assert.sameValue(map.size, 3);
|
||||||
|
|
||||||
|
assert.sameValue(results[0].key, 'foo');
|
||||||
|
assert.sameValue(results[0].value, 0);
|
||||||
|
|
||||||
|
assert.sameValue(results[1].key, 'bar');
|
||||||
|
assert.sameValue(results[1].value, 1);
|
||||||
|
|
||||||
|
assert.sameValue(results[2].key, 'baz');
|
||||||
|
assert.sameValue(results[2].value, 2);
|
50
test/built-ins/Map/prototype/forEach/iterates-values-deleted-then-readded.js
vendored
Normal file
50
test/built-ins/Map/prototype/forEach/iterates-values-deleted-then-readded.js
vendored
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
// 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.3.5
|
||||||
|
description: >
|
||||||
|
New keys are visited if created during forEach execution.
|
||||||
|
info: >
|
||||||
|
Map.prototype.forEach ( callbackfn [ , thisArg ] )
|
||||||
|
|
||||||
|
...
|
||||||
|
5. If thisArg was supplied, let T be thisArg; else let T be undefined.
|
||||||
|
6. Let entries be the List that is the value of M’s [[MapData]] internal slot.
|
||||||
|
7. Repeat for each Record {[[key]], [[value]]} e that is an element of
|
||||||
|
entries, in original key insertion order
|
||||||
|
a. If e.[[key]] is not empty, then
|
||||||
|
i. Let funcResult be Call(callbackfn, T, «e.[[value]], e.[[key]], M»).
|
||||||
|
ii. ReturnIfAbrupt(funcResult).
|
||||||
|
...
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var map = new Map();
|
||||||
|
map.set('foo', 0);
|
||||||
|
map.set('bar', 1);
|
||||||
|
|
||||||
|
var count = 0;
|
||||||
|
var results = [];
|
||||||
|
|
||||||
|
map.forEach(function(value, key) {
|
||||||
|
if (count === 0) {
|
||||||
|
map.delete('foo');
|
||||||
|
map.set('foo', 'baz');
|
||||||
|
}
|
||||||
|
results.push({
|
||||||
|
value: value,
|
||||||
|
key: key
|
||||||
|
});
|
||||||
|
count++;
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.sameValue(count, 3);
|
||||||
|
assert.sameValue(map.size, 2);
|
||||||
|
|
||||||
|
assert.sameValue(results[0].key, 'foo');
|
||||||
|
assert.sameValue(results[0].value, 0);
|
||||||
|
|
||||||
|
assert.sameValue(results[1].key, 'bar');
|
||||||
|
assert.sameValue(results[1].value, 1);
|
||||||
|
|
||||||
|
assert.sameValue(results[2].key, 'foo');
|
||||||
|
assert.sameValue(results[2].value, 'baz');
|
22
test/built-ins/Map/prototype/forEach/length.js
vendored
Normal file
22
test/built-ins/Map/prototype/forEach/length.js
vendored
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// 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.3.5
|
||||||
|
description: >
|
||||||
|
Map.prototype.forEach.length value and descriptor.
|
||||||
|
info: >
|
||||||
|
Map.prototype.forEach ( callbackfn [ , thisArg ] )
|
||||||
|
|
||||||
|
17 ECMAScript Standard Built-in Objects
|
||||||
|
|
||||||
|
includes: [propertyHelper.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
Map.prototype.forEach.length, 1,
|
||||||
|
'The value of `Map.prototype.forEach.length` is `1`'
|
||||||
|
);
|
||||||
|
|
||||||
|
verifyNotEnumerable(Map.prototype.forEach, 'length');
|
||||||
|
verifyNotWritable(Map.prototype.forEach, 'length');
|
||||||
|
verifyConfigurable(Map.prototype.forEach, 'length');
|
22
test/built-ins/Map/prototype/forEach/name.js
vendored
Normal file
22
test/built-ins/Map/prototype/forEach/name.js
vendored
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// 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.3.5
|
||||||
|
description: >
|
||||||
|
Map.prototype.forEach.name value and descriptor.
|
||||||
|
info: >
|
||||||
|
Map.prototype.forEach ( callbackfn [ , thisArg ] )
|
||||||
|
|
||||||
|
17 ECMAScript Standard Built-in Objects
|
||||||
|
|
||||||
|
includes: [propertyHelper.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
Map.prototype.forEach.name, 'forEach',
|
||||||
|
'The value of `Map.prototype.forEach.name` is `"forEach"`'
|
||||||
|
);
|
||||||
|
|
||||||
|
verifyNotEnumerable(Map.prototype.forEach, 'name');
|
||||||
|
verifyNotWritable(Map.prototype.forEach, 'name');
|
||||||
|
verifyConfigurable(Map.prototype.forEach, 'name');
|
27
test/built-ins/Map/prototype/forEach/return-undefined.js
vendored
Normal file
27
test/built-ins/Map/prototype/forEach/return-undefined.js
vendored
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
// 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.3.5
|
||||||
|
description: >
|
||||||
|
Returns undefined.
|
||||||
|
info: >
|
||||||
|
Map.prototype.forEach ( callbackfn [ , thisArg ] )
|
||||||
|
|
||||||
|
...
|
||||||
|
8. Return undefined.
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var map = new Map();
|
||||||
|
|
||||||
|
var result = map.forEach(function() {
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.sameValue(result, undefined, 'Empty map#forEach returns undefined');
|
||||||
|
|
||||||
|
map.set(1, 1);
|
||||||
|
result = map.forEach(function() {
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.sameValue(result, undefined, 'map#forEach returns undefined');
|
37
test/built-ins/Map/prototype/forEach/second-parameter-as-callback-context.js
vendored
Normal file
37
test/built-ins/Map/prototype/forEach/second-parameter-as-callback-context.js
vendored
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
// 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.3.5
|
||||||
|
description: >
|
||||||
|
If a thisArg parameter is provided, it will be used as the this value for each
|
||||||
|
invocation of callbackfn.
|
||||||
|
info: >
|
||||||
|
Map.prototype.forEach ( callbackfn [ , thisArg ] )
|
||||||
|
|
||||||
|
...
|
||||||
|
5. If thisArg was supplied, let T be thisArg; else let T be undefined.
|
||||||
|
6. Let entries be the List that is the value of M’s [[MapData]] internal slot.
|
||||||
|
7. Repeat for each Record {[[key]], [[value]]} e that is an element of
|
||||||
|
entries, in original key insertion order
|
||||||
|
a. If e.[[key]] is not empty, then
|
||||||
|
i. Let funcResult be Call(callbackfn, T, «e.[[value]], e.[[key]], M»).
|
||||||
|
...
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var expectedThis = {};
|
||||||
|
var _this = [];
|
||||||
|
|
||||||
|
var map = new Map();
|
||||||
|
map.set(0, 0);
|
||||||
|
map.set(1, 1);
|
||||||
|
map.set(2, 2);
|
||||||
|
|
||||||
|
var callback = function() {
|
||||||
|
_this.push(this);
|
||||||
|
};
|
||||||
|
|
||||||
|
map.forEach(callback, expectedThis);
|
||||||
|
|
||||||
|
assert.sameValue(_this[0], expectedThis);
|
||||||
|
assert.sameValue(_this[1], expectedThis);
|
||||||
|
assert.sameValue(_this[2], expectedThis);
|
43
test/built-ins/Map/prototype/forEach/this-not-object-throw.js
vendored
Normal file
43
test/built-ins/Map/prototype/forEach/this-not-object-throw.js
vendored
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
// 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.3.5
|
||||||
|
description: >
|
||||||
|
Throws a TypeError if `this` is not an Object.
|
||||||
|
info: >
|
||||||
|
Map.prototype.forEach ( callbackfn [ , thisArg ] )
|
||||||
|
|
||||||
|
1. Let M be the this value.
|
||||||
|
2. If Type(M) is not Object, throw a TypeError exception.
|
||||||
|
...
|
||||||
|
features: [Symbol]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.forEach.call(false, function() {});
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.forEach.call(1, function() {});
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.forEach.call('', function() {});
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.forEach.call(undefined, function() {});
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.forEach.call(null, function() {});
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.forEach.call(Symbol(), function() {});
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
var map = new Map();
|
||||||
|
map.forEach.call(false, function() {});
|
||||||
|
});
|
24
test/built-ins/Map/prototype/get/does-not-have-mapdata-internal-slot-set.js
vendored
Normal file
24
test/built-ins/Map/prototype/get/does-not-have-mapdata-internal-slot-set.js
vendored
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
// 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.3.6
|
||||||
|
description: >
|
||||||
|
Throws a TypeError if `this` is a Set object.
|
||||||
|
info: >
|
||||||
|
Map.prototype.get ( key )
|
||||||
|
|
||||||
|
...
|
||||||
|
3. If M does not have a [[MapData]] internal slot, throw a TypeError
|
||||||
|
exception.
|
||||||
|
...
|
||||||
|
features: [Set]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.get.call(new Set(), 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
var m = new Map();
|
||||||
|
m.get.call(new Set(), 1);
|
||||||
|
});
|
24
test/built-ins/Map/prototype/get/does-not-have-mapdata-internal-slot-weakmap.js
vendored
Normal file
24
test/built-ins/Map/prototype/get/does-not-have-mapdata-internal-slot-weakmap.js
vendored
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
// 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.3.6
|
||||||
|
description: >
|
||||||
|
Throws a TypeError if `this` is a WeakMap object.
|
||||||
|
info: >
|
||||||
|
Map.prototype.get ( key )
|
||||||
|
|
||||||
|
...
|
||||||
|
3. If M does not have a [[MapData]] internal slot, throw a TypeError
|
||||||
|
exception.
|
||||||
|
...
|
||||||
|
features: [WeakMap]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.get.call(new WeakMap(), 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
var m = new Map();
|
||||||
|
m.get.call(new WeakMap(), 1);
|
||||||
|
});
|
32
test/built-ins/Map/prototype/get/does-not-have-mapdata-internal-slot.js
vendored
Normal file
32
test/built-ins/Map/prototype/get/does-not-have-mapdata-internal-slot.js
vendored
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
// 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.3.6
|
||||||
|
description: >
|
||||||
|
Throws a TypeError if `this` object does not have a [[MapData]] internal slot.
|
||||||
|
info: >
|
||||||
|
Map.prototype.get ( key )
|
||||||
|
|
||||||
|
...
|
||||||
|
3. If M does not have a [[MapData]] internal slot, throw a TypeError
|
||||||
|
exception.
|
||||||
|
...
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var m = new Map();
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.get.call([], 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
m.get.call([], 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.get.call({}, 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
m.get.call({}, 1);
|
||||||
|
});
|
22
test/built-ins/Map/prototype/get/get.js
vendored
Normal file
22
test/built-ins/Map/prototype/get/get.js
vendored
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// 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.3.6
|
||||||
|
description: >
|
||||||
|
Property type and descriptor.
|
||||||
|
info: >
|
||||||
|
Map.prototype.get ( key )
|
||||||
|
|
||||||
|
17 ECMAScript Standard Built-in Objects
|
||||||
|
includes: [propertyHelper.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
typeof Map.prototype.get,
|
||||||
|
'function',
|
||||||
|
'`typeof Map.prototype.get` is `function`'
|
||||||
|
);
|
||||||
|
|
||||||
|
verifyNotEnumerable(Map.prototype, 'get');
|
||||||
|
verifyWritable(Map.prototype, 'get');
|
||||||
|
verifyConfigurable(Map.prototype, 'get');
|
22
test/built-ins/Map/prototype/get/length.js
vendored
Normal file
22
test/built-ins/Map/prototype/get/length.js
vendored
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// 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.3.6
|
||||||
|
description: >
|
||||||
|
Map.prototype.get.length value and descriptor.
|
||||||
|
info: >
|
||||||
|
Map.prototype.get ( key )
|
||||||
|
|
||||||
|
17 ECMAScript Standard Built-in Objects
|
||||||
|
|
||||||
|
includes: [propertyHelper.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
Map.prototype.get.length, 1,
|
||||||
|
'The value of `Map.prototype.get.length` is `1`'
|
||||||
|
);
|
||||||
|
|
||||||
|
verifyNotEnumerable(Map.prototype.get, 'length');
|
||||||
|
verifyNotWritable(Map.prototype.get, 'length');
|
||||||
|
verifyConfigurable(Map.prototype.get, 'length');
|
22
test/built-ins/Map/prototype/get/name.js
vendored
Normal file
22
test/built-ins/Map/prototype/get/name.js
vendored
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// 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.3.6
|
||||||
|
description: >
|
||||||
|
Map.prototype.get.name value and descriptor.
|
||||||
|
info: >
|
||||||
|
Map.prototype.get ( key )
|
||||||
|
|
||||||
|
17 ECMAScript Standard Built-in Objects
|
||||||
|
|
||||||
|
includes: [propertyHelper.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
Map.prototype.get.name, 'get',
|
||||||
|
'The value of `Map.prototype.get.name` is `"get"`'
|
||||||
|
);
|
||||||
|
|
||||||
|
verifyNotEnumerable(Map.prototype.get, 'name');
|
||||||
|
verifyNotWritable(Map.prototype.get, 'name');
|
||||||
|
verifyConfigurable(Map.prototype.get, 'name');
|
41
test/built-ins/Map/prototype/get/returns-undefined.js
vendored
Normal file
41
test/built-ins/Map/prototype/get/returns-undefined.js
vendored
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
// 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.3.6
|
||||||
|
description: >
|
||||||
|
Returns undefined when key is not on the map.
|
||||||
|
info: >
|
||||||
|
Map.prototype.get ( key )
|
||||||
|
|
||||||
|
4. Let entries be the List that is the value of M’s [[MapData]] internal slot.
|
||||||
|
5. Repeat for each Record {[[key]], [[value]]} p that is an element of
|
||||||
|
entries,
|
||||||
|
a. If p.[[key]] is not empty and SameValueZero(p.[[key]], key) is true,
|
||||||
|
return p.[[value]].
|
||||||
|
6. Return undefined.
|
||||||
|
...
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var map = new Map();
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
map.get('item'), undefined,
|
||||||
|
'returns undefined if key is not on the map'
|
||||||
|
);
|
||||||
|
|
||||||
|
map.set('item', 1);
|
||||||
|
map.set('another_item', 2);
|
||||||
|
map.delete('item');
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
map.get('item'), undefined,
|
||||||
|
'returns undefined if key was deleted'
|
||||||
|
);
|
||||||
|
|
||||||
|
map.set('item', 1);
|
||||||
|
map.clear();
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
map.get('item'), undefined,
|
||||||
|
'returns undefined after map is cleared'
|
||||||
|
);
|
48
test/built-ins/Map/prototype/get/returns-value-different-key-types.js
vendored
Normal file
48
test/built-ins/Map/prototype/get/returns-value-different-key-types.js
vendored
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
// 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.3.6
|
||||||
|
description: >
|
||||||
|
Returns the value from the specified key on different types.
|
||||||
|
info: >
|
||||||
|
Map.prototype.get ( key )
|
||||||
|
|
||||||
|
4. Let entries be the List that is the value of M’s [[MapData]] internal slot.
|
||||||
|
5. Repeat for each Record {[[key]], [[value]]} p that is an element of
|
||||||
|
entries,
|
||||||
|
a. If p.[[key]] is not empty and SameValueZero(p.[[key]], key) is true,
|
||||||
|
return p.[[value]].
|
||||||
|
...
|
||||||
|
features: [Symbol]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var map = new Map();
|
||||||
|
|
||||||
|
map.set('bar', 0);
|
||||||
|
assert.sameValue(map.get('bar'), 0);
|
||||||
|
|
||||||
|
map.set(1, 42);
|
||||||
|
assert.sameValue(map.get(1), 42);
|
||||||
|
|
||||||
|
map.set(NaN, 1);
|
||||||
|
assert.sameValue(map.get(NaN), 1);
|
||||||
|
|
||||||
|
var item = {};
|
||||||
|
map.set(item, 2);
|
||||||
|
assert.sameValue(map.get(item), 2);
|
||||||
|
|
||||||
|
item = [];
|
||||||
|
map.set(item, 3);
|
||||||
|
assert.sameValue(map.get(item), 3);
|
||||||
|
|
||||||
|
item = Symbol('item');
|
||||||
|
map.set(item, 4);
|
||||||
|
assert.sameValue(map.get(item), 4);
|
||||||
|
|
||||||
|
item = null;
|
||||||
|
map.set(item, 5);
|
||||||
|
assert.sameValue(map.get(item), 5);
|
||||||
|
|
||||||
|
item = undefined;
|
||||||
|
map.set(item, 6);
|
||||||
|
assert.sameValue(map.get(item), 6);
|
25
test/built-ins/Map/prototype/get/returns-value-normalized-zero-key.js
vendored
Normal file
25
test/built-ins/Map/prototype/get/returns-value-normalized-zero-key.js
vendored
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
// 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.3.6
|
||||||
|
description: >
|
||||||
|
-0 and +0 are normalized to +0;
|
||||||
|
info: >
|
||||||
|
Map.prototype.get ( key )
|
||||||
|
|
||||||
|
4. Let entries be the List that is the value of M’s [[MapData]] internal slot.
|
||||||
|
5. Repeat for each Record {[[key]], [[value]]} p that is an element of
|
||||||
|
entries,
|
||||||
|
a. If p.[[key]] is not empty and SameValueZero(p.[[key]], key) is true,
|
||||||
|
return p.[[value]].
|
||||||
|
...
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var map = new Map();
|
||||||
|
|
||||||
|
map.set(+0, 42);
|
||||||
|
assert.sameValue(map.get(-0), 42);
|
||||||
|
|
||||||
|
map = new Map();
|
||||||
|
map.set(-0, 43);
|
||||||
|
assert.sameValue(map.get(+0), 43);
|
43
test/built-ins/Map/prototype/get/this-not-object-throw.js
vendored
Normal file
43
test/built-ins/Map/prototype/get/this-not-object-throw.js
vendored
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
// 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.3.6
|
||||||
|
description: >
|
||||||
|
Throws a TypeError if `this` is not an Object.
|
||||||
|
info: >
|
||||||
|
Map.prototype.get ( key )
|
||||||
|
|
||||||
|
1. Let M be the this value.
|
||||||
|
2. If Type(M) is not Object, throw a TypeError exception.
|
||||||
|
...
|
||||||
|
features: [Symbol]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.get.call(false, 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.get.call(1, 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.get.call('', 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.get.call(undefined, 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.get.call(null, 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.get.call(Symbol(), 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
var map = new Map();
|
||||||
|
map.get.call(false, 1);
|
||||||
|
});
|
24
test/built-ins/Map/prototype/has/does-not-have-mapdata-internal-slot-set.js
vendored
Normal file
24
test/built-ins/Map/prototype/has/does-not-have-mapdata-internal-slot-set.js
vendored
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
// 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.3.7
|
||||||
|
description: >
|
||||||
|
Throws a TypeError if `this` is a Set object.
|
||||||
|
info: >
|
||||||
|
Map.prototype.has ( key )
|
||||||
|
|
||||||
|
...
|
||||||
|
3. If M does not have a [[MapData]] internal slot, throw a TypeError
|
||||||
|
exception.
|
||||||
|
...
|
||||||
|
features: [Set]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.has.call(new Set(), 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
var m = new Map();
|
||||||
|
m.has.call(new Set(), 1);
|
||||||
|
});
|
24
test/built-ins/Map/prototype/has/does-not-have-mapdata-internal-slot-weakmap.js
vendored
Normal file
24
test/built-ins/Map/prototype/has/does-not-have-mapdata-internal-slot-weakmap.js
vendored
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
// 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.3.7
|
||||||
|
description: >
|
||||||
|
Throws a TypeError if `this` is a WeakMap object.
|
||||||
|
info: >
|
||||||
|
Map.prototype.has ( key )
|
||||||
|
|
||||||
|
...
|
||||||
|
3. If M does not have a [[MapData]] internal slot, throw a TypeError
|
||||||
|
exception.
|
||||||
|
...
|
||||||
|
features: [WeakMap]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.has.call(new WeakMap(), 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
var m = new Map();
|
||||||
|
m.has.call(new WeakMap(), 1);
|
||||||
|
});
|
32
test/built-ins/Map/prototype/has/does-not-have-mapdata-internal-slot.js
vendored
Normal file
32
test/built-ins/Map/prototype/has/does-not-have-mapdata-internal-slot.js
vendored
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
// 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.3.7
|
||||||
|
description: >
|
||||||
|
Throws a TypeError if `this` object does not have a [[MapData]] internal slot.
|
||||||
|
info: >
|
||||||
|
Map.prototype.has ( key )
|
||||||
|
|
||||||
|
...
|
||||||
|
3. If M does not have a [[MapData]] internal slot, throw a TypeError
|
||||||
|
exception.
|
||||||
|
...
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var m = new Map();
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.has.call([], 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
m.has.call([], 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.has.call({}, 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
m.has.call({}, 1);
|
||||||
|
});
|
22
test/built-ins/Map/prototype/has/has.js
vendored
Normal file
22
test/built-ins/Map/prototype/has/has.js
vendored
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// 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.3.7
|
||||||
|
description: >
|
||||||
|
Property type and descriptor.
|
||||||
|
info: >
|
||||||
|
Map.prototype.has ( key )
|
||||||
|
|
||||||
|
17 ECMAScript Standard Built-in Objects
|
||||||
|
includes: [propertyHelper.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
typeof Map.prototype.has,
|
||||||
|
'function',
|
||||||
|
'`typeof Map.prototype.has` is `function`'
|
||||||
|
);
|
||||||
|
|
||||||
|
verifyNotEnumerable(Map.prototype, 'has');
|
||||||
|
verifyWritable(Map.prototype, 'has');
|
||||||
|
verifyConfigurable(Map.prototype, 'has');
|
22
test/built-ins/Map/prototype/has/length.js
vendored
Normal file
22
test/built-ins/Map/prototype/has/length.js
vendored
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// 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.3.7
|
||||||
|
description: >
|
||||||
|
Map.prototype.has.length value and descriptor.
|
||||||
|
info: >
|
||||||
|
Map.prototype.has ( key )
|
||||||
|
|
||||||
|
17 ECMAScript Standard Built-in Objects
|
||||||
|
|
||||||
|
includes: [propertyHelper.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
Map.prototype.has.length, 1,
|
||||||
|
'The value of `Map.prototype.has.length` is `1`'
|
||||||
|
);
|
||||||
|
|
||||||
|
verifyNotEnumerable(Map.prototype.has, 'length');
|
||||||
|
verifyNotWritable(Map.prototype.has, 'length');
|
||||||
|
verifyConfigurable(Map.prototype.has, 'length');
|
22
test/built-ins/Map/prototype/has/name.js
vendored
Normal file
22
test/built-ins/Map/prototype/has/name.js
vendored
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// 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.3.7
|
||||||
|
description: >
|
||||||
|
Map.prototype.has.name value and descriptor.
|
||||||
|
info: >
|
||||||
|
Map.prototype.has ( key )
|
||||||
|
|
||||||
|
17 ECMAScript Standard Built-in Objects
|
||||||
|
|
||||||
|
includes: [propertyHelper.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
Map.prototype.has.name, 'has',
|
||||||
|
'The value of `Map.prototype.has.name` is `"has"`'
|
||||||
|
);
|
||||||
|
|
||||||
|
verifyNotEnumerable(Map.prototype.has, 'name');
|
||||||
|
verifyNotWritable(Map.prototype.has, 'name');
|
||||||
|
verifyConfigurable(Map.prototype.has, 'name');
|
30
test/built-ins/Map/prototype/has/normalizes-zero-key.js
vendored
Normal file
30
test/built-ins/Map/prototype/has/normalizes-zero-key.js
vendored
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
// 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.3.7
|
||||||
|
description: >
|
||||||
|
-0 and +0 are normalized to +0;
|
||||||
|
info: >
|
||||||
|
Map.prototype.has ( key )
|
||||||
|
|
||||||
|
5. Repeat for each Record {[[key]], [[value]]} p that is an element of
|
||||||
|
entries,
|
||||||
|
a. If p.[[key]] is not empty and SameValueZero(p.[[key]], key) is true,
|
||||||
|
return true.
|
||||||
|
...
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var map = new Map();
|
||||||
|
|
||||||
|
assert.sameValue(map.has(-0), false);
|
||||||
|
assert.sameValue(map.has(+0), false);
|
||||||
|
|
||||||
|
map.set(-0, 42);
|
||||||
|
assert.sameValue(map.has(-0), true);
|
||||||
|
assert.sameValue(map.has(+0), true);
|
||||||
|
|
||||||
|
map.clear();
|
||||||
|
|
||||||
|
map.set(+0, 42);
|
||||||
|
assert.sameValue(map.has(-0), true);
|
||||||
|
assert.sameValue(map.has(+0), true);
|
29
test/built-ins/Map/prototype/has/return-false-different-key-types.js
vendored
Normal file
29
test/built-ins/Map/prototype/has/return-false-different-key-types.js
vendored
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
// 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.3.7
|
||||||
|
description: >
|
||||||
|
Returns true for existing keys, using different key types.
|
||||||
|
info: >
|
||||||
|
Map.prototype.has ( key )
|
||||||
|
|
||||||
|
5. Repeat for each Record {[[key]], [[value]]} p that is an element of
|
||||||
|
entries,
|
||||||
|
i. If p.[[key]] is not empty and SameValueZero(p.[[key]], key) is true,
|
||||||
|
return true.
|
||||||
|
...
|
||||||
|
features: [Symbol]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var map = new Map();
|
||||||
|
|
||||||
|
assert.sameValue(map.has('str'), false);
|
||||||
|
assert.sameValue(map.has(1), false);
|
||||||
|
assert.sameValue(map.has(NaN), false);
|
||||||
|
assert.sameValue(map.has(true), false);
|
||||||
|
assert.sameValue(map.has(false), false);
|
||||||
|
assert.sameValue(map.has({}), false);
|
||||||
|
assert.sameValue(map.has([]), false);
|
||||||
|
assert.sameValue(map.has(Symbol()), false);
|
||||||
|
assert.sameValue(map.has(null), false);
|
||||||
|
assert.sameValue(map.has(undefined), false);
|
44
test/built-ins/Map/prototype/has/return-true-different-key-types.js
vendored
Normal file
44
test/built-ins/Map/prototype/has/return-true-different-key-types.js
vendored
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
// 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.3.7
|
||||||
|
description: >
|
||||||
|
Returns true for existing keys, using different key types.
|
||||||
|
info: >
|
||||||
|
Map.prototype.has ( key )
|
||||||
|
|
||||||
|
5. Repeat for each Record {[[key]], [[value]]} p that is an element of
|
||||||
|
entries,
|
||||||
|
i. If p.[[key]] is not empty and SameValueZero(p.[[key]], key) is true,
|
||||||
|
return true.
|
||||||
|
...
|
||||||
|
features: [Symbol]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var map = new Map();
|
||||||
|
|
||||||
|
var obj = {};
|
||||||
|
var arr = [];
|
||||||
|
var symb = Symbol();
|
||||||
|
|
||||||
|
map.set('str', undefined);
|
||||||
|
map.set(1, undefined);
|
||||||
|
map.set(NaN, undefined);
|
||||||
|
map.set(true, undefined);
|
||||||
|
map.set(false, undefined);
|
||||||
|
map.set(obj, undefined);
|
||||||
|
map.set(arr, undefined);
|
||||||
|
map.set(symb, undefined);
|
||||||
|
map.set(null, undefined);
|
||||||
|
map.set(undefined, undefined);
|
||||||
|
|
||||||
|
assert.sameValue(map.has('str'), true);
|
||||||
|
assert.sameValue(map.has(1), true);
|
||||||
|
assert.sameValue(map.has(NaN), true);
|
||||||
|
assert.sameValue(map.has(true), true);
|
||||||
|
assert.sameValue(map.has(false), true);
|
||||||
|
assert.sameValue(map.has(obj), true);
|
||||||
|
assert.sameValue(map.has(arr), true);
|
||||||
|
assert.sameValue(map.has(symb), true);
|
||||||
|
assert.sameValue(map.has(null), true);
|
||||||
|
assert.sameValue(map.has(undefined), true);
|
43
test/built-ins/Map/prototype/has/this-not-object-throw.js
vendored
Normal file
43
test/built-ins/Map/prototype/has/this-not-object-throw.js
vendored
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
// 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.3.7
|
||||||
|
description: >
|
||||||
|
Throws a TypeError if `this` is not an Object.
|
||||||
|
info: >
|
||||||
|
Map.prototype.has ( key )
|
||||||
|
|
||||||
|
1. Let M be the this value.
|
||||||
|
2. If Type(M) is not Object, throw a TypeError exception.
|
||||||
|
...
|
||||||
|
features: [Symbol]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.has.call(false, 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.has.call(1, 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.has.call('', 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.has.call(undefined, 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.has.call(null, 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.has.call(Symbol(), 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
var map = new Map();
|
||||||
|
map.has.call(false, 1);
|
||||||
|
});
|
13
test/built-ins/Map/prototype/keys-no-map-data.js
vendored
13
test/built-ins/Map/prototype/keys-no-map-data.js
vendored
@ -1,13 +0,0 @@
|
|||||||
// Copyright (C) 2014 the V8 project authors. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
description: >
|
|
||||||
If the context does not have a [[MapData]] internal slot, throw a
|
|
||||||
TypeError exception as per 23.1.5.1.
|
|
||||||
es6id: 23.1.3.8
|
|
||||||
---*/
|
|
||||||
|
|
||||||
assert.throws(TypeError, function() {
|
|
||||||
Map.prototype.keys.call({});
|
|
||||||
});
|
|
29
test/built-ins/Map/prototype/keys/does-not-have-mapdata-internal-slot-set.js
vendored
Normal file
29
test/built-ins/Map/prototype/keys/does-not-have-mapdata-internal-slot-set.js
vendored
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
// 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.3.8
|
||||||
|
description: >
|
||||||
|
Throws a TypeError if `this` is a Set object.
|
||||||
|
info: >
|
||||||
|
Map.prototype.keys ()
|
||||||
|
|
||||||
|
1. Let M be the this value.
|
||||||
|
2. Return CreateMapIterator(M, "key").
|
||||||
|
|
||||||
|
23.1.5.1 CreateMapIterator Abstract Operation
|
||||||
|
|
||||||
|
...
|
||||||
|
2. If map does not have a [[MapData]] internal slot, throw a TypeError
|
||||||
|
exception.
|
||||||
|
...
|
||||||
|
features: [Set]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.keys.call(new Set());
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
var m = new Map();
|
||||||
|
m.keys.call(new Set());
|
||||||
|
});
|
29
test/built-ins/Map/prototype/keys/does-not-have-mapdata-internal-slot-weakmap.js
vendored
Normal file
29
test/built-ins/Map/prototype/keys/does-not-have-mapdata-internal-slot-weakmap.js
vendored
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
// 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.3.8
|
||||||
|
description: >
|
||||||
|
Throws a TypeError if `this` is a WeakMap object.
|
||||||
|
info: >
|
||||||
|
Map.prototype.keys ()
|
||||||
|
|
||||||
|
1. Let M be the this value.
|
||||||
|
2. Return CreateMapIterator(M, "key").
|
||||||
|
|
||||||
|
23.1.5.1 CreateMapIterator Abstract Operation
|
||||||
|
|
||||||
|
...
|
||||||
|
2. If map does not have a [[MapData]] internal slot, throw a TypeError
|
||||||
|
exception.
|
||||||
|
...
|
||||||
|
features: [WeakMap]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.keys.call(new WeakMap());
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
var m = new Map();
|
||||||
|
m.keys.call(new WeakMap());
|
||||||
|
});
|
38
test/built-ins/Map/prototype/keys/does-not-have-mapdata-internal-slot.js
vendored
Normal file
38
test/built-ins/Map/prototype/keys/does-not-have-mapdata-internal-slot.js
vendored
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
// 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.3.8
|
||||||
|
description: >
|
||||||
|
Throws a TypeError if `this` object does not have a [[MapData]] internal slot.
|
||||||
|
info: >
|
||||||
|
Map.prototype.keys ()
|
||||||
|
|
||||||
|
1. Let M be the this value.
|
||||||
|
2. Return CreateMapIterator(M, "key").
|
||||||
|
|
||||||
|
23.1.5.1 CreateMapIterator Abstract Operation
|
||||||
|
|
||||||
|
...
|
||||||
|
2. If map does not have a [[MapData]] internal slot, throw a TypeError
|
||||||
|
exception.
|
||||||
|
...
|
||||||
|
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var m = new Map();
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.keys.call([]);
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
m.keys.call([]);
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Map.prototype.keys.call({});
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
m.keys.call({});
|
||||||
|
});
|
22
test/built-ins/Map/prototype/keys/keys.js
vendored
Normal file
22
test/built-ins/Map/prototype/keys/keys.js
vendored
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// 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.3.8
|
||||||
|
description: >
|
||||||
|
Property type and descriptor.
|
||||||
|
info: >
|
||||||
|
Map.prototype.keys ()
|
||||||
|
|
||||||
|
17 ECMAScript Standard Built-in Objects
|
||||||
|
includes: [propertyHelper.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
typeof Map.prototype.keys,
|
||||||
|
'function',
|
||||||
|
'`typeof Map.prototype.keys` is `function`'
|
||||||
|
);
|
||||||
|
|
||||||
|
verifyNotEnumerable(Map.prototype, 'keys');
|
||||||
|
verifyWritable(Map.prototype, 'keys');
|
||||||
|
verifyConfigurable(Map.prototype, 'keys');
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user