]> git.r.bdr.sh - rbdr/dotfiles/blob - atom/packages/vim-mode/node_modules/grim/node_modules/emissary/node_modules/es6-weak-map/node_modules/es6-iterator/test/index.js
ea3621adfebeb513a36a9430f1754d0f173e7854
[rbdr/dotfiles] / atom / packages / vim-mode / node_modules / grim / node_modules / emissary / node_modules / es6-weak-map / node_modules / es6-iterator / test / index.js
1 'use strict';
2
3 var ee = require('event-emitter')
4 , iteratorSymbol = require('es6-symbol').iterator;
5
6 module.exports = function (T) {
7 return {
8 "": function (a) {
9 var x = ['raz', 'dwa', 'trzy', 'cztery', 'pięć'], it, y, z;
10
11 it = new T(x);
12 a(it[iteratorSymbol](), it, "@@iterator");
13 y = it.next();
14 a.deep(y, { done: false, value: 'raz' }, "#1");
15 z = it.next();
16 a.not(y, z, "Recreate result");
17 a.deep(z, { done: false, value: 'dwa' }, "#2");
18 a.deep(it.next(), { done: false, value: 'trzy' }, "#3");
19 a.deep(it.next(), { done: false, value: 'cztery' }, "#4");
20 a.deep(it.next(), { done: false, value: 'pięć' }, "#5");
21 a.deep(y = it.next(), { done: true, value: undefined }, "End");
22 a.not(y, it.next(), "Recreate result on dead");
23 },
24 Emited: function (a) {
25 var x = ['raz', 'dwa', 'trzy', 'cztery', 'pięć'], y, it;
26
27 y = ee();
28 it = new T(x, y);
29 a.deep(it.next(), { done: false, value: 'raz' }, "#1");
30 a.deep(it.next(), { done: false, value: 'dwa' }, "#2");
31 y.emit('_add', x.push('sześć') - 1);
32 a.deep(it.next(), { done: false, value: 'trzy' }, "#3");
33 x.splice(1, 0, 'półtora');
34 y.emit('_add', 1);
35 a.deep(it.next(), { done: false, value: 'półtora' }, "Insert");
36 x.splice(5, 1);
37 y.emit('_delete', 5);
38 a.deep(it.next(), { done: false, value: 'cztery' }, "#4");
39 a.deep(it.next(), { done: false, value: 'sześć' }, "#5");
40 a.deep(it.next(), { done: true, value: undefined }, "End");
41 },
42 "Emited #2": function (a) {
43 var x = ['raz', 'dwa', 'trzy', 'cztery', 'pięć', 'sześć'], y, it;
44
45 y = ee();
46 it = new T(x, y);
47 a.deep(it.next(), { done: false, value: 'raz' }, "#1");
48 a.deep(it.next(), { done: false, value: 'dwa' }, "#2");
49 x.splice(1, 0, 'półtora');
50 y.emit('_add', 1);
51 x.splice(1, 0, '1.25');
52 y.emit('_add', 1);
53 x.splice(0, 1);
54 y.emit('_delete', 0);
55 a.deep(it.next(), { done: false, value: 'półtora' }, "Insert");
56 a.deep(it.next(), { done: false, value: '1.25' }, "Insert #2");
57 a.deep(it.next(), { done: false, value: 'trzy' }, "#3");
58 a.deep(it.next(), { done: false, value: 'cztery' }, "#4");
59 x.splice(5, 1);
60 y.emit('_delete', 5);
61 a.deep(it.next(), { done: false, value: 'sześć' }, "#5");
62 a.deep(it.next(), { done: true, value: undefined }, "End");
63 },
64 "Emited: Clear #1": function (a) {
65 var x = ['raz', 'dwa', 'trzy', 'cztery', 'pięć', 'sześć'], y, it;
66
67 y = ee();
68 it = new T(x, y);
69 a.deep(it.next(), { done: false, value: 'raz' }, "#1");
70 a.deep(it.next(), { done: false, value: 'dwa' }, "#2");
71 x.length = 0;
72 y.emit('_clear');
73 a.deep(it.next(), { done: true, value: undefined }, "End");
74 },
75 "Emited: Clear #2": function (a) {
76 var x = ['raz', 'dwa', 'trzy', 'cztery', 'pięć', 'sześć'], y, it;
77
78 y = ee();
79 it = new T(x, y);
80 a.deep(it.next(), { done: false, value: 'raz' }, "#1");
81 a.deep(it.next(), { done: false, value: 'dwa' }, "#2");
82 x.length = 0;
83 y.emit('_clear');
84 x.push('foo');
85 x.push('bar');
86 a.deep(it.next(), { done: false, value: 'foo' }, "#3");
87 a.deep(it.next(), { done: false, value: 'bar' }, "#4");
88 x.splice(1, 0, 'półtora');
89 y.emit('_add', 1);
90 x.splice(1, 0, '1.25');
91 y.emit('_add', 1);
92 x.splice(0, 1);
93 y.emit('_delete', 0);
94 a.deep(it.next(), { done: false, value: 'półtora' }, "Insert");
95 a.deep(it.next(), { done: false, value: '1.25' }, "Insert #2");
96 a.deep(it.next(), { done: true, value: undefined }, "End");
97 }
98 };
99 };