This is my first time writing a unit-test in SC. I have a function which I want to test. When Evaluating the test class, it somehow doesn’t like my classvar
decleration, and I have no idea why!
(
~makeQ = {
var vals = List.new;
var q = 1;
var tmp;
while {
q.fuzzyEqual(0) <= 0.999
} {
tmp = ~get_val_in_rng.(q, [ 0.5, 0.25, 0.125, 0.0625 ]);
tmp.postln;
vals.add(tmp);
q = q - tmp;
};
vals
}
)
and here is my test class:
(
TestQ : UnitTest {
classvar units;
*initClass {
units = Array.fill(10, {var q = ~makeQ.(); q.postln});
}
setUp {
"Setting up test...".postln;
}
test_run {
units.do {
arg unit;
this.assertEquals(unit.sum, 1);
}
}
};
)
SC interpreter says:
ERROR: Command line parse failed
→ nil
ERROR: syntax error, unexpected CLASSVAR, expecting ‘}’
in interpreted text
line 4 char 9:
classvar units;
^^^^^^^^
Any helps are much appreciated!