michael@0: // The argument to Map can be a generator. michael@0: michael@0: var done = false; michael@0: function data(n) { michael@0: var s = ''; michael@0: for (var i = 0; i < n; i++) { michael@0: yield [s, i]; michael@0: s += '.'; michael@0: } michael@0: done = true; michael@0: } michael@0: michael@0: var m = Map(data(50)); michael@0: assertEq(done, true); // the constructor consumes the argument michael@0: assertEq(m.size, 50); michael@0: assertEq(m.get(""), 0); michael@0: assertEq(m.get("....."), 5); michael@0: assertEq(m.get(Array(49+1).join(".")), 49); michael@0: assertEq(m.has(undefined), false);