Update mscript tests. Increase coverage.
This commit is contained in:
parent
d8e5e4521a
commit
c169b7fbae
|
@ -11,7 +11,7 @@ describe(`mscript module`, () => {
|
||||||
const script3 = `CF\nPF`
|
const script3 = `CF\nPF`
|
||||||
|
|
||||||
it ('Should compile very short scripts as strings', () => {
|
it ('Should compile very short scripts as strings', () => {
|
||||||
let obj = mscript.interpret(script1)
|
const obj = mscript.interpret(script1)
|
||||||
assert.ok(obj.success, `Simple script1 compiles`);
|
assert.ok(obj.success, `Simple script1 compiles`);
|
||||||
assert.equal(obj.cam, 0, 'Camera gets equaled out');
|
assert.equal(obj.cam, 0, 'Camera gets equaled out');
|
||||||
assert.equal(obj.proj, 0, 'Projector gets cancelled out');
|
assert.equal(obj.proj, 0, 'Projector gets cancelled out');
|
||||||
|
@ -19,7 +19,7 @@ describe(`mscript module`, () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it ('Should compile script with count values after command', () => {
|
it ('Should compile script with count values after command', () => {
|
||||||
let obj = mscript.interpret(script2)
|
const obj = mscript.interpret(script2)
|
||||||
assert.ok(obj.success, `Simple script2 compiles`);
|
assert.ok(obj.success, `Simple script2 compiles`);
|
||||||
assert.equal(obj.arr[0], 'CF', `First step is a camera_forward command`);
|
assert.equal(obj.arr[0], 'CF', `First step is a camera_forward command`);
|
||||||
assert.equal(obj.cam, 3, `Camera finished on frame 3`);
|
assert.equal(obj.cam, 3, `Camera finished on frame 3`);
|
||||||
|
@ -29,7 +29,7 @@ describe(`mscript module`, () => {
|
||||||
|
|
||||||
|
|
||||||
it ('Should compile with implied counts of 1', () => {
|
it ('Should compile with implied counts of 1', () => {
|
||||||
let obj = mscript.interpret(script3);
|
const obj = mscript.interpret(script3);
|
||||||
assert.ok(obj.success, 'Simple script3 with implied counts compiles');
|
assert.ok(obj.success, 'Simple script3 with implied counts compiles');
|
||||||
//console.log(obj);
|
//console.log(obj);
|
||||||
});
|
});
|
||||||
|
@ -46,35 +46,44 @@ BF 3
|
||||||
BB 3`;
|
BB 3`;
|
||||||
|
|
||||||
it ('Should compile script with integers as count values', () => {
|
it ('Should compile script with integers as count values', () => {
|
||||||
mscript.interpret(script, (obj) => {
|
const obj = mscript.interpret(script)
|
||||||
let pass = false;
|
assert.ok(obj.success, `Script with integers cancels out count, but generates list of commands`)
|
||||||
if (obj.success === true
|
assert.equal(obj.cam , 0, 'Steps cancel each other out on cam');
|
||||||
&& obj.cam === 0
|
assert.equal(obj.proj, 0, 'Steps cancel each other out on proj');
|
||||||
&& obj.proj === 0
|
assert.equal(obj.arr.length, 26, 'Total of 26 steps in sequence');
|
||||||
&& obj.arr.length === 26) {
|
|
||||||
pass = true;
|
|
||||||
}
|
|
||||||
assert.ok(pass, `Script with integers cancels out count, but generates list of commands`)
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe(`mscript - Device commands with counts`, () => {
|
describe(`mscript - Device commands`, () => {
|
||||||
const script = `
|
const script1 = `
|
||||||
CAM 50
|
CAM 50
|
||||||
PROJ 50`;
|
PROJ 50`;
|
||||||
|
|
||||||
it ('Should compile script with device commands', () => {
|
it ('Should compile script with device commands', () => {
|
||||||
mscript.interpret(script, (obj) => {
|
const obj = mscript.interpret(script1);
|
||||||
let pass = false;
|
assert.ok(obj.success, `Script generates 100 step sequence with 50 steps on each device`);
|
||||||
if (obj.success === true
|
assert.equal(obj.cam, 50, `Camera gets to 50`);
|
||||||
&& obj.cam === 50
|
assert.equal(obj.arr[0], 'BF', 'First step is black_forward');
|
||||||
&& obj.proj === 50
|
assert.equal(obj.proj, 50, `Projector gets to 50`);
|
||||||
&& obj.arr.length === 100) {
|
assert.equal(obj.arr[50], 'PF', '51st step is projector_forward');
|
||||||
pass = true;
|
assert.equal(obj.arr.length, 100, `Array is 100 steps long`);
|
||||||
}
|
|
||||||
assert.ok(pass, `Script generates 100 step sequence with 50 steps on each device`)
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const script2 = `
|
||||||
|
SET CAM 0
|
||||||
|
SET PROJ 50
|
||||||
|
|
||||||
|
CAM 50
|
||||||
|
PROJ 0`
|
||||||
|
|
||||||
|
it ('Should generate steps in correct direction', () => {
|
||||||
|
const obj = mscript.interpret(script2);
|
||||||
|
assert.ok(obj.success, `Script generates 100 step sequence with 50 steps on each device`);
|
||||||
|
assert.equal(obj.cam, 50, `Camera gets to 50`);
|
||||||
|
assert.equal(obj.arr[0], 'BF', 'First step is black_forward');
|
||||||
|
assert.equal(obj.proj, 0, `Projector gets to 0`);
|
||||||
|
assert.equal(obj.arr[50], 'PB', '51st step is projector_backward');
|
||||||
|
assert.equal(obj.arr.length, 100, `Array is 100 steps long`);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -86,7 +95,7 @@ SET PROJ 200
|
||||||
PB 200`;
|
PB 200`;
|
||||||
|
|
||||||
it ('Should manage state using SET commands', () => {
|
it ('Should manage state using SET commands', () => {
|
||||||
mscript.interpret(script, (obj) => {
|
const obj = mscript.interpret(script)
|
||||||
let pass = false;
|
let pass = false;
|
||||||
if (obj.success === true
|
if (obj.success === true
|
||||||
&& obj.cam === 0
|
&& obj.cam === 0
|
||||||
|
@ -95,7 +104,6 @@ PB 200`;
|
||||||
}
|
}
|
||||||
assert.ok(pass, `Basic state test`);
|
assert.ok(pass, `Basic state test`);
|
||||||
});
|
});
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('mscript - Loop', () => {
|
describe('mscript - Loop', () => {
|
||||||
|
@ -106,7 +114,7 @@ LOOP 10
|
||||||
END LOOP`;
|
END LOOP`;
|
||||||
|
|
||||||
it ('Should generate a looped sequence between LOOP and END LOOP statements', () => {
|
it ('Should generate a looped sequence between LOOP and END LOOP statements', () => {
|
||||||
mscript.interpret(script1, (obj) => {
|
const obj = mscript.interpret(script1)
|
||||||
let pass = false;
|
let pass = false;
|
||||||
if (obj.success === true
|
if (obj.success === true
|
||||||
&& obj.cam === 30
|
&& obj.cam === 30
|
||||||
|
@ -116,7 +124,6 @@ END LOOP`;
|
||||||
}
|
}
|
||||||
assert.ok(pass, 'Basic loop');
|
assert.ok(pass, 'Basic loop');
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
const script2 = `
|
const script2 = `
|
||||||
LOOP 4
|
LOOP 4
|
||||||
|
@ -127,7 +134,7 @@ LOOP 4
|
||||||
END LOOP`;
|
END LOOP`;
|
||||||
|
|
||||||
it ('Should generate a sequence with nested loops', () => {
|
it ('Should generate a sequence with nested loops', () => {
|
||||||
mscript.interpret(script2, (obj) => {
|
const obj = mscript.interpret(script2)
|
||||||
let pass = false;
|
let pass = false;
|
||||||
if (obj.success === true
|
if (obj.success === true
|
||||||
&& obj.cam === 16
|
&& obj.cam === 16
|
||||||
|
@ -137,7 +144,6 @@ END LOOP`;
|
||||||
}
|
}
|
||||||
assert.ok(pass, 'Nested loop works');
|
assert.ok(pass, 'Nested loop works');
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
//LOOP W/ CAM and PROJ
|
//LOOP W/ CAM and PROJ
|
||||||
const script3 = `
|
const script3 = `
|
||||||
|
@ -147,7 +153,7 @@ LOOP 2
|
||||||
END`;
|
END`;
|
||||||
|
|
||||||
it ('Should generate a sequence with CAM and PROJ statements', () => {
|
it ('Should generate a sequence with CAM and PROJ statements', () => {
|
||||||
mscript.interpret(script3, (obj) => {
|
const obj = mscript.interpret(script3)
|
||||||
let pass = false;
|
let pass = false;
|
||||||
if (obj.success === true
|
if (obj.success === true
|
||||||
&& obj.cam === 8
|
&& obj.cam === 8
|
||||||
|
@ -159,14 +165,14 @@ END`;
|
||||||
}
|
}
|
||||||
assert.ok(pass, 'Basic cam/proj loop');
|
assert.ok(pass, 'Basic cam/proj loop');
|
||||||
});
|
});
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('mscript - Light', () => {
|
describe('mscript - Light', () => {
|
||||||
//Lighting tests
|
//Lighting tests
|
||||||
const script1 = 'L 255,255,255\nCF\nPF';
|
const script1 = 'L 255,255,255\nCF\nPF';
|
||||||
|
|
||||||
mscript.interpret(script1, (obj) => {
|
it ( `Should set a light value on camera steps`, () => {
|
||||||
|
const obj = mscript.interpret(script1)
|
||||||
let pass = false;
|
let pass = false;
|
||||||
if (obj.success === true
|
if (obj.success === true
|
||||||
&& obj.cam === 1
|
&& obj.cam === 1
|
||||||
|
@ -181,7 +187,8 @@ describe('mscript - Light', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
const script2 = 'L 255,255,255\nCF\nPF\nBF';
|
const script2 = 'L 255,255,255\nCF\nPF\nBF';
|
||||||
mscript.interpret(script2, (obj) => {
|
it ( `Should set light to black on black_forward`, () => {
|
||||||
|
const obj = mscript.interpret(script2)
|
||||||
let pass = false;
|
let pass = false;
|
||||||
if (obj.success === true
|
if (obj.success === true
|
||||||
&& obj.cam === 2
|
&& obj.cam === 2
|
||||||
|
@ -196,7 +203,8 @@ describe('mscript - Light', () => {
|
||||||
assert.ok(pass, 'Basic black');
|
assert.ok(pass, 'Basic black');
|
||||||
});
|
});
|
||||||
const script3 = 'LOOP 2\nL 1,1,1\nCF\nL 2,2,2\nCF\nEND';
|
const script3 = 'LOOP 2\nL 1,1,1\nCF\nL 2,2,2\nCF\nEND';
|
||||||
mscript.interpret(script3, (obj) => {
|
it ( `Should set light within a loop`, () => {
|
||||||
|
const obj = mscript.interpret(script3);
|
||||||
let pass = false;
|
let pass = false;
|
||||||
if (obj.success === true
|
if (obj.success === true
|
||||||
&& obj.cam === 4
|
&& obj.cam === 4
|
||||||
|
@ -218,7 +226,8 @@ describe('mscript - Fade', () => {
|
||||||
CF
|
CF
|
||||||
END
|
END
|
||||||
PF 10`
|
PF 10`
|
||||||
mscript.interpret(script1, (obj) => {
|
it ('Should generate a fade', () => {
|
||||||
|
const obj = mscript.interpret(script1)
|
||||||
//console.dir(obj)
|
//console.dir(obj)
|
||||||
assert.ok(obj.success, 'Basic fade compiles');
|
assert.ok(obj.success, 'Basic fade compiles');
|
||||||
assert.equal(obj.cam, 72, `Camera moves forward 72 frames`);
|
assert.equal(obj.cam, 72, `Camera moves forward 72 frames`);
|
||||||
|
@ -227,7 +236,7 @@ PF 10`
|
||||||
assert.equal(obj.light[0], '0,0,0', 'Fade starts with starting color');
|
assert.equal(obj.light[0], '0,0,0', 'Fade starts with starting color');
|
||||||
assert.equal(obj.light[71], '10,20,30', 'Fade ends with ending color');
|
assert.equal(obj.light[71], '10,20,30', 'Fade ends with ending color');
|
||||||
assert.equal(obj.light[72], '', 'Frame after fade is default color');
|
assert.equal(obj.light[72], '', 'Frame after fade is default color');
|
||||||
});
|
})
|
||||||
|
|
||||||
const script2 =
|
const script2 =
|
||||||
`
|
`
|
||||||
|
@ -236,7 +245,9 @@ CF
|
||||||
END
|
END
|
||||||
L 225,125,10
|
L 225,125,10
|
||||||
CF 10`
|
CF 10`
|
||||||
mscript.interpret(script2, (obj) => {
|
|
||||||
|
it ('Should generate a fade and immediately set a light value after', () => {
|
||||||
|
const obj = mscript.interpret(script2)
|
||||||
//console.dir(obj)
|
//console.dir(obj)
|
||||||
assert.ok(obj.success, 'Mscript labeled output success');
|
assert.ok(obj.success, 'Mscript labeled output success');
|
||||||
assert.equal(obj.cam, 34, 'There are 34 camera frames');
|
assert.equal(obj.cam, 34, 'There are 34 camera frames');
|
||||||
|
@ -244,7 +255,7 @@ CF 10`
|
||||||
assert.equal(obj.light[0], '25,255,125', 'First frame is equal to start color');
|
assert.equal(obj.light[0], '25,255,125', 'First frame is equal to start color');
|
||||||
assert.equal(obj.light[23], '225,125,10', 'Last frame in fade is equal to end color');
|
assert.equal(obj.light[23], '225,125,10', 'Last frame in fade is equal to end color');
|
||||||
assert.equal(obj.light[24], '225,125,10', 'First frame after fade is set using Light command');
|
assert.equal(obj.light[24], '225,125,10', 'First frame after fade is set using Light command');
|
||||||
});
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
/*describe('mscript - Variables', () => {
|
/*describe('mscript - Variables', () => {
|
||||||
|
|
Loading…
Reference in New Issue