unify.js
2.75 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
'use strict';
var ee = require('../');
module.exports = function (t) {
return {
"": function (a) {
var x = {}, y = {}, z = {}, count, count2, count3;
ee(x);
ee(y);
ee(z);
count = 0;
count2 = 0;
count3 = 0;
x.on('foo', function () { ++count; });
y.on('foo', function () { ++count2; });
z.on('foo', function () { ++count3; });
x.emit('foo');
a(count, 1, "Pre unify, x");
a(count2, 0, "Pre unify, y");
a(count3, 0, "Pre unify, z");
t(x, y);
a(x.__ee__, y.__ee__, "Post unify y");
x.emit('foo');
a(count, 2, "Post unify, x");
a(count2, 1, "Post unify, y");
a(count3, 0, "Post unify, z");
y.emit('foo');
a(count, 3, "Post unify, on y, x");
a(count2, 2, "Post unify, on y, y");
a(count3, 0, "Post unify, on y, z");
t(x, z);
a(x.__ee__, x.__ee__, "Post unify z");
x.emit('foo');
a(count, 4, "Post unify z, x");
a(count2, 3, "Post unify z, y");
a(count3, 1, "Post unify z, z");
},
"On empty": function (a) {
var x = {}, y = {}, z = {}, count, count2, count3;
ee(x);
ee(y);
ee(z);
count = 0;
count2 = 0;
count3 = 0;
y.on('foo', function () { ++count2; });
x.emit('foo');
a(count, 0, "Pre unify, x");
a(count2, 0, "Pre unify, y");
a(count3, 0, "Pre unify, z");
t(x, y);
a(x.__ee__, y.__ee__, "Post unify y");
x.on('foo', function () { ++count; });
x.emit('foo');
a(count, 1, "Post unify, x");
a(count2, 1, "Post unify, y");
a(count3, 0, "Post unify, z");
y.emit('foo');
a(count, 2, "Post unify, on y, x");
a(count2, 2, "Post unify, on y, y");
a(count3, 0, "Post unify, on y, z");
t(x, z);
a(x.__ee__, z.__ee__, "Post unify z");
z.on('foo', function () { ++count3; });
x.emit('foo');
a(count, 3, "Post unify z, x");
a(count2, 3, "Post unify z, y");
a(count3, 1, "Post unify z, z");
},
Many: function (a) {
var x = {}, y = {}, z = {}, count, count2, count3;
ee(x);
ee(y);
ee(z);
count = 0;
count2 = 0;
count3 = 0;
x.on('foo', function () { ++count; });
y.on('foo', function () { ++count2; });
y.on('foo', function () { ++count2; });
z.on('foo', function () { ++count3; });
x.emit('foo');
a(count, 1, "Pre unify, x");
a(count2, 0, "Pre unify, y");
a(count3, 0, "Pre unify, z");
t(x, y);
a(x.__ee__, y.__ee__, "Post unify y");
x.emit('foo');
a(count, 2, "Post unify, x");
a(count2, 2, "Post unify, y");
a(count3, 0, "Post unify, z");
y.emit('foo');
a(count, 3, "Post unify, on y, x");
a(count2, 4, "Post unify, on y, y");
a(count3, 0, "Post unify, on y, z");
t(x, z);
a(x.__ee__, x.__ee__, "Post unify z");
x.emit('foo');
a(count, 4, "Post unify z, x");
a(count2, 6, "Post unify z, y");
a(count3, 1, "Post unify z, z");
}
};
};