summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Map/prototype/get/returns-undefined.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/built-ins/Map/prototype/get/returns-undefined.js')
-rw-r--r--js/src/tests/test262/built-ins/Map/prototype/get/returns-undefined.js43
1 files changed, 43 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Map/prototype/get/returns-undefined.js b/js/src/tests/test262/built-ins/Map/prototype/get/returns-undefined.js
new file mode 100644
index 0000000000..9af7162993
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Map/prototype/get/returns-undefined.js
@@ -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.
+/*---
+esid: sec-map.prototype.get
+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'
+);
+
+reportCompare(0, 0);