When mscript compilation fails, throw error in console.
This commit is contained in:
parent
b51b7e8481
commit
0eaefb2b48
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"version": "1.8.137",
|
"version": "1.8.138",
|
||||||
"ext_port": 1111,
|
"ext_port": 1111,
|
||||||
"profiles": {
|
"profiles": {
|
||||||
"mcopy": {
|
"mcopy": {
|
||||||
|
|
|
@ -140,7 +140,14 @@ PF 1`;
|
||||||
compile() {
|
compile() {
|
||||||
const data = this.editor.getValue();
|
const data = this.editor.getValue();
|
||||||
const mscript = new mscript_1.default();
|
const mscript = new mscript_1.default();
|
||||||
const output = mscript.interpret(data);
|
let output = null;
|
||||||
|
try {
|
||||||
|
output = mscript.interpret(data);
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
mse.console.print(err.toString());
|
||||||
|
return;
|
||||||
|
}
|
||||||
const len = output.arr.length;
|
const len = output.arr.length;
|
||||||
const cam2 = typeof output.cam2 !== 'undefined' ? `, CAM2 : ${output.cam2}` : '';
|
const cam2 = typeof output.cam2 !== 'undefined' ? `, CAM2 : ${output.cam2}` : '';
|
||||||
const proj2 = typeof output.proj2 !== 'undefined' ? `, PROJ2 : ${output.proj2}` : '';
|
const proj2 = typeof output.proj2 !== 'undefined' ? `, PROJ2 : ${output.proj2}` : '';
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "mcopy-app",
|
"name": "mcopy-app",
|
||||||
"version": "1.8.137",
|
"version": "1.8.138",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "mcopy-app",
|
"name": "mcopy-app",
|
||||||
"version": "1.8.137",
|
"version": "1.8.138",
|
||||||
"description": "GUI for the mcopy small gauge film optical printer platform",
|
"description": "GUI for the mcopy small gauge film optical printer platform",
|
||||||
"main": "main.js",
|
"main": "main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
|
@ -162,7 +162,14 @@ PF 1`;
|
||||||
compile () {
|
compile () {
|
||||||
const data : string = this.editor.getValue();
|
const data : string = this.editor.getValue();
|
||||||
const mscript : Mscript = new Mscript();
|
const mscript : Mscript = new Mscript();
|
||||||
const output : any = mscript.interpret(data);
|
let output : any = null;
|
||||||
|
try {
|
||||||
|
output = mscript.interpret(data);
|
||||||
|
this.raw = '';
|
||||||
|
} catch (err) {
|
||||||
|
mse.console.print(err.toString());
|
||||||
|
return;
|
||||||
|
}
|
||||||
const len : number = output.arr.length;
|
const len : number = output.arr.length;
|
||||||
const cam2 : string = typeof output.cam2 !== 'undefined' ? `, CAM2 : ${output.cam2}` : '';
|
const cam2 : string = typeof output.cam2 !== 'undefined' ? `, CAM2 : ${output.cam2}` : '';
|
||||||
const proj2 : string = typeof output.proj2 !== 'undefined' ? `, PROJ2 : ${output.proj2}` : '';
|
const proj2 : string = typeof output.proj2 !== 'undefined' ? `, PROJ2 : ${output.proj2}` : '';
|
||||||
|
|
|
@ -126,12 +126,16 @@ LOOP 10
|
||||||
PF
|
PF
|
||||||
END`;
|
END`;
|
||||||
|
|
||||||
it('Should SET state within LOOP', () => {
|
it('Should fail when SET state within LOOP', () => {
|
||||||
const obj = mscript.interpret(script2)
|
let errorCaught = false;
|
||||||
assert.ok(typeof obj === 'object', 'Mscript produced an object response');
|
try {
|
||||||
assert.ok(obj.success, 'Mscript labeled output success');
|
const obj = mscript.interpret(script2);
|
||||||
assert.equal(obj.cam, 10, 'Camera state ends at 10');
|
} catch (err) {
|
||||||
assert.equal(obj.proj, 11, 'Projector state should be 11');
|
//fail silently
|
||||||
|
errorCaught = true;
|
||||||
|
}
|
||||||
|
assert.ok(typeof obj === 'undefined', 'Mscript fails to produce an output object');
|
||||||
|
assert.ok(errorCaught, 'Error should be thrown by script');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"version": "1.8.137",
|
"version": "1.8.138",
|
||||||
"ext_port": 1111,
|
"ext_port": 1111,
|
||||||
"profiles": {
|
"profiles": {
|
||||||
"mcopy": {
|
"mcopy": {
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "mcopy",
|
"name": "mcopy",
|
||||||
"version": "1.8.137",
|
"version": "1.8.138",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "mcopy",
|
"name": "mcopy",
|
||||||
"version": "1.8.137",
|
"version": "1.8.138",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"alert": "file:app/lib/alert",
|
"alert": "file:app/lib/alert",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "mcopy",
|
"name": "mcopy",
|
||||||
"version": "1.8.137",
|
"version": "1.8.138",
|
||||||
"description": "Small gauge film optical printer platform",
|
"description": "Small gauge film optical printer platform",
|
||||||
"main": "build.js",
|
"main": "build.js",
|
||||||
"directories": {
|
"directories": {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"version": "1.8.137",
|
"version": "1.8.138",
|
||||||
"ext_port": 1111,
|
"ext_port": 1111,
|
||||||
"profiles": {
|
"profiles": {
|
||||||
"mcopy": {
|
"mcopy": {
|
||||||
|
|
Loading…
Reference in New Issue