more tests

This commit is contained in:
alex 2022-01-24 22:57:52 +00:00
parent 30b7eb7c73
commit e0023a722b
2 changed files with 16 additions and 5 deletions

View File

@ -148,7 +148,7 @@ class Pattern {
split_queries() {
splitQueries() {
// Splits queries at cycle boundaries. This makes some calculations
// easier to express, as all events are then constrained to happen within
// a cycle.

View File

@ -1,9 +1,8 @@
import 'fraction.js';
import Fraction from 'fraction.js'
import { strict as assert } from 'assert';
import {TimeSpan, Hap} from "../js/strudel.mjs";
import {TimeSpan, Hap, Pattern, pure} from "../js/strudel.mjs";
describe('TimeSpan', function() {
describe('equal()', function() {
@ -11,6 +10,11 @@ describe('TimeSpan', function() {
assert.equal((new TimeSpan(0,4)).equals(new TimeSpan(0,4)), true);
});
});
describe('splitCycles', function() {
it('Should split two cycles into two', function() {
assert.equal(new TimeSpan(Fraction(0),Fraction(2)).spanCycles.length, 2)
})
})
});
describe('Hap', function() {
@ -20,4 +24,11 @@ describe('Hap', function() {
});
});
});
describe('Pattern', function() {
describe('pure', function () {
it('Can make a pattern', function() {
assert.equal(pure("hello").query(new TimeSpan(Fraction(0.5), Fraction(2.5))).length, 3)
})
})
})