discombobulator 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/test/articulation.mjs +0 -66
- package/src/test/articulationset.mjs +0 -43
- package/src/test/binaryoperator.mjs +0 -210
- package/src/test/chord.mjs +0 -292
- package/src/test/concolour.mjs +0 -70
- package/src/test/difference.mjs +0 -492
- package/src/test/element.mjs +0 -66
- package/src/test/group.mjs +0 -79
- package/src/test/groupset.mjs +0 -43
- package/src/test/instrument.mjs +0 -66
- package/src/test/instrumentset.mjs +0 -43
- package/src/test/intersection.mjs +0 -493
- package/src/test/irregulargroupset.mjs +0 -461
- package/src/test/note.mjs +0 -367
- package/src/test/noteset.mjs +0 -43
- package/src/test/operator.mjs +0 -63
- package/src/test/pattern.mjs +0 -113
- package/src/test/patternset.mjs +0 -43
- package/src/test/patternsource.mjs +0 -43
- package/src/test/regulargroupset.mjs +0 -290
- package/src/test/repl.mjs +0 -63
- package/src/test/replinit.mjs +0 -134
- package/src/test/rotation.mjs +0 -753
- package/src/test/schedule.mjs +0 -275
- package/src/test/schema.mjs +0 -333
- package/src/test/set.mjs +0 -1081
- package/src/test/symmetricdifference.mjs +0 -495
- package/src/test/test.mjs +0 -208
- package/src/test/testing.mjs +0 -63
- package/src/test/union.mjs +0 -495
package/src/test/instrument.mjs
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
// instrument.mjs
|
|
2
|
-
//
|
|
3
|
-
// Tests for instrument.mjs.
|
|
4
|
-
|
|
5
|
-
import { expect } from './testing.mjs'
|
|
6
|
-
|
|
7
|
-
import { Element } from '../element.mjs'
|
|
8
|
-
import { Instrument } from '../instrument.mjs'
|
|
9
|
-
|
|
10
|
-
export const test = {
|
|
11
|
-
tests: [
|
|
12
|
-
{
|
|
13
|
-
title: "default constructor results in undefined symbol",
|
|
14
|
-
test: () => {
|
|
15
|
-
const instrument = new Instrument();
|
|
16
|
-
|
|
17
|
-
expect(instrument.symbol, undefined);
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
title: "constructor correctly initialises valid symbol",
|
|
22
|
-
test: () => {
|
|
23
|
-
const instrument = new Instrument("test");
|
|
24
|
-
const symbol = Symbol.for("test");
|
|
25
|
-
|
|
26
|
-
expect(instrument.symbol, (result) => { return result === symbol; });
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
|
|
30
|
-
{
|
|
31
|
-
title: "isEqual succeeds when comparing with self",
|
|
32
|
-
test: () => {
|
|
33
|
-
const instrument = new Instrument("test");
|
|
34
|
-
|
|
35
|
-
expect(instrument.isEqual(instrument), true);
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
title: "isEqual succeeds when comparing instruments with the same symbol",
|
|
40
|
-
test: () => {
|
|
41
|
-
const instrument = new Instrument("test");
|
|
42
|
-
const other = new Instrument("test");
|
|
43
|
-
|
|
44
|
-
expect(instrument.isEqual(other), true);
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
title: "isEqual fails when comparing instruments with different symbols",
|
|
49
|
-
test: () => {
|
|
50
|
-
const instrument = new Instrument("test");
|
|
51
|
-
const other = new Instrument("other");
|
|
52
|
-
|
|
53
|
-
expect(instrument.isEqual(other), false);
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
title: "isEqual fails when comparing against a non-instrument class",
|
|
58
|
-
test: () => {
|
|
59
|
-
const instrument = new Instrument();
|
|
60
|
-
const other = new Element();
|
|
61
|
-
|
|
62
|
-
expect(instrument.isEqual(other), false);
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
],
|
|
66
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
// instrumentset.mjs
|
|
2
|
-
//
|
|
3
|
-
// Tests for instrumentset.mjs.
|
|
4
|
-
|
|
5
|
-
import { expect, expectException } from './testing.mjs'
|
|
6
|
-
|
|
7
|
-
import { Instruments } from '../instrument.mjs'
|
|
8
|
-
import { Articulations } from '../articulation.mjs'
|
|
9
|
-
import { InstrumentSet } from '../instrumentset.mjs'
|
|
10
|
-
|
|
11
|
-
export const test = {
|
|
12
|
-
tests: [
|
|
13
|
-
{
|
|
14
|
-
title: "default constructor results in correct set",
|
|
15
|
-
test: () => {
|
|
16
|
-
let set = new InstrumentSet();
|
|
17
|
-
|
|
18
|
-
expect(set.isAbstract, false);
|
|
19
|
-
expect(set.allowDuplicates, false);
|
|
20
|
-
expect(set.size, 0);
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
title: "add throws error when adding non-instrument",
|
|
25
|
-
test: () => {
|
|
26
|
-
let set = new InstrumentSet();
|
|
27
|
-
let element = Articulations.Accent;
|
|
28
|
-
|
|
29
|
-
expectException(() => { set.add(element); }, Error);
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
title: "add succeeds adding instrument",
|
|
34
|
-
test: () => {
|
|
35
|
-
let set = new InstrumentSet();
|
|
36
|
-
let element = Instruments.Snare;
|
|
37
|
-
|
|
38
|
-
expect(set.add(element), (result) => { return result === set; });
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
|
|
42
|
-
],
|
|
43
|
-
}
|
|
@@ -1,493 +0,0 @@
|
|
|
1
|
-
// intersection.mjs
|
|
2
|
-
//
|
|
3
|
-
// Tests for intersection.mjs.
|
|
4
|
-
|
|
5
|
-
import { expect, expectException } from "./testing.mjs";
|
|
6
|
-
|
|
7
|
-
import { Instruments } from "../instrument.mjs";
|
|
8
|
-
import { Set } from "../set.mjs";
|
|
9
|
-
import { InstrumentSet } from "../instrumentset.mjs";
|
|
10
|
-
|
|
11
|
-
export const test = {
|
|
12
|
-
tests: [
|
|
13
|
-
{
|
|
14
|
-
title: "default constructor results in correct set",
|
|
15
|
-
test: () => {
|
|
16
|
-
const set1 = new InstrumentSet();
|
|
17
|
-
const set2 = new InstrumentSet();
|
|
18
|
-
|
|
19
|
-
let operator = new Set.Intersection(set1, set2);
|
|
20
|
-
|
|
21
|
-
expect(operator.isAbstract, true);
|
|
22
|
-
expect(operator.allowDuplicates, false);
|
|
23
|
-
expect(operator.isStrict, true);
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
|
|
27
|
-
{
|
|
28
|
-
title: "add element fails because intersection is an immutable set",
|
|
29
|
-
test: () => {
|
|
30
|
-
const set1 = new InstrumentSet();
|
|
31
|
-
const set2 = new InstrumentSet();
|
|
32
|
-
|
|
33
|
-
let operator = new Set.Intersection(set1, set2);
|
|
34
|
-
|
|
35
|
-
expectException(() => {
|
|
36
|
-
operator.add(Instruments.Snare);
|
|
37
|
-
}, Error);
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
|
|
41
|
-
{
|
|
42
|
-
title: "iterator yields nothing for an empty set",
|
|
43
|
-
test: () => {
|
|
44
|
-
const set1 = new InstrumentSet({ add: Instruments.Snare });
|
|
45
|
-
const set2 = new InstrumentSet({ add: Instruments.Bass1 });
|
|
46
|
-
|
|
47
|
-
const operator = new Set.Intersection(set1, set2);
|
|
48
|
-
|
|
49
|
-
let count = 0;
|
|
50
|
-
|
|
51
|
-
for (const e of operator) { ++count; }
|
|
52
|
-
|
|
53
|
-
expect(count, 0);
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
title: "iterator yields correct results for a non-empty set",
|
|
58
|
-
test: () => {
|
|
59
|
-
const instruments = [
|
|
60
|
-
Instruments.Crash,
|
|
61
|
-
Instruments.Snare,
|
|
62
|
-
Instruments.Bass1,
|
|
63
|
-
Instruments.Claves,
|
|
64
|
-
];
|
|
65
|
-
const set1 = new InstrumentSet({
|
|
66
|
-
add: instruments,
|
|
67
|
-
});
|
|
68
|
-
const set2 = new InstrumentSet({
|
|
69
|
-
add: [Instruments.Snare, Instruments.Bass1],
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
const operator = new Set.Intersection(set1, set2);
|
|
73
|
-
let count = 0;
|
|
74
|
-
|
|
75
|
-
for (const e of operator) {
|
|
76
|
-
expect(e, (result) => { return result === instruments[1+count++]; });
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
expect(count, 2);
|
|
80
|
-
},
|
|
81
|
-
},
|
|
82
|
-
|
|
83
|
-
{
|
|
84
|
-
title: "size returns correct size with no intersection elements",
|
|
85
|
-
test: () => {
|
|
86
|
-
const set1 = new InstrumentSet({ add: Instruments.Snare });
|
|
87
|
-
const set2 = new InstrumentSet({ add: Instruments.Bass1 });
|
|
88
|
-
|
|
89
|
-
const operator = new Set.Intersection(set1, set2);
|
|
90
|
-
|
|
91
|
-
expect(operator.size === 0, true);
|
|
92
|
-
},
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
title: "size returns correct size with a single intersection element",
|
|
96
|
-
test: () => {
|
|
97
|
-
const set1 = new InstrumentSet({
|
|
98
|
-
add: [Instruments.Snare, Instruments.Bass1],
|
|
99
|
-
});
|
|
100
|
-
const set2 = new InstrumentSet({ add: Instruments.Snare });
|
|
101
|
-
|
|
102
|
-
const operator = new Set.Intersection(set1, set2);
|
|
103
|
-
|
|
104
|
-
expect(operator.size === 1, true);
|
|
105
|
-
},
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
title: "size returns correct size with multiple different elements",
|
|
109
|
-
test: () => {
|
|
110
|
-
const set1 = new InstrumentSet({
|
|
111
|
-
add: [
|
|
112
|
-
Instruments.Snare,
|
|
113
|
-
Instruments.Crash,
|
|
114
|
-
Instruments.Claves,
|
|
115
|
-
Instruments.Bass1,
|
|
116
|
-
],
|
|
117
|
-
});
|
|
118
|
-
const set2 = new InstrumentSet({
|
|
119
|
-
add: [Instruments.Snare, Instruments.Bass1],
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
const operator = new Set.Intersection(set1, set2);
|
|
123
|
-
|
|
124
|
-
expect(operator.size === 2, true);
|
|
125
|
-
},
|
|
126
|
-
},
|
|
127
|
-
|
|
128
|
-
{
|
|
129
|
-
title: "has fails when empty",
|
|
130
|
-
test: () => {
|
|
131
|
-
const set1 = new InstrumentSet({ add: Instruments.Snare });
|
|
132
|
-
const set2 = new InstrumentSet({ add: Instruments.Bass1 });
|
|
133
|
-
|
|
134
|
-
const operator = new Set.Intersection(set1, set2);
|
|
135
|
-
|
|
136
|
-
expect(operator.size === 0, true);
|
|
137
|
-
expect(operator.has(Instruments.Snare), false);
|
|
138
|
-
},
|
|
139
|
-
},
|
|
140
|
-
{
|
|
141
|
-
title: "has succeeds for element that is in intersection",
|
|
142
|
-
test: () => {
|
|
143
|
-
let set1 = new InstrumentSet({ add: [ Instruments.Snare, Instruments.Bass1 ] });
|
|
144
|
-
let set2 = new InstrumentSet({ add: [ Instruments.Bass1 ] });
|
|
145
|
-
|
|
146
|
-
const operator = new Set.Intersection(set1, set2);
|
|
147
|
-
|
|
148
|
-
expect(operator.size === 1, true);
|
|
149
|
-
expect(operator.has(Instruments.Bass1), true);
|
|
150
|
-
},
|
|
151
|
-
},
|
|
152
|
-
{
|
|
153
|
-
title: "has fails for element that is not in intersection",
|
|
154
|
-
test: () => {
|
|
155
|
-
let set1 = new InstrumentSet({ add: [ Instruments.Snare, Instruments.Bass1 ] });
|
|
156
|
-
let set2 = new InstrumentSet({ add: [ Instruments.Bass1 ] });
|
|
157
|
-
|
|
158
|
-
const operator = new Set.Intersection(set1, set2);
|
|
159
|
-
|
|
160
|
-
expect(operator.size === 1, true);
|
|
161
|
-
expect(operator.has(Instruments.Snare), false);
|
|
162
|
-
},
|
|
163
|
-
},
|
|
164
|
-
{
|
|
165
|
-
title: "has succeeds for set that is in intersection",
|
|
166
|
-
test: () => {
|
|
167
|
-
let subset = new InstrumentSet({ add: [ Instruments.Bass1, Instruments.Snare ]});
|
|
168
|
-
let set1 = new InstrumentSet({ add: [ Instruments.Snare, Instruments.Claves, Instruments.Bass1 ] });
|
|
169
|
-
let set2 = new InstrumentSet({ add: [ Instruments.Bass1, Instruments.Crash, Instruments.Snare ] });
|
|
170
|
-
|
|
171
|
-
const operator = new Set.Intersection(set1, set2);
|
|
172
|
-
|
|
173
|
-
expect(operator.size === 2, true);
|
|
174
|
-
expect(operator.has(subset), true);
|
|
175
|
-
},
|
|
176
|
-
},
|
|
177
|
-
{
|
|
178
|
-
title: "has fails for other set that is not in intersection",
|
|
179
|
-
test: () => {
|
|
180
|
-
let subset = new InstrumentSet({ add: [ Instruments.Claves, Instruments.Crash ]});
|
|
181
|
-
let set1 = new InstrumentSet({ add: [ Instruments.Snare, Instruments.Claves, Instruments.Bass1 ] });
|
|
182
|
-
let set2 = new InstrumentSet({ add: [ Instruments.Bass1, Instruments.Crash, Instruments.Snare ] });
|
|
183
|
-
|
|
184
|
-
const operator = new Set.Intersection(set1, set2);
|
|
185
|
-
|
|
186
|
-
expect(operator.size === 2, true);
|
|
187
|
-
expect(operator.has(subset), false);
|
|
188
|
-
},
|
|
189
|
-
},
|
|
190
|
-
|
|
191
|
-
{
|
|
192
|
-
title: "indexOf throws error for undefined element",
|
|
193
|
-
test: () => {
|
|
194
|
-
let set1 = new InstrumentSet({ add: [ Instruments.Snare, Instruments.Claves, Instruments.Bass1 ] });
|
|
195
|
-
let set2 = new InstrumentSet({ add: [ Instruments.Crash, Instruments.Claves ] });
|
|
196
|
-
|
|
197
|
-
const operator = new Set.Intersection(set1, set2);
|
|
198
|
-
|
|
199
|
-
expect(operator.size === 1, true);
|
|
200
|
-
expectException(() => { operator.indexOf(); }, Error);
|
|
201
|
-
},
|
|
202
|
-
},
|
|
203
|
-
{
|
|
204
|
-
title: "indexOf throws error for argument not derived from Element",
|
|
205
|
-
test: () => {
|
|
206
|
-
let set1 = new InstrumentSet({ add: [ Instruments.Snare, Instruments.Claves, Instruments.Bass1 ] });
|
|
207
|
-
let set2 = new InstrumentSet({ add: [ Instruments.Crash, Instruments.Claves ] });
|
|
208
|
-
|
|
209
|
-
const operator = new Set.Intersection(set1, set2);
|
|
210
|
-
|
|
211
|
-
expect(operator.size === 1, true);
|
|
212
|
-
expectException(() => { operator.indexOf(new Error()); }, Error);
|
|
213
|
-
},
|
|
214
|
-
},
|
|
215
|
-
{
|
|
216
|
-
title: "indexOf fails to find non-existant element",
|
|
217
|
-
test: () => {
|
|
218
|
-
let set1 = new InstrumentSet({ add: [ Instruments.Snare, Instruments.Claves, Instruments.Bass1 ] });
|
|
219
|
-
let set2 = new InstrumentSet({ add: [ Instruments.Bass1, Instruments.Crash, Instruments.Claves ] });
|
|
220
|
-
|
|
221
|
-
const operator = new Set.Intersection(set1, set2);
|
|
222
|
-
|
|
223
|
-
expect(operator.size === 2, true);
|
|
224
|
-
expect(operator.indexOf(Instruments.Crash), -1);
|
|
225
|
-
},
|
|
226
|
-
},
|
|
227
|
-
{
|
|
228
|
-
title: "indexOf fails for empty set",
|
|
229
|
-
test: () => {
|
|
230
|
-
let set1 = new InstrumentSet({ add: [ Instruments.Snare, Instruments.Bass1 ] });
|
|
231
|
-
let set2 = new InstrumentSet({ add: [ Instruments.Crash, Instruments.Claves ] });
|
|
232
|
-
|
|
233
|
-
const operator = new Set.Intersection(set1, set2);
|
|
234
|
-
|
|
235
|
-
expect(operator.size === 0, true);
|
|
236
|
-
expect(operator.indexOf(Instruments.Bass1), -1);
|
|
237
|
-
},
|
|
238
|
-
},
|
|
239
|
-
{
|
|
240
|
-
title: "indexOf succeeds for element in the set",
|
|
241
|
-
test: () => {
|
|
242
|
-
let set1 = new InstrumentSet({ add: [ Instruments.Snare, Instruments.Claves, Instruments.Bass1 ] });
|
|
243
|
-
let set2 = new InstrumentSet({ add: [ Instruments.Crash, Instruments.Claves, Instruments.Snare ] });
|
|
244
|
-
|
|
245
|
-
const operator = new Set.Intersection(set1, set2);
|
|
246
|
-
|
|
247
|
-
expect(operator.size === 2, true);
|
|
248
|
-
expect(operator.indexOf(Instruments.Snare), 0);
|
|
249
|
-
expect(operator.indexOf(Instruments.Claves), 1);
|
|
250
|
-
},
|
|
251
|
-
},
|
|
252
|
-
{
|
|
253
|
-
title: "indexOf fails for element in the set prior to after",
|
|
254
|
-
test: () => {
|
|
255
|
-
let set1 = new InstrumentSet({ add: [ Instruments.Snare, Instruments.Claves, Instruments.Bass1 ] });
|
|
256
|
-
let set2 = new InstrumentSet({ add: [ Instruments.Snare, Instruments.Crash, Instruments.Claves ] });
|
|
257
|
-
|
|
258
|
-
const operator = new Set.Intersection(set1, set2);
|
|
259
|
-
|
|
260
|
-
expect(operator.size === 2, true);
|
|
261
|
-
expect(operator.indexOf(Instruments.Snare, 0), -1);
|
|
262
|
-
},
|
|
263
|
-
},
|
|
264
|
-
{
|
|
265
|
-
title: "indexOf succeeds for element in the set later than after",
|
|
266
|
-
test: () => {
|
|
267
|
-
let set1 = new InstrumentSet({ add: [ Instruments.Snare, Instruments.Claves, Instruments.Bass1 ] });
|
|
268
|
-
let set2 = new InstrumentSet({ add: [ Instruments.Snare, Instruments.Crash, Instruments.Claves ] });
|
|
269
|
-
|
|
270
|
-
const operator = new Set.Intersection(set1, set2);
|
|
271
|
-
|
|
272
|
-
expect(operator.size === 2, true);
|
|
273
|
-
expect(operator.indexOf(Instruments.Claves, 0), 1);
|
|
274
|
-
},
|
|
275
|
-
},
|
|
276
|
-
{
|
|
277
|
-
title: "indexOf fails if after >= size-1",
|
|
278
|
-
test: () => {
|
|
279
|
-
let set1 = new InstrumentSet({ add: [ Instruments.Snare, Instruments.Claves, Instruments.Bass1 ] });
|
|
280
|
-
let set2 = new InstrumentSet({ add: [ Instruments.Snare, Instruments.Crash, Instruments.Claves ] });
|
|
281
|
-
|
|
282
|
-
const operator = new Set.Intersection(set1, set2);
|
|
283
|
-
|
|
284
|
-
expect(operator.size === 2, true);
|
|
285
|
-
expect(operator.indexOf(Instruments.Claves, 1), -1);
|
|
286
|
-
expect(operator.indexOf(Instruments.Claves, 2), -1);
|
|
287
|
-
expect(operator.indexOf(Instruments.Claves, 3), -1);
|
|
288
|
-
},
|
|
289
|
-
},
|
|
290
|
-
|
|
291
|
-
{
|
|
292
|
-
title: "elementAt throws error for index < 0",
|
|
293
|
-
test: () => {
|
|
294
|
-
let set1 = new InstrumentSet({ add: [ Instruments.Snare, Instruments.Claves, Instruments.Bass1 ] });
|
|
295
|
-
let set2 = new InstrumentSet({ add: [ Instruments.Crash, Instruments.Claves ] });
|
|
296
|
-
|
|
297
|
-
const operator = new Set.Intersection(set1, set2);
|
|
298
|
-
|
|
299
|
-
expect(operator.size === 1, true);
|
|
300
|
-
expectException(() => { operator.elementAt(-1); }, Error);
|
|
301
|
-
},
|
|
302
|
-
},
|
|
303
|
-
{
|
|
304
|
-
title: "elementAt throws error for empty set",
|
|
305
|
-
test: () => {
|
|
306
|
-
let set1 = new InstrumentSet({ add: [ Instruments.Snare, Instruments.Bass1 ] });
|
|
307
|
-
let set2 = new InstrumentSet({ add: [ Instruments.Crash, Instruments.Claves ] });
|
|
308
|
-
|
|
309
|
-
const operator = new Set.Intersection(set1, set2);
|
|
310
|
-
|
|
311
|
-
expect(operator.size === 0, true);
|
|
312
|
-
expectException(() => { operator.elementAt(0); }, Error);
|
|
313
|
-
},
|
|
314
|
-
},
|
|
315
|
-
{
|
|
316
|
-
title: "elementAt throws error for index >= set size",
|
|
317
|
-
test: () => {
|
|
318
|
-
let set1 = new InstrumentSet({ add: [ Instruments.Snare, Instruments.Claves, Instruments.Bass1 ] });
|
|
319
|
-
let set2 = new InstrumentSet({ add: [ Instruments.Bass1, Instruments.Crash, Instruments.Claves ] });
|
|
320
|
-
|
|
321
|
-
const operator = new Set.Intersection(set1, set2);
|
|
322
|
-
|
|
323
|
-
expect(operator.size === 2, true);
|
|
324
|
-
expectException(() => { operator.elementAt(2); }, Error);
|
|
325
|
-
},
|
|
326
|
-
},
|
|
327
|
-
{
|
|
328
|
-
title: "elementAt succeeds for element in valid index",
|
|
329
|
-
test: () => {
|
|
330
|
-
let set1 = new InstrumentSet({ add: [ Instruments.Snare, Instruments.Claves, Instruments.Bass1 ] });
|
|
331
|
-
let set2 = new InstrumentSet({ add: [ Instruments.Bass1, Instruments.Crash, Instruments.Claves ] });
|
|
332
|
-
|
|
333
|
-
const operator = new Set.Intersection(set1, set2);
|
|
334
|
-
|
|
335
|
-
expect(operator.size === 2, true);
|
|
336
|
-
expect(operator.elementAt(0), (result) => { return result === Instruments.Claves; });
|
|
337
|
-
expect(operator.elementAt(1), (result) => { return result === Instruments.Bass1; });
|
|
338
|
-
},
|
|
339
|
-
},
|
|
340
|
-
|
|
341
|
-
{
|
|
342
|
-
title: "clone succeeds on an intersection operator (Shallow)",
|
|
343
|
-
test: () => {
|
|
344
|
-
let set1 = new InstrumentSet({ add: [ Instruments.Snare, Instruments.Claves, Instruments.Bass1 ] });
|
|
345
|
-
let set2 = new InstrumentSet({ add: [ Instruments.Bass1, Instruments.Crash, Instruments.Claves ] });
|
|
346
|
-
|
|
347
|
-
const operator = new Set.Intersection(set1, set2);
|
|
348
|
-
|
|
349
|
-
expect(operator.size === 2, true);
|
|
350
|
-
|
|
351
|
-
const clone = operator.clone();
|
|
352
|
-
|
|
353
|
-
expect(clone.isAbstract, true);
|
|
354
|
-
expect(clone.allowDuplicates, false);
|
|
355
|
-
expect(clone.isStrict, true);
|
|
356
|
-
expect(clone.skipValidation, false);
|
|
357
|
-
expect(clone.elements[0] === set1, true);
|
|
358
|
-
expect(clone.elements[1] === set2, true);
|
|
359
|
-
|
|
360
|
-
let index = 0;
|
|
361
|
-
|
|
362
|
-
for (let e of operator) {
|
|
363
|
-
expect(e.isEqual(clone.elementAt(index++)), true);
|
|
364
|
-
}
|
|
365
|
-
},
|
|
366
|
-
},
|
|
367
|
-
{
|
|
368
|
-
title: "clone succeeds on an intersection operator (Deep)",
|
|
369
|
-
test: () => {
|
|
370
|
-
let set1 = new InstrumentSet({ add: [ Instruments.Snare, Instruments.Claves, Instruments.Bass1 ] });
|
|
371
|
-
let set2 = new InstrumentSet({ add: [ Instruments.Bass1, Instruments.Crash, Instruments.Claves ] });
|
|
372
|
-
|
|
373
|
-
const operator = new Set.Intersection(set1, set2);
|
|
374
|
-
|
|
375
|
-
expect(operator.size === 2, true);
|
|
376
|
-
|
|
377
|
-
const clone = operator.clone(true);
|
|
378
|
-
|
|
379
|
-
expect(clone.isAbstract, true);
|
|
380
|
-
expect(clone.allowDuplicates, false);
|
|
381
|
-
expect(clone.isStrict, true);
|
|
382
|
-
expect(clone.skipValidation, false);
|
|
383
|
-
expect(clone.elements[0] !== set1, true);
|
|
384
|
-
expect(clone.elements[1] !== set2, true);
|
|
385
|
-
|
|
386
|
-
let index = 0;
|
|
387
|
-
|
|
388
|
-
for (let e of operator) {
|
|
389
|
-
expect(e.isEqual(clone.elementAt(index++)), true);
|
|
390
|
-
}
|
|
391
|
-
},
|
|
392
|
-
},
|
|
393
|
-
|
|
394
|
-
{
|
|
395
|
-
title: "isDisjointFrom fails for intersection set that is not disjoint from another set",
|
|
396
|
-
test: () => {
|
|
397
|
-
let set = new InstrumentSet({ add: [ Instruments.Snare, Instruments.Claves, Instruments.Crash ]});
|
|
398
|
-
let set1 = new InstrumentSet({ add: [ Instruments.Snare, Instruments.Claves, Instruments.Bass1 ] });
|
|
399
|
-
let set2 = new InstrumentSet({ add: [ Instruments.Crash, Instruments.Claves ] });
|
|
400
|
-
|
|
401
|
-
const operator = new Set.Intersection(set1, set2);
|
|
402
|
-
|
|
403
|
-
expect(operator.isDisjointFrom(set), false);
|
|
404
|
-
},
|
|
405
|
-
},
|
|
406
|
-
{
|
|
407
|
-
title: "isDisjointFrom succeeds for intersection set that is disjoint from another set",
|
|
408
|
-
test: () => {
|
|
409
|
-
let set = new InstrumentSet({ add: [ Instruments.Claves, Instruments.Crash ]});
|
|
410
|
-
let set1 = new InstrumentSet({ add: [ Instruments.Snare, Instruments.Claves, Instruments.Bass1 ] });
|
|
411
|
-
let set2 = new InstrumentSet({ add: [ Instruments.Crash, Instruments.Snare, Instruments.Bass1 ] });
|
|
412
|
-
|
|
413
|
-
const operator = new Set.Intersection(set1, set2);
|
|
414
|
-
|
|
415
|
-
expect(operator.isDisjointFrom(set), true);
|
|
416
|
-
},
|
|
417
|
-
},
|
|
418
|
-
{
|
|
419
|
-
title: "isDisjointFrom fails for a set that is not disjoint from a intersection set",
|
|
420
|
-
test: () => {
|
|
421
|
-
let set = new InstrumentSet({ add: [ Instruments.Snare, Instruments.Claves, Instruments.Crash ]});
|
|
422
|
-
let set1 = new InstrumentSet({ add: [ Instruments.Snare, Instruments.Claves, Instruments.Bass1 ] });
|
|
423
|
-
let set2 = new InstrumentSet({ add: [ Instruments.Crash, Instruments.Claves ] });
|
|
424
|
-
|
|
425
|
-
const operator = new Set.Intersection(set1, set2);
|
|
426
|
-
|
|
427
|
-
expect(set.isDisjointFrom(operator), false);
|
|
428
|
-
},
|
|
429
|
-
},
|
|
430
|
-
{
|
|
431
|
-
title: "isDisjointFrom succeeds for a set that is disjoint from a intersection set",
|
|
432
|
-
test: () => {
|
|
433
|
-
let set = new InstrumentSet({ add: [ Instruments.Snare, Instruments.Claves ]});
|
|
434
|
-
let set1 = new InstrumentSet({ add: [ Instruments.Snare, Instruments.Crash, Instruments.Bass1 ] });
|
|
435
|
-
let set2 = new InstrumentSet({ add: [ Instruments.Bass1, Instruments.Crash ] });
|
|
436
|
-
|
|
437
|
-
const operator = new Set.Intersection(set1, set2);
|
|
438
|
-
|
|
439
|
-
expect(set.isDisjointFrom(operator), true);
|
|
440
|
-
},
|
|
441
|
-
},
|
|
442
|
-
|
|
443
|
-
{
|
|
444
|
-
title: "isSubsetOf fails for intersection set that is not a subset of another set",
|
|
445
|
-
test: () => {
|
|
446
|
-
let set = new InstrumentSet({ add: [ Instruments.Snare, Instruments.Claves, Instruments.Crash ]});
|
|
447
|
-
let set1 = new InstrumentSet({ add: [ Instruments.Snare, Instruments.Claves, Instruments.Bass1 ] });
|
|
448
|
-
let set2 = new InstrumentSet({ add: [ Instruments.Crash, Instruments.Claves, Instruments.Bass1 ] });
|
|
449
|
-
|
|
450
|
-
const operator = new Set.Intersection(set1, set2);
|
|
451
|
-
|
|
452
|
-
expect(operator.isSubsetOf(set), false);
|
|
453
|
-
},
|
|
454
|
-
},
|
|
455
|
-
{
|
|
456
|
-
title: "isSubsetOf succeeds for intersection set that is subset of another set",
|
|
457
|
-
test: () => {
|
|
458
|
-
let set = new InstrumentSet({ add: [ Instruments.Snare, Instruments.Claves, Instruments.Crash, Instruments.Bass1 ]});
|
|
459
|
-
let set1 = new InstrumentSet({ add: [ Instruments.Snare, Instruments.Claves, Instruments.Bass1 ] });
|
|
460
|
-
let set2 = new InstrumentSet({ add: [ Instruments.Crash, Instruments.Claves, Instruments.Bass1 ] });
|
|
461
|
-
|
|
462
|
-
const operator = new Set.Intersection(set1, set2);
|
|
463
|
-
|
|
464
|
-
expect(operator.isSubsetOf(set), true);
|
|
465
|
-
},
|
|
466
|
-
},
|
|
467
|
-
{
|
|
468
|
-
title: "isSubsetOf fails for a set that is not a subset of an intesection set",
|
|
469
|
-
test: () => {
|
|
470
|
-
let set = new InstrumentSet({ add: [ Instruments.Snare, Instruments.Claves, Instruments.Crash ]});
|
|
471
|
-
let set1 = new InstrumentSet({ add: [ Instruments.Snare, Instruments.Claves, Instruments.Bass1 ] });
|
|
472
|
-
let set2 = new InstrumentSet({ add: [ Instruments.Crash, Instruments.Claves, Instruments.Bass1 ] });
|
|
473
|
-
|
|
474
|
-
const operator = new Set.Intersection(set1, set2);
|
|
475
|
-
|
|
476
|
-
expect(set.isSubsetOf(operator), false);
|
|
477
|
-
},
|
|
478
|
-
},
|
|
479
|
-
{
|
|
480
|
-
title: "isSubsetOf succeeds for a set that is a subset of an intersection set",
|
|
481
|
-
test: () => {
|
|
482
|
-
let set = new InstrumentSet({ add: [ Instruments.Bass1, Instruments.Snare ]});
|
|
483
|
-
let set1 = new InstrumentSet({ add: [ Instruments.Snare, Instruments.Crash, Instruments.Bass1 ] });
|
|
484
|
-
let set2 = new InstrumentSet({ add: [ Instruments.Snare, Instruments.Claves, Instruments.Bass1 ] });
|
|
485
|
-
|
|
486
|
-
const operator = new Set.Intersection(set1, set2);
|
|
487
|
-
|
|
488
|
-
expect(set.isSubsetOf(operator), true);
|
|
489
|
-
},
|
|
490
|
-
},
|
|
491
|
-
|
|
492
|
-
],
|
|
493
|
-
};
|