Spaces:
Runtime error
Runtime error
File size: 2,587 Bytes
b5ea024 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
"use strict";
var iteratorSymbol = require("es6-symbol").iterator;
module.exports = function (T) {
return {
"Values": function (a) {
var x = ["raz", "dwa", "trzy", "cztery", "pięć", "sześć"], it;
it = new T(x);
a(it[iteratorSymbol](), it, "@@iterator");
a.deep(it.next(), { done: false, value: "raz" }, "#1");
a.deep(it.next(), { done: false, value: "dwa" }, "#2");
x.splice(1, 0, "elo");
a.deep(it.next(), { done: false, value: "dwa" }, "Insert");
a.deep(it.next(), { done: false, value: "trzy" }, "#3");
a.deep(it.next(), { done: false, value: "cztery" }, "#4");
x.pop();
a.deep(it.next(), { done: false, value: "pięć" }, "#5");
a.deep(it.next(), { done: true, value: undefined }, "End");
},
"Keys & Values": function (a) {
var x = ["raz", "dwa", "trzy", "cztery", "pięć", "sześć"], it;
it = new T(x, "key+value");
a(it[iteratorSymbol](), it, "@@iterator");
a.deep(it.next(), { done: false, value: [0, "raz"] }, "#1");
a.deep(it.next(), { done: false, value: [1, "dwa"] }, "#2");
x.splice(1, 0, "elo");
a.deep(it.next(), { done: false, value: [2, "dwa"] }, "Insert");
a.deep(it.next(), { done: false, value: [3, "trzy"] }, "#3");
a.deep(it.next(), { done: false, value: [4, "cztery"] }, "#4");
x.pop();
a.deep(it.next(), { done: false, value: [5, "pięć"] }, "#5");
a.deep(it.next(), { done: true, value: undefined }, "End");
},
"Keys": function (a) {
var x = ["raz", "dwa", "trzy", "cztery", "pięć", "sześć"], it;
it = new T(x, "key");
a(it[iteratorSymbol](), it, "@@iterator");
a.deep(it.next(), { done: false, value: 0 }, "#1");
a.deep(it.next(), { done: false, value: 1 }, "#2");
x.splice(1, 0, "elo");
a.deep(it.next(), { done: false, value: 2 }, "Insert");
a.deep(it.next(), { done: false, value: 3 }, "#3");
a.deep(it.next(), { done: false, value: 4 }, "#4");
x.pop();
a.deep(it.next(), { done: false, value: 5 }, "#5");
a.deep(it.next(), { done: true, value: undefined }, "End");
},
"Sparse": function (a) {
var x = new Array(6), it;
x[2] = "raz";
x[4] = "dwa";
it = new T(x);
a.deep(it.next(), { done: false, value: undefined }, "#1");
a.deep(it.next(), { done: false, value: undefined }, "#2");
a.deep(it.next(), { done: false, value: "raz" }, "#3");
a.deep(it.next(), { done: false, value: undefined }, "#4");
a.deep(it.next(), { done: false, value: "dwa" }, "#5");
a.deep(it.next(), { done: false, value: undefined }, "#6");
a.deep(it.next(), { done: true, value: undefined }, "End");
}
};
};
|