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/testing.mjs
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
// testing.mjs
|
|
2
|
-
//
|
|
3
|
-
// Functions and definitions used by test modules.
|
|
4
|
-
|
|
5
|
-
export class TestExpectationFailed extends Error {
|
|
6
|
-
constructor(result, expectedValue) {
|
|
7
|
-
super(`Failed expectation: ${result.toString()} != ${expectedValue}`);
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export class TestExceptionFailed extends Error {
|
|
12
|
-
constructor(expectedExceptionType, actualException = undefined) {
|
|
13
|
-
let message = `Failed exception: expected ${expectedExceptionType.name} to be thrown but it wasn't`;
|
|
14
|
-
|
|
15
|
-
if (!!actualException) {
|
|
16
|
-
message += ` ('${actualException}' was thrown instead)`;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
super(message);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// Check that the given result is equal (loosely) to the expectedValue.
|
|
24
|
-
// Throws TestExpectationFailed if the expected value does not match.
|
|
25
|
-
//
|
|
26
|
-
// result may be a concrete value, or a function whose return value should
|
|
27
|
-
// be taken as the actual result.
|
|
28
|
-
export const expect = (result, expectedValue) => {
|
|
29
|
-
const isFunction = typeof expectedValue === 'function';
|
|
30
|
-
|
|
31
|
-
if (typeof result === 'function') {
|
|
32
|
-
result = result();
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if ((isFunction && !expectedValue(result)) || (!isFunction && result != expectedValue)) {
|
|
36
|
-
throw new TestExpectationFailed(result, expectedValue);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// Check that the given function results in a particular exception type being thrown.
|
|
41
|
-
// Throws TestExceptionFailed if the function throws a different exception to .
|
|
42
|
-
// expectedExceptionType, or none at all.
|
|
43
|
-
//
|
|
44
|
-
// fn must be a function whose execution is expected to throw an exception of expectedExceptionType.
|
|
45
|
-
export const expectException = (fn, expectedExceptionType) => {
|
|
46
|
-
if (typeof fn !== 'function') {
|
|
47
|
-
throw `expectException requires a function as its first argument`;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
let failureException = undefined;
|
|
51
|
-
|
|
52
|
-
try {
|
|
53
|
-
fn();
|
|
54
|
-
|
|
55
|
-
failureException = new TestExceptionFailed(expectedExceptionType);
|
|
56
|
-
} catch (e) {
|
|
57
|
-
if (!(e instanceof expectedExceptionType)) {
|
|
58
|
-
failureException = new TestExceptionFailed(expectedExceptionType, e);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
if (!!failureException) throw failureException;
|
|
63
|
-
}
|
package/src/test/union.mjs
DELETED
|
@@ -1,495 +0,0 @@
|
|
|
1
|
-
// union.mjs
|
|
2
|
-
//
|
|
3
|
-
// Tests for union.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.Union(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.Union(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();
|
|
45
|
-
const set2 = new InstrumentSet();
|
|
46
|
-
|
|
47
|
-
const operator = new Set.Union(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.Claves,
|
|
62
|
-
Instruments.Snare,
|
|
63
|
-
Instruments.Bass1,
|
|
64
|
-
];
|
|
65
|
-
const set1 = new InstrumentSet({
|
|
66
|
-
add: [Instruments.Crash, Instruments.Claves],
|
|
67
|
-
});
|
|
68
|
-
const set2 = new InstrumentSet({
|
|
69
|
-
add: [Instruments.Snare, Instruments.Bass1],
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
const operator = new Set.Union(set1, set2);
|
|
73
|
-
let count = 0;
|
|
74
|
-
|
|
75
|
-
for (const e of operator) {
|
|
76
|
-
expect(e, (result) => { return result === instruments[count++]; });
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
expect(count, 4);
|
|
80
|
-
},
|
|
81
|
-
},
|
|
82
|
-
|
|
83
|
-
{
|
|
84
|
-
title: "size returns correct size with no union elements",
|
|
85
|
-
test: () => {
|
|
86
|
-
const set1 = new InstrumentSet();
|
|
87
|
-
const set2 = new InstrumentSet();
|
|
88
|
-
|
|
89
|
-
const operator = new Set.Union(set1, set2);
|
|
90
|
-
|
|
91
|
-
expect(operator.size === 0, true);
|
|
92
|
-
},
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
title: "size returns correct size with a single union element",
|
|
96
|
-
test: () => {
|
|
97
|
-
const set1 = new InstrumentSet();
|
|
98
|
-
const set2 = new InstrumentSet({ add: Instruments.Snare });
|
|
99
|
-
|
|
100
|
-
const operator = new Set.Union(set1, set2);
|
|
101
|
-
|
|
102
|
-
expect(operator.size === 1, true);
|
|
103
|
-
},
|
|
104
|
-
},
|
|
105
|
-
{
|
|
106
|
-
title: "size returns correct size with multiple different elements",
|
|
107
|
-
test: () => {
|
|
108
|
-
const set1 = new InstrumentSet({
|
|
109
|
-
add: [
|
|
110
|
-
Instruments.Snare,
|
|
111
|
-
Instruments.Crash,
|
|
112
|
-
Instruments.Claves,
|
|
113
|
-
Instruments.Bass1,
|
|
114
|
-
],
|
|
115
|
-
});
|
|
116
|
-
const set2 = new InstrumentSet({
|
|
117
|
-
add: [Instruments.Snare, Instruments.Bass1],
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
const operator = new Set.Union(set1, set2);
|
|
121
|
-
|
|
122
|
-
expect(operator.size === 4, true);
|
|
123
|
-
},
|
|
124
|
-
},
|
|
125
|
-
|
|
126
|
-
{
|
|
127
|
-
title: "has fails when empty",
|
|
128
|
-
test: () => {
|
|
129
|
-
const set1 = new InstrumentSet();
|
|
130
|
-
const set2 = new InstrumentSet();
|
|
131
|
-
|
|
132
|
-
const operator = new Set.Union(set1, set2);
|
|
133
|
-
|
|
134
|
-
expect(operator.size === 0, true);
|
|
135
|
-
expect(operator.has(Instruments.Snare), false);
|
|
136
|
-
},
|
|
137
|
-
},
|
|
138
|
-
{
|
|
139
|
-
title: "has succeeds for element that is in union",
|
|
140
|
-
test: () => {
|
|
141
|
-
let set1 = new InstrumentSet({ add: [ Instruments.Snare, Instruments.Bass1 ] });
|
|
142
|
-
let set2 = new InstrumentSet({ add: [ Instruments.Bass1 ] });
|
|
143
|
-
|
|
144
|
-
const operator = new Set.Union(set1, set2);
|
|
145
|
-
|
|
146
|
-
expect(operator.size === 2, true);
|
|
147
|
-
expect(operator.has(Instruments.Bass1), true);
|
|
148
|
-
},
|
|
149
|
-
},
|
|
150
|
-
{
|
|
151
|
-
title: "has fails for element that is not in union",
|
|
152
|
-
test: () => {
|
|
153
|
-
let set1 = new InstrumentSet({ add: [ Instruments.Snare, Instruments.Bass1 ] });
|
|
154
|
-
let set2 = new InstrumentSet({ add: [ Instruments.Bass1 ] });
|
|
155
|
-
|
|
156
|
-
const operator = new Set.Union(set1, set2);
|
|
157
|
-
|
|
158
|
-
expect(operator.size === 2, true);
|
|
159
|
-
expect(operator.has(Instruments.Crash), false);
|
|
160
|
-
},
|
|
161
|
-
},
|
|
162
|
-
{
|
|
163
|
-
title: "has succeeds for set that is in union",
|
|
164
|
-
test: () => {
|
|
165
|
-
let subset = new InstrumentSet({ add: [ Instruments.Bass1, Instruments.Snare ]});
|
|
166
|
-
let set1 = new InstrumentSet({ add: [ Instruments.Snare, Instruments.Claves, Instruments.Bass1 ] });
|
|
167
|
-
let set2 = new InstrumentSet({ add: [ Instruments.Bass1, Instruments.Crash, Instruments.Snare ] });
|
|
168
|
-
|
|
169
|
-
const operator = new Set.Union(set1, set2);
|
|
170
|
-
|
|
171
|
-
expect(operator.size === 4, true);
|
|
172
|
-
expect(operator.has(subset), true);
|
|
173
|
-
},
|
|
174
|
-
},
|
|
175
|
-
{
|
|
176
|
-
title: "has fails for other set that is not in union",
|
|
177
|
-
test: () => {
|
|
178
|
-
let subset = new InstrumentSet({ add: [ Instruments.Claves, Instruments.China ]});
|
|
179
|
-
let set1 = new InstrumentSet({ add: [ Instruments.Snare, Instruments.Bass1 ] });
|
|
180
|
-
let set2 = new InstrumentSet({ add: [ Instruments.Bass1, Instruments.Crash, Instruments.Snare ] });
|
|
181
|
-
|
|
182
|
-
const operator = new Set.Union(set1, set2);
|
|
183
|
-
|
|
184
|
-
expect(operator.size === 3, true);
|
|
185
|
-
expect(operator.has(subset), false);
|
|
186
|
-
},
|
|
187
|
-
},
|
|
188
|
-
|
|
189
|
-
{
|
|
190
|
-
title: "indexOf throws error for undefined element",
|
|
191
|
-
test: () => {
|
|
192
|
-
let set1 = new InstrumentSet({ add: [ Instruments.Snare, Instruments.Claves, Instruments.Bass1 ] });
|
|
193
|
-
let set2 = new InstrumentSet({ add: [ Instruments.Crash, Instruments.Claves ] });
|
|
194
|
-
|
|
195
|
-
const operator = new Set.Union(set1, set2);
|
|
196
|
-
|
|
197
|
-
expect(operator.size === 4, true);
|
|
198
|
-
expectException(() => { operator.indexOf(); }, Error);
|
|
199
|
-
},
|
|
200
|
-
},
|
|
201
|
-
{
|
|
202
|
-
title: "indexOf throws error for argument not derived from Element",
|
|
203
|
-
test: () => {
|
|
204
|
-
let set1 = new InstrumentSet({ add: [ Instruments.Snare, Instruments.Claves, Instruments.Bass1 ] });
|
|
205
|
-
let set2 = new InstrumentSet({ add: [ Instruments.Crash, Instruments.Claves ] });
|
|
206
|
-
|
|
207
|
-
const operator = new Set.Union(set1, set2);
|
|
208
|
-
|
|
209
|
-
expect(operator.size === 4, true);
|
|
210
|
-
expectException(() => { operator.indexOf(new Error()); }, Error);
|
|
211
|
-
},
|
|
212
|
-
},
|
|
213
|
-
{
|
|
214
|
-
title: "indexOf fails to find non-existant element",
|
|
215
|
-
test: () => {
|
|
216
|
-
let set1 = new InstrumentSet({ add: [ Instruments.Snare, Instruments.Claves, Instruments.Bass1 ] });
|
|
217
|
-
let set2 = new InstrumentSet({ add: [ Instruments.Bass1, Instruments.Claves ] });
|
|
218
|
-
|
|
219
|
-
const operator = new Set.Union(set1, set2);
|
|
220
|
-
|
|
221
|
-
expect(operator.size === 3, true);
|
|
222
|
-
expect(operator.indexOf(Instruments.Crash), -1);
|
|
223
|
-
},
|
|
224
|
-
},
|
|
225
|
-
{
|
|
226
|
-
title: "indexOf fails for empty set",
|
|
227
|
-
test: () => {
|
|
228
|
-
let set1 = new InstrumentSet();
|
|
229
|
-
let set2 = new InstrumentSet();
|
|
230
|
-
|
|
231
|
-
const operator = new Set.Union(set1, set2);
|
|
232
|
-
|
|
233
|
-
expect(operator.size === 0, true);
|
|
234
|
-
expect(operator.indexOf(Instruments.Bass1), -1);
|
|
235
|
-
},
|
|
236
|
-
},
|
|
237
|
-
{
|
|
238
|
-
title: "indexOf succeeds for element in the set",
|
|
239
|
-
test: () => {
|
|
240
|
-
let set1 = new InstrumentSet({ add: [ Instruments.Snare, Instruments.Claves, Instruments.Bass1 ] });
|
|
241
|
-
let set2 = new InstrumentSet({ add: [ Instruments.Crash, Instruments.Claves, Instruments.Snare ] });
|
|
242
|
-
|
|
243
|
-
const operator = new Set.Union(set1, set2);
|
|
244
|
-
|
|
245
|
-
expect(operator.size === 4, true);
|
|
246
|
-
expect(operator.indexOf(Instruments.Snare), 0);
|
|
247
|
-
expect(operator.indexOf(Instruments.Claves), 1);
|
|
248
|
-
expect(operator.indexOf(Instruments.Bass1), 2);
|
|
249
|
-
expect(operator.indexOf(Instruments.Crash), 3);
|
|
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.Union(set1, set2);
|
|
259
|
-
|
|
260
|
-
expect(operator.size === 4, 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.Union(set1, set2);
|
|
271
|
-
|
|
272
|
-
expect(operator.size === 4, 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.Union(set1, set2);
|
|
283
|
-
|
|
284
|
-
expect(operator.size === 4, true);
|
|
285
|
-
expect(operator.indexOf(Instruments.Claves, 3), -1);
|
|
286
|
-
expect(operator.indexOf(Instruments.Claves, 4), -1);
|
|
287
|
-
expect(operator.indexOf(Instruments.Claves, 5), -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.Union(set1, set2);
|
|
298
|
-
|
|
299
|
-
expect(operator.size === 4, 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();
|
|
307
|
-
let set2 = new InstrumentSet();
|
|
308
|
-
|
|
309
|
-
const operator = new Set.Union(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.Union(set1, set2);
|
|
322
|
-
|
|
323
|
-
expect(operator.size === 4, true);
|
|
324
|
-
expectException(() => { operator.elementAt(5); }, 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.Union(set1, set2);
|
|
334
|
-
|
|
335
|
-
expect(operator.size === 4, true);
|
|
336
|
-
expect(operator.elementAt(0), (result) => { return result === Instruments.Snare; });
|
|
337
|
-
expect(operator.elementAt(1), (result) => { return result === Instruments.Claves; });
|
|
338
|
-
expect(operator.elementAt(2), (result) => { return result === Instruments.Bass1; });
|
|
339
|
-
expect(operator.elementAt(3), (result) => { return result === Instruments.Crash; });
|
|
340
|
-
},
|
|
341
|
-
},
|
|
342
|
-
|
|
343
|
-
{
|
|
344
|
-
title: "clone succeeds on a union operator (Shallow)",
|
|
345
|
-
test: () => {
|
|
346
|
-
let set1 = new InstrumentSet({ add: [ Instruments.Snare, Instruments.Claves, Instruments.Bass1 ] });
|
|
347
|
-
let set2 = new InstrumentSet({ add: [ Instruments.Bass1, Instruments.Crash, Instruments.Claves ] });
|
|
348
|
-
|
|
349
|
-
const operator = new Set.Union(set1, set2);
|
|
350
|
-
|
|
351
|
-
expect(operator.size === 4, true);
|
|
352
|
-
|
|
353
|
-
const clone = operator.clone();
|
|
354
|
-
|
|
355
|
-
expect(clone.isAbstract, true);
|
|
356
|
-
expect(clone.allowDuplicates, false);
|
|
357
|
-
expect(clone.isStrict, true);
|
|
358
|
-
expect(clone.skipValidation, false);
|
|
359
|
-
expect(clone.elements[0] === set1, true);
|
|
360
|
-
expect(clone.elements[1] === set2, true);
|
|
361
|
-
|
|
362
|
-
let index = 0;
|
|
363
|
-
|
|
364
|
-
for (let e of operator) {
|
|
365
|
-
expect(e.isEqual(clone.elementAt(index++)), true);
|
|
366
|
-
}
|
|
367
|
-
},
|
|
368
|
-
},
|
|
369
|
-
{
|
|
370
|
-
title: "clone succeeds on a union operator (Deep)",
|
|
371
|
-
test: () => {
|
|
372
|
-
let set1 = new InstrumentSet({ add: [ Instruments.Snare, Instruments.Claves, Instruments.Bass1 ] });
|
|
373
|
-
let set2 = new InstrumentSet({ add: [ Instruments.Bass1, Instruments.Crash, Instruments.Claves ] });
|
|
374
|
-
|
|
375
|
-
const operator = new Set.Union(set1, set2);
|
|
376
|
-
|
|
377
|
-
expect(operator.size === 4, true);
|
|
378
|
-
|
|
379
|
-
const clone = operator.clone(true);
|
|
380
|
-
|
|
381
|
-
expect(clone.isAbstract, true);
|
|
382
|
-
expect(clone.allowDuplicates, false);
|
|
383
|
-
expect(clone.isStrict, true);
|
|
384
|
-
expect(clone.skipValidation, false);
|
|
385
|
-
expect(clone.elements[0] !== set1, true);
|
|
386
|
-
expect(clone.elements[1] !== set2, true);
|
|
387
|
-
|
|
388
|
-
let index = 0;
|
|
389
|
-
|
|
390
|
-
for (let e of operator) {
|
|
391
|
-
expect(e.isEqual(clone.elementAt(index++)), true);
|
|
392
|
-
}
|
|
393
|
-
},
|
|
394
|
-
},
|
|
395
|
-
|
|
396
|
-
{
|
|
397
|
-
title: "isDisjointFrom fails for union set that is not disjoint from another set",
|
|
398
|
-
test: () => {
|
|
399
|
-
let set = new InstrumentSet({ add: [ Instruments.Snare, Instruments.Claves, Instruments.Crash ]});
|
|
400
|
-
let set1 = new InstrumentSet({ add: [ Instruments.Snare, Instruments.Claves, Instruments.Bass1 ] });
|
|
401
|
-
let set2 = new InstrumentSet({ add: [ Instruments.Crash, Instruments.Claves ] });
|
|
402
|
-
|
|
403
|
-
const operator = new Set.Union(set1, set2);
|
|
404
|
-
|
|
405
|
-
expect(operator.isDisjointFrom(set), false);
|
|
406
|
-
},
|
|
407
|
-
},
|
|
408
|
-
{
|
|
409
|
-
title: "isDisjointFrom succeeds for union set that is disjoint from another set",
|
|
410
|
-
test: () => {
|
|
411
|
-
let set = new InstrumentSet({ add: [ Instruments.Claves, Instruments.Crash ]});
|
|
412
|
-
let set1 = new InstrumentSet({ add: [ Instruments.Snare, Instruments.Bass1 ] });
|
|
413
|
-
let set2 = new InstrumentSet({ add: [ Instruments.China, Instruments.Bass2 ] });
|
|
414
|
-
|
|
415
|
-
const operator = new Set.Union(set1, set2);
|
|
416
|
-
|
|
417
|
-
expect(operator.isDisjointFrom(set), true);
|
|
418
|
-
},
|
|
419
|
-
},
|
|
420
|
-
{
|
|
421
|
-
title: "isDisjointFrom fails for a set that is not disjoint from a union set",
|
|
422
|
-
test: () => {
|
|
423
|
-
let set = new InstrumentSet({ add: [ Instruments.China, Instruments.Crash ]});
|
|
424
|
-
let set1 = new InstrumentSet({ add: [ Instruments.Snare, Instruments.Bass1 ] });
|
|
425
|
-
let set2 = new InstrumentSet({ add: [ Instruments.Crash, Instruments.Claves ] });
|
|
426
|
-
|
|
427
|
-
const operator = new Set.Union(set1, set2);
|
|
428
|
-
|
|
429
|
-
expect(set.isDisjointFrom(operator), false);
|
|
430
|
-
},
|
|
431
|
-
},
|
|
432
|
-
{
|
|
433
|
-
title: "isDisjointFrom succeeds for a set that is disjoint from a union set",
|
|
434
|
-
test: () => {
|
|
435
|
-
let set = new InstrumentSet({ add: [ Instruments.China, Instruments.Claves ]});
|
|
436
|
-
let set1 = new InstrumentSet({ add: [ Instruments.Snare, Instruments.Bass1 ] });
|
|
437
|
-
let set2 = new InstrumentSet({ add: [ Instruments.Bass1, Instruments.Crash ] });
|
|
438
|
-
|
|
439
|
-
const operator = new Set.Union(set1, set2);
|
|
440
|
-
|
|
441
|
-
expect(set.isDisjointFrom(operator), true);
|
|
442
|
-
},
|
|
443
|
-
},
|
|
444
|
-
|
|
445
|
-
{
|
|
446
|
-
title: "isSubsetOf fails for union set that is not a subset of another set",
|
|
447
|
-
test: () => {
|
|
448
|
-
let set = new InstrumentSet({ add: [ Instruments.Snare, Instruments.Bass1, Instruments.Claves ]});
|
|
449
|
-
let set1 = new InstrumentSet({ add: [ Instruments.Snare ] });
|
|
450
|
-
let set2 = new InstrumentSet({ add: [ Instruments.Crash ] });
|
|
451
|
-
|
|
452
|
-
const operator = new Set.Union(set1, set2);
|
|
453
|
-
|
|
454
|
-
expect(operator.isSubsetOf(set), false);
|
|
455
|
-
},
|
|
456
|
-
},
|
|
457
|
-
{
|
|
458
|
-
title: "isSubsetOf succeeds for union set that is subset of another set",
|
|
459
|
-
test: () => {
|
|
460
|
-
let set = new InstrumentSet({ add: [ Instruments.Snare, Instruments.Claves, Instruments.Crash ]});
|
|
461
|
-
let set1 = new InstrumentSet({ add: [ Instruments.Snare, Instruments.Claves ] });
|
|
462
|
-
let set2 = new InstrumentSet({ add: [ Instruments.Crash, Instruments.Claves ] });
|
|
463
|
-
|
|
464
|
-
const operator = new Set.Union(set1, set2);
|
|
465
|
-
|
|
466
|
-
expect(operator.isSubsetOf(set), true);
|
|
467
|
-
},
|
|
468
|
-
},
|
|
469
|
-
{
|
|
470
|
-
title: "isSubsetOf fails for a set that is not a subset of an union set",
|
|
471
|
-
test: () => {
|
|
472
|
-
let set = new InstrumentSet({ add: [ Instruments.Snare, Instruments.Claves, Instruments.China ]});
|
|
473
|
-
let set1 = new InstrumentSet({ add: [ Instruments.Snare, Instruments.Claves ] });
|
|
474
|
-
let set2 = new InstrumentSet({ add: [ Instruments.Crash, Instruments.Bass1 ] });
|
|
475
|
-
|
|
476
|
-
const operator = new Set.Union(set1, set2);
|
|
477
|
-
|
|
478
|
-
expect(set.isSubsetOf(operator), false);
|
|
479
|
-
},
|
|
480
|
-
},
|
|
481
|
-
{
|
|
482
|
-
title: "isSubsetOf succeeds for a set that is a subset of an union set",
|
|
483
|
-
test: () => {
|
|
484
|
-
let set = new InstrumentSet({ add: [ Instruments.Bass1, Instruments.Snare ]});
|
|
485
|
-
let set1 = new InstrumentSet({ add: [ Instruments.Snare, Instruments.Crash, Instruments.Bass1 ] });
|
|
486
|
-
let set2 = new InstrumentSet({ add: [ Instruments.Snare, Instruments.Claves, Instruments.Bass1 ] });
|
|
487
|
-
|
|
488
|
-
const operator = new Set.Union(set1, set2);
|
|
489
|
-
|
|
490
|
-
expect(set.isSubsetOf(operator), true);
|
|
491
|
-
},
|
|
492
|
-
},
|
|
493
|
-
|
|
494
|
-
],
|
|
495
|
-
};
|