mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-11 05:38:34 +00:00
get tests working
This commit is contained in:
parent
40f2355fbf
commit
615d441381
@ -30,7 +30,7 @@ class TimeSpan {
|
||||
|
||||
while (end.gt(begin)) {
|
||||
// If begin and end are in the same cycle, we're done.
|
||||
if (begin.sam() == end_sam) {
|
||||
if (begin.sam().equals(end_sam)) {
|
||||
spans.push(new TimeSpan(begin, this.end))
|
||||
break
|
||||
}
|
||||
@ -73,7 +73,7 @@ class TimeSpan {
|
||||
intersection_e(other) {
|
||||
// Like 'sect', but raises an exception if the timespans don't intersect.
|
||||
result = this.intersection(other)
|
||||
if (result == None) {
|
||||
if (result.equals(None)) {
|
||||
// TODO - raise exception
|
||||
// raise ValueError(f'TimeSpan {self} and TimeSpan {other} do not intersect')
|
||||
}
|
||||
@ -89,7 +89,7 @@ class TimeSpan {
|
||||
}
|
||||
}
|
||||
|
||||
class Event {
|
||||
class Hap {
|
||||
|
||||
/*
|
||||
Event class, representing a value active during the timespan
|
||||
@ -111,28 +111,19 @@ class Event {
|
||||
with_span(func) {
|
||||
// Returns a new event with the function f applies to the event timespan.
|
||||
var whole = this.whole ? func(self.whole) : undefined
|
||||
return new Event(whole, func(this.part), this.value)
|
||||
return new Hap(whole, func(this.part), this.value)
|
||||
}
|
||||
|
||||
with_value(func) {
|
||||
// Returns a new event with the function f applies to the event value.
|
||||
return new Event(this.whole, this.part, func(this.value))
|
||||
return new Hap(this.whole, this.part, func(this.value))
|
||||
}
|
||||
|
||||
has_onset() {
|
||||
// Test whether the event contains the onset, i.e that
|
||||
// the beginning of the part is the same as that of the whole timespan."""
|
||||
return (this.whole != undefined) && (this.whole.begin == this.part.begin)
|
||||
return (this.whole != undefined) && (this.whole.begin.equals(this.part.begin))
|
||||
}
|
||||
}
|
||||
|
||||
window.bar = function() {
|
||||
console.log("aha" + typeof(Fraction(3.5)));
|
||||
}
|
||||
|
||||
//console.log((new TimeSpan(3.5,4)).midpoint);
|
||||
|
||||
var ts = new TimeSpan(0,4)
|
||||
console.log((new Event(new TimeSpan(0,2), new TimeSpan(0,2), "aha")).has_onset());
|
||||
var x = new TimeSpan(0,4)
|
||||
console.log(ts.equals(x))
|
||||
export {TimeSpan, Hap}
|
||||
8191
package-lock.json
generated
8191
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -24,6 +24,10 @@
|
||||
},
|
||||
"homepage": "https://github.com/yaxu/strudel#readme",
|
||||
"devDependencies": {
|
||||
"fraction.js": "^4.1.2"
|
||||
"fraction.js": "^4.1.2",
|
||||
"mocha": "^9.1.4"
|
||||
},
|
||||
"dependencies": {
|
||||
"snowpack": "^3.8.8"
|
||||
}
|
||||
}
|
||||
|
||||
23
test/pattern.test.mjs
Normal file
23
test/pattern.test.mjs
Normal file
@ -0,0 +1,23 @@
|
||||
|
||||
import 'fraction.js';
|
||||
|
||||
import { strict as assert } from 'assert';
|
||||
|
||||
import {TimeSpan, Hap} from "../js/strudel.mjs";
|
||||
|
||||
describe('TimeSpan', function() {
|
||||
describe('equal()', function() {
|
||||
it('Should be equal to the same value', function() {
|
||||
assert.equal((new TimeSpan(0,4)).equals(new TimeSpan(0,4)), true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Hap', function() {
|
||||
describe('has_onset()', function() {
|
||||
it('True if part includes onset from whole', function() {
|
||||
assert.equal(new Hap(new TimeSpan(0,1), new TimeSpan(0,1), "thing").has_onset(), true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user