mirror of
https://github.com/eliasstepanik/strudel.git
synced 2026-01-11 13:48:40 +00:00
squeezeflip, tests for add including failing one..
This commit is contained in:
parent
d9e3ff3256
commit
974503160d
@ -263,7 +263,7 @@ export class Pattern {
|
||||
_opSqueezeFlip(other, func) {
|
||||
const thisPat = this;
|
||||
const otherPat = reify(other);
|
||||
return otherPat.fmap((a) => thisPat.fmap((b) => func(a)(b)))._squeezeJoin();
|
||||
return otherPat.fmap((a) => thisPat.fmap((b) => func(b)(a)))._squeezeJoin();
|
||||
}
|
||||
|
||||
_asNumber(silent = false) {
|
||||
@ -754,6 +754,9 @@ for (const [name, op] of Object.entries(composers)) {
|
||||
Pattern.prototype[name + 'Squeeze'] = function (...other) {
|
||||
return op[1](this)._opSqueeze(sequence(other), op[0]);
|
||||
};
|
||||
Pattern.prototype[name + 'SqueezeFlip'] = function (...other) {
|
||||
return op[1](this)._opSqueezeFlip(sequence(other), op[0]);
|
||||
};
|
||||
}
|
||||
|
||||
// methods of Pattern that get callable factories
|
||||
|
||||
@ -51,7 +51,7 @@ const third = Fraction(1, 3);
|
||||
const twothirds = Fraction(2, 3);
|
||||
|
||||
const sameFirst = (a, b) => {
|
||||
return assert.deepStrictEqual(a.firstCycle(), b.firstCycle());
|
||||
return assert.deepStrictEqual(a._sortEventsByPart().firstCycle(), b._sortEventsByPart().firstCycle());
|
||||
};
|
||||
|
||||
describe('TimeSpan', function () {
|
||||
@ -150,6 +150,33 @@ describe('Pattern', function () {
|
||||
assert.equal(pure(3).add(pure(4)).query(st(0, 1))[0].value, 7);
|
||||
});
|
||||
});
|
||||
describe('addFlip()', () => {
|
||||
it('Can add things with structure from second pattern', () => {
|
||||
sameFirst(sequence(1, 2).addFlip(4), sequence(5, 6).struct(true));
|
||||
});
|
||||
});
|
||||
describe('addSqueeze()', () => {
|
||||
it('Can add while squeezing the second pattern inside the events of the first', () => {
|
||||
sameFirst(
|
||||
sequence(1, [2, 3]).addSqueeze(sequence(10, 20, 30)),
|
||||
sequence(
|
||||
[11, 21, 31],
|
||||
[
|
||||
[12, 22, 32],
|
||||
[13, 23, 33],
|
||||
],
|
||||
),
|
||||
);
|
||||
});
|
||||
});
|
||||
describe('addSqueezeFlip()', () => {
|
||||
it('Can add while squeezing the first pattern inside the events of the second', () => {
|
||||
sameFirst(
|
||||
sequence(1, [2, 3]).addSqueezeFlip(10, 20, 30),
|
||||
sequence([11, [12, 13]], [21, [22, 23]], [31, [32, 33]]),
|
||||
);
|
||||
});
|
||||
});
|
||||
describe('sub()', function () {
|
||||
it('Can subtract things', function () {
|
||||
assert.equal(pure(3).sub(pure(4)).query(st(0, 1))[0].value, -1);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user