3 module.exports = function (t, a) {
4 var x = t(), y, count, count2, count3, count4, test, listener1, listener2;
10 x.once('foo', function (a1, a2, a3) {
11 a(this, x, test + "Context");
12 a.deep([a1, a2, a3], ['foo', x, 15], test + "Arguments");
17 a(count, 0, test + "Not invoked on other event");
18 x.emit('foo', 'foo', x, 15);
19 a(count, 1, test + "Emitted");
21 a(count, 1, test + "Emitted once");
25 x.on('foo', listener1 = function (a1, a2, a3) {
26 a(this, x, test + "Context");
27 a.deep([a1, a2, a3], ['foo', x, 15], test + "Arguments");
31 x.once('foo', listener2 = function (a1, a2, a3) {
32 a(this, x, test + "Context");
33 a.deep([a1, a2, a3], ['foo', x, 15], test + "Arguments");
38 a(count, 0, test + "Not invoked on other event");
39 x.emit('foo', 'foo', x, 15);
40 a(count, 1, test + "Emitted");
41 x.emit('foo', 'foo', x, 15);
42 a(count, 2, test + "Emitted twice");
43 a(count2, 1, test + "Emitted once");
44 x.off('foo', listener1);
46 a(count, 2, test + "Not emitter after off");
49 x.once('foo', listener1 = function () { ++count; });
51 x.off('foo', listener1);
53 a(count, 0, "Once Off: Not emitted");
56 x.on('foo', listener2 = function () {});
57 x.once('foo', listener1 = function () { ++count; });
59 x.off('foo', listener1);
61 a(count, 0, "Once Off (multi): Not emitted");
62 x.off('foo', listener2);
64 test = "Prototype Share: ";
72 x.on('foo', function () {
75 y.on('foo', function () {
78 x.once('foo', function () {
81 y.once('foo', function () {
85 a(count, 1, test + "x on count");
86 a(count2, 0, test + "y on count");
87 a(count3, 1, test + "x once count");
88 a(count4, 0, test + "y once count");
91 a(count, 1, test + "x on count");
92 a(count2, 1, test + "y on count");
93 a(count3, 1, test + "x once count");
94 a(count4, 1, test + "y once count");
97 a(count, 2, test + "x on count");
98 a(count2, 1, test + "y on count");
99 a(count3, 1, test + "x once count");
100 a(count4, 1, test + "y once count");
103 a(count, 2, test + "x on count");
104 a(count2, 2, test + "y on count");
105 a(count3, 1, test + "x once count");
106 a(count4, 1, test + "y once count");