|
|
@ -12,6 +12,7 @@ describe(`mscript module`, () => {
|
|
|
|
|
|
|
|
|
|
|
|
it ('Should compile very short scripts as strings', () => {
|
|
|
|
it ('Should compile very short scripts as strings', () => {
|
|
|
|
const obj = mscript.interpret(script1)
|
|
|
|
const obj = mscript.interpret(script1)
|
|
|
|
|
|
|
|
assert.ok(typeof obj === 'object', 'Mscript produced an object response');
|
|
|
|
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');
|
|
|
@ -20,6 +21,7 @@ describe(`mscript module`, () => {
|
|
|
|
|
|
|
|
|
|
|
|
it ('Should compile script with count values after command', () => {
|
|
|
|
it ('Should compile script with count values after command', () => {
|
|
|
|
const obj = mscript.interpret(script2)
|
|
|
|
const obj = mscript.interpret(script2)
|
|
|
|
|
|
|
|
assert.ok(typeof obj === 'object', 'Mscript produced an object response');
|
|
|
|
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`);
|
|
|
@ -30,8 +32,11 @@ describe(`mscript module`, () => {
|
|
|
|
|
|
|
|
|
|
|
|
it ('Should compile with implied counts of 1', () => {
|
|
|
|
it ('Should compile with implied counts of 1', () => {
|
|
|
|
const obj = mscript.interpret(script3);
|
|
|
|
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');
|
|
|
|
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', () => {
|
|
|
|
it ('Should compile script with integers as count values', () => {
|
|
|
|
const obj = mscript.interpret(script)
|
|
|
|
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.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.cam , 0, 'Steps cancel each other out on cam');
|
|
|
|
assert.equal(obj.proj, 0, 'Steps cancel each other out on proj');
|
|
|
|
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', () => {
|
|
|
|
it ('Should compile script with device commands', () => {
|
|
|
|
const obj = mscript.interpret(script1);
|
|
|
|
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.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.cam, 50, `Camera gets to 50`);
|
|
|
|
assert.equal(obj.arr[0], 'BF', 'First step is black_forward');
|
|
|
|
assert.equal(obj.arr[0], 'BF', 'First step is black_forward');
|
|
|
@ -78,6 +85,7 @@ PROJ 0`
|
|
|
|
|
|
|
|
|
|
|
|
it ('Should generate steps in correct direction', () => {
|
|
|
|
it ('Should generate steps in correct direction', () => {
|
|
|
|
const obj = mscript.interpret(script2);
|
|
|
|
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.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.cam, 50, `Camera gets to 50`);
|
|
|
|
assert.equal(obj.arr[0], 'BF', 'First step is black_forward');
|
|
|
|
assert.equal(obj.arr[0], 'BF', 'First step is black_forward');
|
|
|
@ -96,13 +104,10 @@ PB 200`;
|
|
|
|
|
|
|
|
|
|
|
|
it ('Should manage state using SET commands', () => {
|
|
|
|
it ('Should manage state using SET commands', () => {
|
|
|
|
const obj = mscript.interpret(script)
|
|
|
|
const obj = mscript.interpret(script)
|
|
|
|
let pass = false;
|
|
|
|
assert.ok(typeof obj === 'object', 'Mscript produced an object response');
|
|
|
|
if (obj.success === true
|
|
|
|
assert.ok(obj.success, 'Mscript labeled output success');
|
|
|
|
&& obj.cam === 0
|
|
|
|
assert.equal(obj.cam, 0, 'Camera state ends at 0');
|
|
|
|
&& obj.proj === 0) {
|
|
|
|
assert.equal(obj.proj, 0, 'Projector state ends at 0');
|
|
|
|
pass = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.ok(pass, `Basic state test`);
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
@ -115,14 +120,11 @@ 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', () => {
|
|
|
|
const obj = mscript.interpret(script1)
|
|
|
|
const obj = mscript.interpret(script1)
|
|
|
|
let pass = false;
|
|
|
|
assert.ok(typeof obj === 'object', 'Mscript produced an object response');
|
|
|
|
if (obj.success === true
|
|
|
|
assert.ok(obj.success, 'Mscript labeled output success');
|
|
|
|
&& obj.cam === 30
|
|
|
|
assert.equal(obj.cam, 30, 'Camera state ends at 30');
|
|
|
|
&& obj.proj === 10
|
|
|
|
assert.equal(obj.proj, 10, 'Projector state ends at 10');
|
|
|
|
&& obj.arr.length === 40) {
|
|
|
|
assert.equal(obj.arr.length, 40, 'Array contains 40 steps');
|
|
|
|
pass = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.ok(pass, 'Basic loop');
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
const script2 = `
|
|
|
|
const script2 = `
|
|
|
@ -135,14 +137,11 @@ END LOOP`;
|
|
|
|
|
|
|
|
|
|
|
|
it ('Should generate a sequence with nested loops', () => {
|
|
|
|
it ('Should generate a sequence with nested loops', () => {
|
|
|
|
const obj = mscript.interpret(script2)
|
|
|
|
const obj = mscript.interpret(script2)
|
|
|
|
let pass = false;
|
|
|
|
assert.ok(typeof obj === 'object', 'Mscript produced an object response');
|
|
|
|
if (obj.success === true
|
|
|
|
assert.ok(obj.success, 'Mscript labeled output success');
|
|
|
|
&& obj.cam === 16
|
|
|
|
assert.equal(obj.cam, 16, 'Camera state ends at 16');
|
|
|
|
&& obj.proj === 16
|
|
|
|
assert.equal(obj.proj, 16, 'Projector state ends at 16');
|
|
|
|
&& obj.arr.length === 32) {
|
|
|
|
assert.equal(obj.arr.length, 32, 'Array contains 32 steps');
|
|
|
|
pass = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.ok(pass, 'Nested loop works');
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
//LOOP W/ CAM and PROJ
|
|
|
|
//LOOP W/ CAM and PROJ
|
|
|
@ -154,68 +153,56 @@ END`;
|
|
|
|
|
|
|
|
|
|
|
|
it ('Should generate a sequence with CAM and PROJ statements', () => {
|
|
|
|
it ('Should generate a sequence with CAM and PROJ statements', () => {
|
|
|
|
const obj = mscript.interpret(script3)
|
|
|
|
const obj = mscript.interpret(script3)
|
|
|
|
let pass = false;
|
|
|
|
assert.ok(typeof obj === 'object', 'Mscript produced an object response');
|
|
|
|
if (obj.success === true
|
|
|
|
assert.ok(obj.success, 'Mscript labeled output success');
|
|
|
|
&& obj.cam === 8
|
|
|
|
assert.equal(obj.cam, 8, 'Camera state ends at 8');
|
|
|
|
&& obj.proj === 8
|
|
|
|
assert.equal(obj.proj, 8, 'Projector state ends at 8');
|
|
|
|
&& obj.arr.length === 16
|
|
|
|
assert.equal(obj.arr.length, 16, 'Array contains 16 steps');
|
|
|
|
&& obj.meta.length === 16
|
|
|
|
assert.equal(obj.meta.length, 16, 'Meta contains 16 steps');
|
|
|
|
&& obj.meta[0] === '0,0,0') {
|
|
|
|
assert.equal(obj.meta[0], '0,0,0', 'First meta step should be 0,0,0');
|
|
|
|
pass = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
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';
|
|
|
|
|
|
|
|
it ( `Should set a light value on camera steps only`, () => {
|
|
|
|
it ( `Should set a light value on camera steps`, () => {
|
|
|
|
|
|
|
|
const obj = mscript.interpret(script1)
|
|
|
|
const obj = mscript.interpret(script1)
|
|
|
|
let pass = false;
|
|
|
|
assert.ok(typeof obj === 'object', 'Mscript produced an object response');
|
|
|
|
if (obj.success === true
|
|
|
|
assert.ok(obj.success, 'Mscript labeled output success');
|
|
|
|
&& obj.cam === 1
|
|
|
|
assert.equal(obj.cam, 1, 'Camera state ends at 1');
|
|
|
|
&& obj.proj === 1
|
|
|
|
assert.equal(obj.proj, 1, 'Projector state ends at 1');
|
|
|
|
&& obj.arr.length === 2
|
|
|
|
assert.equal(obj.arr.length, 2, 'Array contains 2 steps');
|
|
|
|
&& obj.meta.length === 2
|
|
|
|
assert.equal(obj.meta.length, 2, 'Meta contains 2 steps');
|
|
|
|
&& obj.meta[0] === '255,255,255'
|
|
|
|
assert.equal(obj.meta[0], '255,255,255', 'First meta step should be 255,255,255');
|
|
|
|
&& obj.meta[1] === '') {
|
|
|
|
assert.equal(obj.meta[1], '', 'Second meta step should be ""');
|
|
|
|
pass = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.ok(pass, 'Basic light');
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
const script2 = 'L 255,255,255\nCF\nPF\nBF';
|
|
|
|
const script2 = 'L 255,255,255\nCF\nPF\nBF';
|
|
|
|
it ( `Should set light to black on black_forward`, () => {
|
|
|
|
it ( `Should set light to black on black_forward`, () => {
|
|
|
|
const obj = mscript.interpret(script2)
|
|
|
|
const obj = mscript.interpret(script2)
|
|
|
|
let pass = false;
|
|
|
|
assert.ok(typeof obj === 'object', 'Mscript produced an object response');
|
|
|
|
if (obj.success === true
|
|
|
|
assert.ok(obj.success, 'Mscript labeled output success');
|
|
|
|
&& obj.cam === 2
|
|
|
|
assert.equal(obj.cam, 2, 'Camera state ends at 2');
|
|
|
|
&& obj.proj === 1
|
|
|
|
assert.equal(obj.proj, 1, 'Projector state ends at 1');
|
|
|
|
&& obj.arr.length === 3
|
|
|
|
assert.equal(obj.arr.length, 3, 'Array contains 3 steps');
|
|
|
|
&& obj.meta.length === 3
|
|
|
|
assert.equal(obj.meta.length, 3, 'Meta contains 3 steps');
|
|
|
|
&& obj.meta[0] === '255,255,255'
|
|
|
|
assert.equal(obj.meta[0], '255,255,255', 'First meta step should be 255,255,255');
|
|
|
|
&& obj.meta[1] === ''
|
|
|
|
assert.equal(obj.meta[1], '', 'Second meta step should be ""');
|
|
|
|
&& obj.meta[2] === '0,0,0') {
|
|
|
|
assert.equal(obj.meta[2], '0,0,0', 'Third meta step should be ""');
|
|
|
|
pass = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
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';
|
|
|
|
it ( `Should set light within a loop`, () => {
|
|
|
|
it ( `Should set light within a loop`, () => {
|
|
|
|
const obj = mscript.interpret(script3);
|
|
|
|
const obj = mscript.interpret(script3);
|
|
|
|
let pass = false;
|
|
|
|
assert.ok(typeof obj === 'object', 'Mscript produced an object response');
|
|
|
|
if (obj.success === true
|
|
|
|
assert.ok(obj.success, 'Mscript labeled output success');
|
|
|
|
&& obj.cam === 4
|
|
|
|
assert.equal(obj.cam, 4, 'Camera state ends at 4');
|
|
|
|
&& obj.proj === 0
|
|
|
|
assert.equal(obj.proj, 0, 'Projector state ends at 0');
|
|
|
|
&& obj.arr.length === 4
|
|
|
|
assert.equal(obj.arr.length, 4, 'Array contains 4 steps');
|
|
|
|
&& obj.meta.length === 4
|
|
|
|
assert.equal(obj.meta.length, 4, 'Meta contains 4 steps');
|
|
|
|
&& obj.meta[0] === '1,1,1'
|
|
|
|
assert.equal(obj.meta[0], '1,1,1', 'First meta step should be 1,1,1');
|
|
|
|
&& obj.meta[3] === '2,2,2') {
|
|
|
|
assert.equal(obj.meta[3], '2,2,2', 'Fourth meta step should be 2,2,2');
|
|
|
|
pass = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.ok(pass, 'Basic light');
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
@ -228,7 +215,7 @@ END
|
|
|
|
PF 10`
|
|
|
|
PF 10`
|
|
|
|
it ('Should generate a fade', () => {
|
|
|
|
it ('Should generate a fade', () => {
|
|
|
|
const obj = mscript.interpret(script1)
|
|
|
|
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.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`);
|
|
|
|
assert.equal(obj.proj, 10, 'Projector moves forward 10 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', () => {
|
|
|
|
it ('Should generate a fade and immediately set a light value after', () => {
|
|
|
|
const obj = mscript.interpret(script2)
|
|
|
|
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.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');
|
|
|
|
assert.equal(obj.arr.length, 34, 'There are 34 steps in the script');
|
|
|
|
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', () => {
|
|
|
|
/*describe('mscript - Variables', () => {
|
|
|
|
const script1 =
|
|
|
|
const script1 =
|
|
|
|