3 var aFrom = require('es5-ext/array/from')
4 , getIterator = require('es6-iterator/get')
5 , toArray = require('es5-ext/array/to-array');
7 module.exports = function (T, a) {
8 var arr = [['raz', 'one'], ['dwa', 'two'], ['trzy', 'three']]
9 , map = new T(arr), x = 'other', y = 'other2'
12 a(map instanceof T, true, "Map");
13 a(map.size, 3, "Size");
14 a(map.get('raz'), 'one', "Get: contained");
15 a(map.get(x), undefined, "Get: not contained");
16 a(map.has('raz'), true, "Has: true");
17 a(map.has(x), false, "Has: false");
18 a(map.set(x, y), map, "Add: return");
19 a(map.has(x), true, "Add");
20 a(map.size, 4, "Add: Size");
22 a(map.get('dwa'), x, "Overwrite: get");
23 a(map.size, 4, "Overwrite: size");
25 a(map.delete('else'), false, "Delete: false");
29 map.forEach(function () {
30 result.push(aFrom(arguments));
31 a(this, y, "ForEach: Context: #" + i);
34 a.deep(result.sort(function (a, b) {
35 return String([a[1], a[0]]).localeCompare([b[1], b[0]]);
36 }), arr.sort().map(function (val) { return [val[1], val[0], map]; }),
37 "ForEach: Arguments");
39 a.deep(toArray(map.entries()).sort(), [['dwa', x], ['trzy', 'three'],
40 [x, y], ['raz', 'one']].sort(), "Entries");
41 a.deep(toArray(map.keys()).sort(), ['dwa', 'trzy', x, 'raz'].sort(),
43 a.deep(toArray(map.values()).sort(), [x, 'three', y, 'one'].sort(),
45 a.deep(toArray(getIterator(map)).sort(), [['dwa', x], ['trzy', 'three'],
46 [x, y], ['raz', 'one']].sort(),
50 a(map.size, 0, "Clear: size");
51 a(map.has('trzy'), false, "Clear: has");
52 a.deep(toArray(map.values()), [], "Clear: Values");