discombobulator 1.0.0

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.
Files changed (53) hide show
  1. package/package.json +16 -0
  2. package/src/articulation.mjs +61 -0
  3. package/src/articulationset.mjs +20 -0
  4. package/src/chord.mjs +82 -0
  5. package/src/cross.mjs +133 -0
  6. package/src/disco.mjs +14 -0
  7. package/src/element.mjs +51 -0
  8. package/src/group.mjs +70 -0
  9. package/src/groupset.mjs +259 -0
  10. package/src/instrument.mjs +105 -0
  11. package/src/instrumentset.mjs +20 -0
  12. package/src/irregulargroupset.mjs +224 -0
  13. package/src/note.mjs +155 -0
  14. package/src/noteset.mjs +21 -0
  15. package/src/pattern.mjs +52 -0
  16. package/src/patternset.mjs +20 -0
  17. package/src/patternsource.mjs +21 -0
  18. package/src/permute.mjs +63 -0
  19. package/src/regulargroupset.mjs +120 -0
  20. package/src/schedule.mjs +88 -0
  21. package/src/schema.mjs +108 -0
  22. package/src/set.mjs +1159 -0
  23. package/src/test/articulation.mjs +66 -0
  24. package/src/test/articulationset.mjs +43 -0
  25. package/src/test/binaryoperator.mjs +210 -0
  26. package/src/test/chord.mjs +292 -0
  27. package/src/test/concolour.mjs +70 -0
  28. package/src/test/difference.mjs +492 -0
  29. package/src/test/element.mjs +66 -0
  30. package/src/test/group.mjs +79 -0
  31. package/src/test/groupset.mjs +43 -0
  32. package/src/test/instrument.mjs +66 -0
  33. package/src/test/instrumentset.mjs +43 -0
  34. package/src/test/intersection.mjs +493 -0
  35. package/src/test/irregulargroupset.mjs +461 -0
  36. package/src/test/note.mjs +367 -0
  37. package/src/test/noteset.mjs +43 -0
  38. package/src/test/operator.mjs +63 -0
  39. package/src/test/pattern.mjs +113 -0
  40. package/src/test/patternset.mjs +43 -0
  41. package/src/test/patternsource.mjs +43 -0
  42. package/src/test/regulargroupset.mjs +290 -0
  43. package/src/test/repl.mjs +63 -0
  44. package/src/test/replinit.mjs +134 -0
  45. package/src/test/rotation.mjs +753 -0
  46. package/src/test/schedule.mjs +275 -0
  47. package/src/test/schema.mjs +333 -0
  48. package/src/test/set.mjs +1081 -0
  49. package/src/test/symmetricdifference.mjs +495 -0
  50. package/src/test/test.mjs +208 -0
  51. package/src/test/testing.mjs +63 -0
  52. package/src/test/union.mjs +495 -0
  53. package/src/util.mjs +21 -0
