|
|
|
@ -12,6 +12,7 @@ describe(`mscript module`, () => {
|
|
|
|
|
|
|
|
|
|
it ('Should compile very short scripts as strings', () => {
|
|
|
|
|
const obj = mscript.interpret(script1)
|
|
|
|
|
assert.ok(typeof obj === 'object', 'Mscript produced an object response');
|
|
|
|
|
assert.ok(obj.success, `Simple script1 compiles`);
|
|
|
|
|
assert.equal(obj.cam, 0, 'Camera gets equaled out');
|
|
|
|
|
assert.equal(obj.proj, 0, 'Projector gets cancelled out');
|
|
|
|
@ -20,6 +21,7 @@ describe(`mscript module`, () => {
|
|
|
|
|
|
|
|
|
|
it ('Should compile script with count values after command', () => {
|
|
|
|
|
const obj = mscript.interpret(script2)
|
|
|
|
|
assert.ok(typeof obj === 'object', 'Mscript produced an object response');
|
|
|
|
|
assert.ok(obj.success, `Simple script2 compiles`);
|
|
|
|
|
assert.equal(obj.arr[0], 'CF', `First step is a camera_forward command`);
|
|
|
|
|
assert.equal(obj.cam, 3, `Camera finished on frame 3`);
|
|
|
|
@ -30,8 +32,11 @@ describe(`mscript module`, () => {
|
|
|
|
|
|
|
|
|
|
it ('Should compile with implied counts of 1', () => {
|
|
|
|
|
const obj = mscript.interpret(script3);
|
|
|
|
|
assert.ok(typeof obj === 'object', 'Mscript produced an object response');
|
|
|
|
|
assert.ok(obj.success, 'Simple script3 with implied counts compiles');
|
|
|
|
|
//console.log(obj);
|
|
|
|
|
assert.equal(obj.cam, 1, 'Camera state should be at 1');
|
|
|
|
|
assert.equal(obj.proj, 1, 'Projector state should be at 1');
|
|
|
|
|
assert.equal(obj.arr.length, 2, 'Generate sequence of 2 steps');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
@ -47,6 +52,7 @@ BB 3`;
|
|
|
|
|
|
|
|
|
|
it ('Should compile script with integers as count values', () => {
|
|
|
|
|
const obj = mscript.interpret(script)
|
|
|
|
|
assert.ok(typeof obj === 'object', 'Mscript produced an object response');
|
|
|
|
|
assert.ok(obj.success, `Script with integers cancels out count, but generates list of commands`)
|
|
|
|
|
assert.equal(obj.cam , 0, 'Steps cancel each other out on cam');
|
|
|
|
|
assert.equal(obj.proj, 0, 'Steps cancel each other out on proj');
|
|
|
|
@ -61,6 +67,7 @@ PROJ 50`;
|
|
|
|
|
|
|
|
|
|
it ('Should compile script with device commands', () => {
|
|
|
|
|
const obj = mscript.interpret(script1);
|
|
|
|
|
assert.ok(typeof obj === 'object', 'Mscript produced an object response');
|
|
|
|
|
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');
|
|
|
|
@ -78,6 +85,7 @@ PROJ 0`
|
|
|
|
|
|
|
|
|
|
it ('Should generate steps in correct direction', () => {
|
|
|
|
|
const obj = mscript.interpret(script2);
|
|
|
|
|
assert.ok(typeof obj === 'object', 'Mscript produced an object response');
|
|
|
|
|
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');
|
|
|
|
@ -96,13 +104,10 @@ PB 200`;
|
|
|
|
|
|
|
|
|
|
it ('Should manage state using SET commands', () => {
|
|
|
|
|
const obj = mscript.interpret(script)
|
|
|
|
|
let pass = false;
|
|
|
|
|
if (obj.success === true
|
|
|
|
|
&& obj.cam === 0
|
|
|
|
|
&& obj.proj === 0) {
|
|
|
|
|
pass = true;
|
|
|
|
|
}
|
|
|
|
|
assert.ok(pass, `Basic state test`);
|
|
|
|
|
assert.ok(typeof obj === 'object', 'Mscript produced an object response');
|
|
|
|
|
assert.ok(obj.success, 'Mscript labeled output success');
|
|
|
|
|
assert.equal(obj.cam, 0, 'Camera state ends at 0');
|
|
|
|
|
assert.equal(obj.proj, 0, 'Projector state ends at 0');
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
@ -115,14 +120,11 @@ END LOOP`;
|
|
|
|
|
|
|
|
|
|
it ('Should generate a looped sequence between LOOP and END LOOP statements', () => {
|
|
|
|
|
const obj = mscript.interpret(script1)
|
|
|
|
|
let pass = false;
|
|
|
|
|
if (obj.success === true
|
|
|
|
|
&& obj.cam === 30
|
|
|
|
|
&& obj.proj === 10
|
|
|
|
|
&& obj.arr.length === 40) {
|
|
|
|
|
pass = true;
|
|
|
|
|
}
|
|
|
|
|
assert.ok(pass, 'Basic loop');
|
|
|
|
|
assert.ok(typeof obj === 'object', 'Mscript produced an object response');
|
|
|
|
|
assert.ok(obj.success, 'Mscript labeled output success');
|
|
|
|
|
assert.equal(obj.cam, 30, 'Camera state ends at 30');
|
|
|
|
|
assert.equal(obj.proj, 10, 'Projector state ends at 10');
|
|
|
|
|
assert.equal(obj.arr.length, 40, 'Array contains 40 steps');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const script2 = `
|
|
|
|
@ -135,14 +137,11 @@ END LOOP`;
|
|
|
|
|
|
|
|
|
|
it ('Should generate a sequence with nested loops', () => {
|
|
|
|
|
const obj = mscript.interpret(script2)
|
|
|
|
|
let pass = false;
|
|
|
|
|
if (obj.success === true
|
|
|
|
|
&& obj.cam === 16
|
|
|
|
|
&& obj.proj === 16
|
|
|
|
|
&& obj.arr.length === 32) {
|
|
|
|
|
pass = true;
|
|
|
|
|
}
|
|
|
|
|
assert.ok(pass, 'Nested loop works');
|
|
|
|
|
assert.ok(typeof obj === 'object', 'Mscript produced an object response');
|
|
|
|
|
assert.ok(obj.success, 'Mscript labeled output success');
|
|
|
|
|
assert.equal(obj.cam, 16, 'Camera state ends at 16');
|
|
|
|
|
assert.equal(obj.proj, 16, 'Projector state ends at 16');
|
|
|
|
|
assert.equal(obj.arr.length, 32, 'Array contains 32 steps');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
//LOOP W/ CAM and PROJ
|
|
|
|
@ -154,68 +153,56 @@ END`;
|
|
|
|
|
|
|
|
|
|
it ('Should generate a sequence with CAM and PROJ statements', () => {
|
|
|
|
|
const obj = mscript.interpret(script3)
|
|
|
|
|
let pass = false;
|
|
|
|
|
if (obj.success === true
|
|
|
|
|
&& obj.cam === 8
|
|
|
|
|
&& obj.proj === 8
|
|
|
|
|
&& obj.arr.length === 16
|
|
|
|
|
&& obj.meta.length === 16
|
|
|
|
|
&& obj.meta[0] === '0,0,0') {
|
|
|
|
|
pass = true;
|
|
|
|
|
}
|
|
|
|
|
assert.ok(pass, 'Basic cam/proj loop');
|
|
|
|
|
assert.ok(typeof obj === 'object', 'Mscript produced an object response');
|
|
|
|
|
assert.ok(obj.success, 'Mscript labeled output success');
|
|
|
|
|
assert.equal(obj.cam, 8, 'Camera state ends at 8');
|
|
|
|
|
assert.equal(obj.proj, 8, 'Projector state ends at 8');
|
|
|
|
|
assert.equal(obj.arr.length, 16, 'Array contains 16 steps');
|
|
|
|
|
assert.equal(obj.meta.length, 16, 'Meta contains 16 steps');
|
|
|
|
|
assert.equal(obj.meta[0], '0,0,0', 'First meta step should be 0,0,0');
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('mscript - Light', () => {
|
|
|
|
|
//Lighting tests
|
|
|
|
|
const script1 = 'L 255,255,255\nCF\nPF';
|
|
|
|
|
|
|
|
|
|
it ( `Should set a light value on camera steps`, () => {
|
|
|
|
|
it ( `Should set a light value on camera steps only`, () => {
|
|
|
|
|
const obj = mscript.interpret(script1)
|
|
|
|
|
let pass = false;
|
|
|
|
|
if (obj.success === true
|
|
|
|
|
&& obj.cam === 1
|
|
|
|
|
&& obj.proj === 1
|
|
|
|
|
&& obj.arr.length === 2
|
|
|
|
|
&& obj.meta.length === 2
|
|
|
|
|
&& obj.meta[0] === '255,255,255'
|
|
|
|
|
&& obj.meta[1] === '') {
|
|
|
|
|
pass = true;
|
|
|
|
|
}
|
|
|
|
|
assert.ok(pass, 'Basic light');
|
|
|
|
|
assert.ok(typeof obj === 'object', 'Mscript produced an object response');
|
|
|
|
|
assert.ok(obj.success, 'Mscript labeled output success');
|
|
|
|
|
assert.equal(obj.cam, 1, 'Camera state ends at 1');
|
|
|
|
|
assert.equal(obj.proj, 1, 'Projector state ends at 1');
|
|
|
|
|
assert.equal(obj.arr.length, 2, 'Array contains 2 steps');
|
|
|
|
|
assert.equal(obj.meta.length, 2, 'Meta contains 2 steps');
|
|
|
|
|
assert.equal(obj.meta[0], '255,255,255', 'First meta step should be 255,255,255');
|
|
|
|
|
assert.equal(obj.meta[1], '', 'Second meta step should be ""');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const script2 = 'L 255,255,255\nCF\nPF\nBF';
|
|
|
|
|
it ( `Should set light to black on black_forward`, () => {
|
|
|
|
|
const obj = mscript.interpret(script2)
|
|
|
|
|
let pass = false;
|
|
|
|
|
if (obj.success === true
|
|
|
|
|
&& obj.cam === 2
|
|
|
|
|
&& obj.proj === 1
|
|
|
|
|
&& obj.arr.length === 3
|
|
|
|
|
&& obj.meta.length === 3
|
|
|
|
|
&& obj.meta[0] === '255,255,255'
|
|
|
|
|
&& obj.meta[1] === ''
|
|
|
|
|
&& obj.meta[2] === '0,0,0') {
|
|
|
|
|
pass = true;
|
|
|
|
|
}
|
|
|
|
|
assert.ok(pass, 'Basic black');
|
|
|
|
|
assert.ok(typeof obj === 'object', 'Mscript produced an object response');
|
|
|
|
|
assert.ok(obj.success, 'Mscript labeled output success');
|
|
|
|
|
assert.equal(obj.cam, 2, 'Camera state ends at 2');
|
|
|
|
|
assert.equal(obj.proj, 1, 'Projector state ends at 1');
|
|
|
|
|
assert.equal(obj.arr.length, 3, 'Array contains 3 steps');
|
|
|
|
|
assert.equal(obj.meta.length, 3, 'Meta contains 3 steps');
|
|
|
|
|
assert.equal(obj.meta[0], '255,255,255', 'First meta step should be 255,255,255');
|
|
|
|
|
assert.equal(obj.meta[1], '', 'Second meta step should be ""');
|
|
|
|
|
assert.equal(obj.meta[2], '0,0,0', 'Third meta step should be ""');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const script3 = 'LOOP 2\nL 1,1,1\nCF\nL 2,2,2\nCF\nEND';
|
|
|
|
|
it ( `Should set light within a loop`, () => {
|
|
|
|
|
const obj = mscript.interpret(script3);
|
|
|
|
|
let pass = false;
|
|
|
|
|
if (obj.success === true
|
|
|
|
|
&& obj.cam === 4
|
|
|
|
|
&& obj.proj === 0
|
|
|
|
|
&& obj.arr.length === 4
|
|
|
|
|
&& obj.meta.length === 4
|
|
|
|
|
&& obj.meta[0] === '1,1,1'
|
|
|
|
|
&& obj.meta[3] === '2,2,2') {
|
|
|
|
|
pass = true;
|
|
|
|
|
}
|
|
|
|
|
assert.ok(pass, 'Basic light');
|
|
|
|
|
assert.ok(typeof obj === 'object', 'Mscript produced an object response');
|
|
|
|
|
assert.ok(obj.success, 'Mscript labeled output success');
|
|
|
|
|
assert.equal(obj.cam, 4, 'Camera state ends at 4');
|
|
|
|
|
assert.equal(obj.proj, 0, 'Projector state ends at 0');
|
|
|
|
|
assert.equal(obj.arr.length, 4, 'Array contains 4 steps');
|
|
|
|
|
assert.equal(obj.meta.length, 4, 'Meta contains 4 steps');
|
|
|
|
|
assert.equal(obj.meta[0], '1,1,1', 'First meta step should be 1,1,1');
|
|
|
|
|
assert.equal(obj.meta[3], '2,2,2', 'Fourth meta step should be 2,2,2');
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
@ -228,7 +215,7 @@ END
|
|
|
|
|
PF 10`
|
|
|
|
|
it ('Should generate a fade', () => {
|
|
|
|
|
const obj = mscript.interpret(script1)
|
|
|
|
|
//console.dir(obj)
|
|
|
|
|
assert.ok(typeof obj === 'object', 'Mscript produced an object response');
|
|
|
|
|
assert.ok(obj.success, 'Basic fade compiles');
|
|
|
|
|
assert.equal(obj.cam, 72, `Camera moves forward 72 frames`);
|
|
|
|
|
assert.equal(obj.proj, 10, 'Projector moves forward 10 frames');
|
|
|
|
@ -248,7 +235,7 @@ CF 10`
|
|
|
|
|
|
|
|
|
|
it ('Should generate a fade and immediately set a light value after', () => {
|
|
|
|
|
const obj = mscript.interpret(script2)
|
|
|
|
|
//console.dir(obj)
|
|
|
|
|
assert.ok(typeof obj === 'object', 'Mscript produced an object response');
|
|
|
|
|
assert.ok(obj.success, 'Mscript labeled output success');
|
|
|
|
|
assert.equal(obj.cam, 34, 'There are 34 camera frames');
|
|
|
|
|
assert.equal(obj.arr.length, 34, 'There are 34 steps in the script');
|
|
|
|
@ -258,7 +245,54 @@ CF 10`
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
//secondary
|
|
|
|
|
describe('mscript - Secondary', () => {
|
|
|
|
|
const script = `
|
|
|
|
|
LOOP 10
|
|
|
|
|
C2F
|
|
|
|
|
P2F
|
|
|
|
|
END
|
|
|
|
|
`
|
|
|
|
|
it('Should generate an array with secondary devices', () => {
|
|
|
|
|
const obj = mscript.interpret(script)
|
|
|
|
|
assert.ok(typeof obj === 'object', 'Mscript produced an object response');
|
|
|
|
|
assert.ok(obj.success, 'Mscript labeled output success');
|
|
|
|
|
assert.equal(obj.arr.length, 20, 'Script should produce 20 steps');
|
|
|
|
|
})
|
|
|
|
|
const script2 = `
|
|
|
|
|
C2F 1000
|
|
|
|
|
CB 1000
|
|
|
|
|
SET PROJ2 200
|
|
|
|
|
PB 200`;
|
|
|
|
|
|
|
|
|
|
it ('Should correctly determine state of secondary device', () => {
|
|
|
|
|
const obj = mscript.interpret(script2);
|
|
|
|
|
assert.ok(typeof obj === 'object', 'Mscript produced an object response');
|
|
|
|
|
assert.ok(obj.success, 'Mscript parsed the script correctly');
|
|
|
|
|
assert.equal(obj.arr.length, 2200, 'Script should produce 2200 steps');
|
|
|
|
|
assert.equal(obj.cam, -1000, 'Camera should be at -1000');
|
|
|
|
|
assert.equal(obj.cam2, 1000, 'Camera 2 should be at 1000');
|
|
|
|
|
assert.equal(obj.proj, -200, 'Projector should be at -200');
|
|
|
|
|
assert.equal(obj.proj2, 200, 'Projector 2 should be set to 200');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const script3 = `
|
|
|
|
|
LOOP 5
|
|
|
|
|
CF 10
|
|
|
|
|
PB 200
|
|
|
|
|
P2F
|
|
|
|
|
END`;
|
|
|
|
|
|
|
|
|
|
it ('Should correctly determine state of secondary device in loops', () => {
|
|
|
|
|
const obj = mscript.interpret(script3);
|
|
|
|
|
assert.ok(typeof obj === 'object', 'Mscript produced an object response');
|
|
|
|
|
assert.ok(obj.success, 'Mscript parsed the script correctly');
|
|
|
|
|
assert.equal(obj.arr.length, 1055, 'Script should produce 1055 steps');
|
|
|
|
|
assert.equal(obj.cam, 50, 'Camera should be at -1000');
|
|
|
|
|
assert.ok(typeof obj.cam2 === 'undefined', 'Camera 2 should not exist');
|
|
|
|
|
assert.equal(obj.proj, -1000, 'Projector should be at -1000');
|
|
|
|
|
assert.equal(obj.proj2, 5, 'Projector 2 should be set to 5');
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
/*describe('mscript - Variables', () => {
|
|
|
|
|
const script1 =
|
|
|
|
|