@@ -0,0 +1,753 @@
1
+ // rotation.mjs
2
+ //
3
+ // Tests for rotation.mjs.
4
+
5
+ import { expect, expectException } from "./testing.mjs";
6
+
7
+ import { Element } from "../element.mjs";
8
+ import { Instruments } from "../instrument.mjs";
9
+ import { Set } from "../set.mjs";
10
+ import { InstrumentSet } from "../instrumentset.mjs";
11
+
12
+ export const test = {
13
+ tests: [
14
+ {
15
+ title: "default constructor throws if setClass invalid",
16
+ test: () => {
17
+ let operator;
18
+
19
+ expectException(() => (operator = new Set.Rotation()), Error);
20
+ expectException(() => (operator = new Set.Rotation(5)), Error);
21
+ },
22
+ },
23
+ {
24
+ title: "default constructor throws if set invalid",
25
+ test: () => {
26
+ let operator;
27
+
28
+ expectException(
29
+ () => (operator = new Set.Rotation({ setClass: InstrumentSet })),
30
+ Error
31
+ );
32
+ expectException(
33
+ () =>
34
+ (operator = new Set.Rotation({
35
+ setClass: InstrumentSet,
36
+ set: new Element(),
37
+ })),
38
+ Error
39
+ );
40
+ },
41
+ },
42
+ {
43
+ title: "minimal constructor results in correct set",
44
+ test: () => {
45
+ const set = new InstrumentSet({
46
+ add: [Instruments.Crash, Instruments.Snare, Instruments.Bass1],
47
+ });
48
+
49
+ let operator = new Set.Rotation(set, InstrumentSet);
50
+
51
+ expect(operator.isAbstract, true);
52
+ expect(operator.allowDuplicates, false);
53
+ expect(operator.set === set, true);
54
+ expect(operator.rotateLeft, true);
55
+ },
56
+ },
57
+ {
58
+ title: "constructor with rotateLeft option results in correct set",
59
+ test: () => {
60
+ const set = new InstrumentSet({
61
+ add: [Instruments.Crash, Instruments.Snare, Instruments.Bass1],
62
+ });
63
+
64
+ let operator = new Set.Rotation(set, InstrumentSet, {
65
+ rotateLeft: false,
66
+ });
67
+
68
+ expect(operator.isAbstract, true);
69
+ expect(operator.allowDuplicates, false);
70
+ expect(operator.set === set, true);
71
+ expect(operator.rotateLeft, false);
72
+ },
73
+ },
74
+
75
+ {
76
+ title: "add element fails because rotation is an immutable set",
77
+ test: () => {
78
+ const set = new InstrumentSet({
79
+ add: [Instruments.Crash, Instruments.Snare, Instruments.Bass1],
80
+ });
81
+
82
+ let operator = new Set.Rotation(set, InstrumentSet);
83
+
84
+ expectException(() => {
85
+ operator.add(Instruments.Snare);
86
+ }, Error);
87
+ },
88
+ },
89
+
90
+ {
91
+ title: "iterator yields nothing for an empty set",
92
+ test: () => {
93
+ let operator = new Set.Rotation(
94
+ new InstrumentSet(),
95
+ InstrumentSet,
96
+ );
97
+
98
+ expect(operator.size, 0);
99
+
100
+ let count = 0;
101
+
102
+ for (const e of operator) {
103
+ ++count;
104
+ }
105
+
106
+ expect(count, 0);
107
+ },
108
+ },
109
+ {
110
+ title: "iterator yields correct results for a non-empty set",
111
+ test: () => {
112
+ const set = new InstrumentSet({
113
+ add: [Instruments.Crash, Instruments.Snare, Instruments.Bass1],
114
+ });
115
+ const size = set.size;
116
+
117
+ let operator = new Set.Rotation(set, InstrumentSet);
118
+
119
+ expect(size === operator.size, true);
120
+
121
+ let offset = 0;
122
+ let index,
123
+ count = 0;
124
+
125
+ for (const e of operator) {
126
+ expect(e.size === size, true);
127
+
128
+ index = offset;
129
+ count = 0;
130
+
131
+ for (let i of e) {
132
+ expect(i, (result) => {
133
+ result = result === set.elements[index];
134
+ index = (index + 1) % size;
135
+ return result;
136
+ });
137
+
138
+ ++count;
139
+ }
140
+
141
+ expect(count, 3);
142
+
143
+ offset = (offset + 1) % size;
144
+ }
145
+ },
146
+ },
147
+
148
+ {
149
+ title: "size returns correct size with no rotation elements",
150
+ test: () => {
151
+ const set = new InstrumentSet();
152
+
153
+ let operator = new Set.Rotation(set, InstrumentSet);
154
+
155
+ expect(operator.size === 0, true);
156
+ },
157
+ },
158
+ {
159
+ title: "size returns correct size with a single rotation element",
160
+ test: () => {
161
+ const set = new InstrumentSet({
162
+ add: [Instruments.Crash],
163
+ });
164
+ const size = set.size;
165
+
166
+ let operator = new Set.Rotation(set, InstrumentSet);
167
+
168
+ expect(operator.size === 1, true);
169
+ },
170
+ },
171
+ {
172
+ title: "size returns correct size with multiple different elements",
173
+ test: () => {
174
+ const set = new InstrumentSet({
175
+ add: [Instruments.Crash, Instruments.Snare, Instruments.Bass1],
176
+ });
177
+
178
+ let operator = new Set.Rotation(set, InstrumentSet);
179
+
180
+ expect(operator.size === 3, true);
181
+ },
182
+ },
183
+
184
+ {
185
+ title: "has fails when empty",
186
+ test: () => {
187
+ const set = new InstrumentSet();
188
+
189
+ let operator = new Set.Rotation(set, InstrumentSet);
190
+
191
+ expect(operator.size === 0, true);
192
+ expect(operator.has(new InstrumentSet()), false);
193
+ },
194
+ },
195
+ {
196
+ title: "has succeeds for element that is in rotation",
197
+ test: () => {
198
+ const set1 = new InstrumentSet({
199
+ add: [Instruments.Crash, Instruments.Snare, Instruments.Bass1],
200
+ });
201
+ const set2 = new InstrumentSet({
202
+ add: [Instruments.Snare, Instruments.Bass1, Instruments.Crash],
203
+ });
204
+ const set3 = new InstrumentSet({
205
+ add: [Instruments.Bass1, Instruments.Crash, Instruments.Snare],
206
+ });
207
+
208
+ let operator = new Set.Rotation(set1, InstrumentSet);
209
+
210
+ expect(operator.size === 3, true);
211
+ expect(operator.has(set1), true);
212
+ expect(operator.has(set2), true);
213
+ expect(operator.has(set3), true);
214
+ },
215
+ },
216
+ {
217
+ title: "has fails for element that is not in rotation",
218
+ test: () => {
219
+ const set1 = new InstrumentSet({
220
+ add: [Instruments.Crash, Instruments.Snare, Instruments.Bass1],
221
+ });
222
+ const set2 = new InstrumentSet({
223
+ add: [Instruments.Crash, Instruments.Snare, Instruments.Bass2],
224
+ });
225
+
226
+ let operator = new Set.Rotation(set1, InstrumentSet);
227
+
228
+ expect(operator.size === 3, true);
229
+ expect(operator.has(set2), false);
230
+ },
231
+ },
232
+ {
233
+ title: "has succeeds for set that is in rotation",
234
+ test: () => {
235
+ const set1 = new InstrumentSet({
236
+ add: [Instruments.Crash, Instruments.Snare, Instruments.Bass1],
237
+ });
238
+ const set2 = new InstrumentSet({
239
+ add: [Instruments.Snare, Instruments.Bass1, Instruments.Crash],
240
+ });
241
+ const set3 = new InstrumentSet({
242
+ add: [Instruments.Bass1, Instruments.Crash, Instruments.Snare],
243
+ });
244
+
245
+ const subset = new Set({
246
+ add: [set2, set3],
247
+ allowedElements: [InstrumentSet],
248
+ });
249
+
250
+ let operator = new Set.Rotation(set1, InstrumentSet);
251
+
252
+ expect(operator.size === 3, true);
253
+ expect(operator.has(subset), true);
254
+ },
255
+ },
256
+ {
257
+ title: "has fails for other set that is not in rotation",
258
+ test: () => {
259
+ const set1 = new InstrumentSet({
260
+ add: [Instruments.Crash, Instruments.Snare, Instruments.Bass1],
261
+ });
262
+ const set2 = new InstrumentSet({
263
+ add: [Instruments.Snare, Instruments.Bass1, Instruments.Crash],
264
+ });
265
+ const set3 = new InstrumentSet({
266
+ add: [Instruments.Bass1, Instruments.China, Instruments.Snare],
267
+ });
268
+
269
+ const subset = new Set({
270
+ add: [set2, set3],
271
+ allowedElements: [InstrumentSet],
272
+ });
273
+
274
+ let operator = new Set.Rotation(set1, InstrumentSet);
275
+
276
+ expect(operator.size === 3, true);
277
+ expect(operator.has(subset), false);
278
+ },
279
+ },
280
+
281
+ {
282
+ title: "indexOf throws error for undefined element",
283
+ test: () => {
284
+ const set = new InstrumentSet({
285
+ add: [Instruments.Crash, Instruments.Snare, Instruments.Bass1],
286
+ });
287
+
288
+ let operator = new Set.Rotation(set, InstrumentSet);
289
+
290
+ expect(operator.size === 3, true);
291
+ expectException(() => {
292
+ operator.indexOf();
293
+ }, Error);
294
+ },
295
+ },
296
+ {
297
+ title: "indexOf throws error for argument not derived from Element",
298
+ test: () => {
299
+ const set = new InstrumentSet({
300
+ add: [Instruments.Crash, Instruments.Snare, Instruments.Bass1],
301
+ });
302
+
303
+ let operator = new Set.Rotation(set, InstrumentSet);
304
+
305
+ expect(operator.size === 3, true);
306
+ expectException(() => {
307
+ operator.indexOf(new Error());
308
+ }, Error);
309
+ },
310
+ },
311
+ {
312
+ title: "indexOf fails to find non-existant element",
313
+ test: () => {
314
+ const set = new InstrumentSet({
315
+ add: [Instruments.Crash, Instruments.Snare, Instruments.Bass1],
316
+ });
317
+
318
+ const other = new InstrumentSet({
319
+ add: [Instruments.China, Instruments.Snare, Instruments.Bass1],
320
+ });
321
+
322
+ let operator = new Set.Rotation(set, InstrumentSet);
323
+
324
+ expect(operator.size === 3, true);
325
+ expect(operator.indexOf(other), -1);
326
+ },
327
+ },
328
+ {
329
+ title: "indexOf fails for empty set",
330
+ test: () => {
331
+ const set = new InstrumentSet();
332
+
333
+ const other = new InstrumentSet({
334
+ add: [Instruments.China, Instruments.Snare, Instruments.Bass1],
335
+ });
336
+
337
+ let operator = new Set.Rotation(set, InstrumentSet);
338
+
339
+ expect(operator.size === 0, true);
340
+ expect(operator.indexOf(other), -1);
341
+ },
342
+ },
343
+ {
344
+ title: "indexOf succeeds for element in the set",
345
+ test: () => {
346
+ const set = new InstrumentSet({
347
+ add: [Instruments.Crash, Instruments.Snare, Instruments.Bass1],
348
+ });
349
+
350
+ const others = [
351
+ new InstrumentSet({
352
+ add: [Instruments.Crash, Instruments.Snare, Instruments.Bass1],
353
+ }),
354
+ new InstrumentSet({
355
+ add: [Instruments.Snare, Instruments.Bass1, Instruments.Crash],
356
+ }),
357
+ new InstrumentSet({
358
+ add: [Instruments.Bass1, Instruments.Crash, Instruments.Snare],
359
+ }),
360
+ ];
361
+
362
+ let operator = new Set.Rotation(set, InstrumentSet);
363
+
364
+ expect(operator.size === 3, true);
365
+
366
+ let count = 0;
367
+
368
+ for (let other of others) {
369
+ expect(operator.indexOf(other), count++);
370
+ }
371
+
372
+ expect(count, 3);
373
+ },
374
+ },
375
+ {
376
+ title: "indexOf fails for element in the set prior to after",
377
+ test: () => {
378
+ const set = new InstrumentSet({
379
+ add: [Instruments.Crash, Instruments.Snare, Instruments.Bass1],
380
+ });
381
+
382
+ const other = new InstrumentSet({
383
+ add: [Instruments.Crash, Instruments.Snare, Instruments.Bass1],
384
+ });
385
+
386
+ let operator = new Set.Rotation(set, InstrumentSet);
387
+
388
+ expect(operator.size === 3, true);
389
+ expect(operator.indexOf(other, 0), -1);
390
+ },
391
+ },
392
+ {
393
+ title: "indexOf succeeds for element in the set later than after",
394
+ test: () => {
395
+ const set = new InstrumentSet({
396
+ add: [Instruments.Crash, Instruments.Snare, Instruments.Bass1],
397
+ });
398
+
399
+ const other = new InstrumentSet({
400
+ add: [Instruments.Snare, Instruments.Bass1, Instruments.Crash],
401
+ });
402
+
403
+ let operator = new Set.Rotation(set, InstrumentSet);
404
+
405
+ expect(operator.size === 3, true);
406
+ expect(operator.indexOf(other, 0), 1);
407
+ },
408
+ },
409
+ {
410
+ title: "indexOf fails if after >= size-1",
411
+ test: () => {
412
+ const set = new InstrumentSet({
413
+ add: [Instruments.Crash, Instruments.Snare, Instruments.Bass1],
414
+ });
415
+
416
+ const other = new InstrumentSet({
417
+ add: [Instruments.China, Instruments.Snare, Instruments.Bass1],
418
+ });
419
+
420
+ let operator = new Set.Rotation(set, InstrumentSet);
421
+
422
+ expect(operator.size === 3, true);
423
+ expect(operator.indexOf(other, 2), -1);
424
+ expect(operator.indexOf(other, 3), -1);
425
+ },
426
+ },
427
+
428
+ {
429
+ title: "elementAt throws error for index < 0",
430
+ test: () => {
431
+ const set = new InstrumentSet({
432
+ add: [Instruments.Crash, Instruments.Snare, Instruments.Bass1],
433
+ });
434
+
435
+ let operator = new Set.Rotation(set, InstrumentSet);
436
+
437
+ expect(operator.size === 3, true);
438
+ expectException(() => {
439
+ operator.elementAt(-1);
440
+ }, Error);
441
+ },
442
+ },
443
+ {
444
+ title: "elementAt throws error for empty set",
445
+ test: () => {
446
+ const set = new InstrumentSet();
447
+
448
+ let operator = new Set.Rotation(set, InstrumentSet);
449
+
450
+ expect(operator.size === 0, true);
451
+ expectException(() => {
452
+ operator.elementAt(0);
453
+ }, Error);
454
+ },
455
+ },
456
+ {
457
+ title: "elementAt throws error for index >= set size",
458
+ test: () => {
459
+ const set = new InstrumentSet({
460
+ add: [Instruments.Crash, Instruments.Snare, Instruments.Bass1],
461
+ });
462
+
463
+ const other = new InstrumentSet({
464
+ add: [Instruments.China, Instruments.Snare, Instruments.Bass1],
465
+ });
466
+
467
+ let operator = new Set.Rotation(set, InstrumentSet);
468
+
469
+ expect(operator.size === 3, true);
470
+ expectException(() => {
471
+ operator.elementAt(3);
472
+ }, Error);
473
+ },
474
+ },
475
+ {
476
+ title: "elementAt succeeds for element in valid index",
477
+ test: () => {
478
+ const set = new InstrumentSet({
479
+ add: [Instruments.Crash, Instruments.Snare, Instruments.Bass1],
480
+ });
481
+
482
+ const others = [
483
+ new InstrumentSet({
484
+ add: [Instruments.Crash, Instruments.Snare, Instruments.Bass1],
485
+ }),
486
+ new InstrumentSet({
487
+ add: [Instruments.Snare, Instruments.Bass1, Instruments.Crash],
488
+ }),
489
+ new InstrumentSet({
490
+ add: [Instruments.Bass1, Instruments.Crash, Instruments.Snare],
491
+ }),
492
+ ];
493
+
494
+ let operator = new Set.Rotation(set, InstrumentSet);
495
+
496
+ expect(operator.size === 3, true);
497
+
498
+ let count = 0;
499
+
500
+ for (let other of others) {
501
+ expect(operator.elementAt(count++), (result) => {
502
+ return result.isEqual(other);
503
+ });
504
+ }
505
+
506
+ expect(count, 3);
507
+ },
508
+ },
509
+
510
+ {
511
+ title: "clone succeeds on a rotation operator (Shallow)",
512
+ test: () => {
513
+ const set = new InstrumentSet({
514
+ add: [Instruments.Crash, Instruments.Snare, Instruments.Bass1],
515
+ });
516
+
517
+ const operator = new Set.Rotation(set, InstrumentSet);
518
+
519
+ expect(operator.size === 3, true);
520
+
521
+ const clone = operator.clone();
522
+
523
+ expect(clone.isAbstract, true);
524
+ expect(clone.allowDuplicates, false);
525
+ expect(clone.isStrict, true);
526
+ expect(clone.setClass === InstrumentSet, true);
527
+ expect(clone.set === set, true);
528
+
529
+ let index = 0;
530
+
531
+ for (let e of operator) {
532
+ expect(e.isEqual(clone.elementAt(index++)), true);
533
+ }
534
+ },
535
+ },
536
+ {
537
+ title: "clone succeeds on a rotation operator (Deep)",
538
+ test: () => {
539
+ const set = new InstrumentSet({
540
+ add: [Instruments.Crash, Instruments.Snare, Instruments.Bass1],
541
+ });
542
+
543
+ const operator = new Set.Rotation(set, InstrumentSet);
544
+
545
+ expect(operator.size === 3, true);
546
+
547
+ const clone = operator.clone(true);
548
+
549
+ expect(clone.isAbstract, true);
550
+ expect(clone.allowDuplicates, false);
551
+ expect(clone.isStrict, true);
552
+ expect(clone.setClass === InstrumentSet, true);
553
+ expect(clone.set !== set, true);
554
+
555
+ let index = 0;
556
+
557
+ for (let e of operator) {
558
+ expect(e.isEqual(clone.elementAt(index++)), true);
559
+ }
560
+ },
561
+ },
562
+
563
+ {
564
+ title:
565
+ "isDisjointFrom fails for rotation set that is not disjoint from another set",
566
+ test: () => {
567
+ const set = new InstrumentSet({
568
+ add: [Instruments.Crash, Instruments.Snare, Instruments.Bass1],
569
+ });
570
+
571
+ const operator = new Set.Rotation(set, InstrumentSet);
572
+
573
+ let other = new Set({
574
+ add: new InstrumentSet({
575
+ add: [Instruments.Snare, Instruments.Bass1, Instruments.Crash],
576
+ }),
577
+ allowedElements: [InstrumentSet],
578
+ });
579
+
580
+ expect(operator.isDisjointFrom(other), false);
581
+ },
582
+ },
583
+ {
584
+ title:
585
+ "isDisjointFrom succeeds for rotation set that is disjoint from another set",
586
+ test: () => {
587
+ const set = new InstrumentSet({
588
+ add: [Instruments.Crash, Instruments.Snare, Instruments.Bass1],
589
+ });
590
+
591
+ const operator = new Set.Rotation(set, InstrumentSet);
592
+
593
+ let other = new Set({
594
+ add: new InstrumentSet({
595
+ add: [Instruments.Snare, Instruments.Bass1, Instruments.Claves],
596
+ }),
597
+ allowedElements: [InstrumentSet],
598
+ });
599
+
600
+ expect(operator.isDisjointFrom(other), true);
601
+ },
602
+ },
603
+ {
604
+ title:
605
+ "isDisjointFrom fails for a set that is not disjoint from a rotation set",
606
+ test: () => {
607
+ const set = new InstrumentSet({
608
+ add: [Instruments.Crash, Instruments.Snare, Instruments.Bass1],
609
+ });
610
+
611
+ const operator = new Set.Rotation(set, InstrumentSet);
612
+
613
+ let other = new Set({
614
+ add: new InstrumentSet({
615
+ add: [Instruments.Snare, Instruments.Bass1, Instruments.Crash],
616
+ }),
617
+ allowedElements: [InstrumentSet],
618
+ });
619
+
620
+ expect(other.isDisjointFrom(operator), false);
621
+ },
622
+ },
623
+ {
624
+ title:
625
+ "isDisjointFrom succeeds for a set that is disjoint from a rotation set",
626
+ test: () => {
627
+ const set = new InstrumentSet({
628
+ add: [Instruments.Crash, Instruments.Snare, Instruments.Bass1],
629
+ });
630
+
631
+ const operator = new Set.Rotation(set, InstrumentSet);
632
+
633
+ let other = new Set({
634
+ add: new InstrumentSet({
635
+ add: [Instruments.Snare, Instruments.Bass1, Instruments.Claves],
636
+ }),
637
+ allowedElements: [InstrumentSet],
638
+ });
639
+
640
+ expect(other.isDisjointFrom(operator), true);
641
+ },
642
+ },
643
+
644
+ {
645
+ title:
646
+ "isSubsetOf fails for rotation set that is not a subset of another set",
647
+ test: () => {
648
+ const set = new InstrumentSet({
649
+ add: [Instruments.Crash, Instruments.Snare, Instruments.Bass1],
650
+ });
651
+
652
+ const operator = new Set.Rotation(set, InstrumentSet);
653
+
654
+ let other = new Set({
655
+ add: new InstrumentSet({
656
+ add: [Instruments.Snare, Instruments.Bass1, Instruments.Crash],
657
+ }),
658
+ add: new InstrumentSet({
659
+ add: [Instruments.Bass1, Instruments.Crash, Instruments.Snare],
660
+ }),
661
+ add: new InstrumentSet({
662
+ add: [Instruments.Claves, Instruments.Snare, Instruments.Bass1],
663
+ }),
664
+ add: new InstrumentSet({
665
+ add: [Instruments.Snare, Instruments.Claves, Instruments.Crash],
666
+ }),
667
+ allowedElements: [InstrumentSet],
668
+ });
669
+
670
+ expect(operator.isSubsetOf(other), false);
671
+ },
672
+ },
673
+ {
674
+ title:
675
+ "isSubsetOf succeeds for rotation set that is subset of another set",
676
+ test: () => {
677
+ const set = new InstrumentSet({
678
+ add: [Instruments.Crash, Instruments.Snare, Instruments.Bass1],
679
+ });
680
+
681
+ const operator = new Set.Rotation(set, InstrumentSet);
682
+
683
+ let other = new Set({
684
+ add: [
685
+ new InstrumentSet({
686
+ add: [Instruments.Snare, Instruments.Bass1, Instruments.Crash],
687
+ }),
688
+ new InstrumentSet({
689
+ add: [Instruments.Bass1, Instruments.Crash, Instruments.Snare],
690
+ }),
691
+ new InstrumentSet({
692
+ add: [Instruments.Crash, Instruments.Snare, Instruments.Bass1],
693
+ }),
694
+ new InstrumentSet({
695
+ add: [Instruments.Snare, Instruments.Claves, Instruments.Crash],
696
+ }),
697
+ ],
698
+ allowedElements: [InstrumentSet],
699
+ });
700
+
701
+ expect(operator.isSubsetOf(other), true);
702
+ },
703
+ },
704
+ {
705
+ title: "isSubsetOf fails for a set that is not a subset of an rotation set",
706
+ test: () => {
707
+ const set = new InstrumentSet({
708
+ add: [Instruments.Crash, Instruments.Snare, Instruments.Bass1],
709
+ });
710
+
711
+ const operator = new Set.Rotation(set, InstrumentSet);
712
+
713
+ let other = new Set({
714
+ add: [
715
+ new InstrumentSet({
716
+ add: [Instruments.Snare, Instruments.Bass1, Instruments.Crash],
717
+ }),
718
+ new InstrumentSet({
719
+ add: [Instruments.Claves, Instruments.Snare, Instruments.Bass1],
720
+ }),
721
+ ],
722
+ allowedElements: [InstrumentSet],
723
+ });
724
+
725
+ expect(other.isSubsetOf(operator), false);
726
+ },
727
+ },
728
+ {
729
+ title: "isSubsetOf succeeds for a set that is a subset of an rotation set",
730
+ test: () => {
731
+ const set = new InstrumentSet({
732
+ add: [Instruments.Crash, Instruments.Snare, Instruments.Bass1],
733
+ });
734
+
735
+ const operator = new Set.Rotation(set, InstrumentSet);
736
+
737
+ let other = new Set({
738
+ add: [
739
+ new InstrumentSet({
740
+ add: [Instruments.Snare, Instruments.Bass1, Instruments.Crash],
741
+ }),
742
+ new InstrumentSet({
743
+ add: [Instruments.Crash, Instruments.Snare, Instruments.Bass1],
744
+ }),
745
+ ],
746
+ allowedElements: [InstrumentSet],
747
+ });
748
+
749
+ expect(other.isSubsetOf(operator), true);
750
+ },
751
+ },
752
+ ],
753
+ };