@@ -67,6 +67,195 @@ map(f, list(1, 2));",
6767}
6868` ;
6969
70+ exports [` Cascading js errors work properly 1: expectParsedError 1` ] = `
71+ Object {
72+ " alertResult" : Array [],
73+ " code" : " function make_alternating_stream(stream) {
74+ return pair (head (stream ), () => make_alternating_stream (
75+ negate_whole_stream (
76+ stream_tail (stream ))));
77+ }
78+
79+ function negate_whole_stream(stream) {
80+ return pair (- head (stream ), () => negate_whole_stream (stream_tail (stream )));
81+ }
82+
83+ const ones = pair(1, () => ones);
84+ eval_stream(make_alternating_stream(enum_stream(1, 9)), 9);",
85+ "displayResult": Array [],
86+ "errors": Array [
87+ ExceptionError {
88+ " error" : [Error : head (xs ) expects a pair as argument xs , but encountered null ],
89+ " location" : SourceLocation {
90+ " end" : Position {
91+ " column" : 29 ,
92+ " line" : 8 ,
93+ },
94+ " start" : Position {
95+ " column" : 17 ,
96+ " line" : 8 ,
97+ },
98+ },
99+ " severity" : " Error" ,
100+ " type" : " Runtime" ,
101+ } ,
102+ ],
103+ "parsedErrors": "Line 8: Error: head(xs) expects a pair as argument xs, but encountered null",
104+ "result": undefined,
105+ "resultStatus": "error",
106+ "transpiled": "const native = $$NATIVE_STORAGE;
107+ const callIfFuncAndRightArgs = native.operators.get(\\ "callIfFuncAndRightArgs\\ ");
108+ const boolOrErr = native.operators.get(\\ "boolOrErr\\ ");
109+ const wrap = native.operators.get(\\ "wrap\\ ");
110+ const unaryOp = native.operators.get(\\ "unaryOp\\ ");
111+ const binaryOp = native.operators.get(\\ "binaryOp\\ ");
112+ const throwIfTimeout = native.operators.get(\\ "throwIfTimeout\\ ");
113+ const setProp = native.operators.get(\\ "setProp\\ ");
114+ const getProp = native.operators.get(\\ "getProp\\ ");
115+ let lastStatementResult = undefined;
116+ const globals = $NATIVE_STORAGE.globals;
117+ (( <globals redacted > ) => {
118+ return (() => {
119+ {
120+ {
121+ const make_alternating_stream = wrap (stream => {
122+ return {
123+ isTail: true ,
124+ function: pair ,
125+ functionName: \\" pair\\ " ,
126+ arguments: [callIfFuncAndRightArgs (head , 2 , 14 , stream ), wrap (() => ({
127+ isTail: true ,
128+ function: make_alternating_stream ,
129+ functionName: \\" make_alternating_stream\\ " ,
130+ arguments: [callIfFuncAndRightArgs (negate_whole_stream , 3 , 36 , callIfFuncAndRightArgs (stream_tail , 4 , 40 , stream ))],
131+ line: 2 ,
132+ column: 34
133+ }), \\" () => make_alternating_stream(negate_whole_stream(stream_tail(stream)))\\ " )],
134+ line: 2 ,
135+ column: 9
136+ };
137+ }, \\" function make_alternating_stream(stream) {\\\\ n return pair(head(stream), () => make_alternating_stream(negate_whole_stream(stream_tail(stream))));\\\\ n}\\ " );
138+ const negate_whole_stream = wrap (stream => {
139+ return {
140+ isTail: true ,
141+ function: pair ,
142+ functionName: \\" pair\\ " ,
143+ arguments: [unaryOp (\\" -\\ " , callIfFuncAndRightArgs (head , 8 , 17 , stream ), 8 , 16 ), wrap (() => ({
144+ isTail: true ,
145+ function: negate_whole_stream ,
146+ functionName: \\" negate_whole_stream\\ " ,
147+ arguments: [callIfFuncAndRightArgs (stream_tail , 8 , 57 , stream )],
148+ line: 8 ,
149+ column: 37
150+ }), \\" () => negate_whole_stream(stream_tail(stream))\\ " )],
151+ line: 8 ,
152+ column: 11
153+ };
154+ }, \\" function negate_whole_stream(stream) {\\\\ n return pair(-head(stream), () => negate_whole_stream(stream_tail(stream)));\\\\ n}\\ " );
155+ const ones = callIfFuncAndRightArgs (pair , 11 , 13 , 1 , wrap (() => ({
156+ isTail: false ,
157+ value: ones
158+ }), \\" () => ones\\ " ));
159+ lastStatementResult = eval (\\" callIfFuncAndRightArgs(eval_stream, 12, 0, callIfFuncAndRightArgs(make_alternating_stream, 12, 12, callIfFuncAndRightArgs(enum_stream, 12, 36, 1, 9)), 9);\\ " );
160+ globals .variables .set (\\" make_alternating_stream\\ " , {
161+ kind: \\" const\\ " ,
162+ getValue : () => {
163+ return make_alternating_stream ;
164+ }
165+ });
166+ globals .variables .set (\\" negate_whole_stream\\ " , {
167+ kind: \\" const\\ " ,
168+ getValue : () => {
169+ return negate_whole_stream ;
170+ }
171+ });
172+ globals .variables .set (\\" ones\\ " , {
173+ kind: \\" const\\ " ,
174+ getValue : () => {
175+ return ones ;
176+ }
177+ });
178+ }
179+ }
180+ return lastStatementResult ;
181+ })();
182+ } )();
183+ ",
184+ "visualiseListResult": Array [],
185+ }
186+ `;
187+
188+ exports[`Cascading js errors work properly: expectParsedError 1`] = `
189+ Object {
190+ " alertResult" : Array [],
191+ " code" : " function h(p) {
192+ return head (p );
193+ }
194+
195+ h(null);",
196+ "displayResult": Array [],
197+ "errors": Array [
198+ ExceptionError {
199+ " error" : [Error : head (xs ) expects a pair as argument xs , but encountered null ],
200+ " location" : SourceLocation {
201+ " end" : Position {
202+ " column" : 16 ,
203+ " line" : 2 ,
204+ },
205+ " start" : Position {
206+ " column" : 9 ,
207+ " line" : 2 ,
208+ },
209+ },
210+ " severity" : " Error" ,
211+ " type" : " Runtime" ,
212+ } ,
213+ ],
214+ "parsedErrors": "Line 2: Error: head(xs) expects a pair as argument xs, but encountered null",
215+ "result": undefined,
216+ "resultStatus": "error",
217+ "transpiled": "const native = $$NATIVE_STORAGE;
218+ const callIfFuncAndRightArgs = native.operators.get(\\"callIfFuncAndRightArgs\\");
219+ const boolOrErr = native.operators.get(\\"boolOrErr\\");
220+ const wrap = native.operators.get(\\"wrap\\");
221+ const unaryOp = native.operators.get(\\"unaryOp\\");
222+ const binaryOp = native.operators.get(\\"binaryOp\\");
223+ const throwIfTimeout = native.operators.get(\\"throwIfTimeout\\");
224+ const setProp = native.operators.get(\\"setProp\\");
225+ const getProp = native.operators.get(\\"getProp\\");
226+ let lastStatementResult = undefined;
227+ const globals = $NATIVE_STORAGE.globals;
228+ (( <globals redacted > ) => {
229+ return (() => {
230+ {
231+ {
232+ const h = wrap (p => {
233+ return {
234+ isTail: true ,
235+ function: head ,
236+ functionName: \\" head\\ " ,
237+ arguments: [p ],
238+ line: 2 ,
239+ column: 9
240+ };
241+ }, \\" function h(p) {\\\\ n return head(p);\\\\ n}\\ " );
242+ lastStatementResult = eval (\\" callIfFuncAndRightArgs(h, 5, 0, null);\\ " );
243+ globals .variables .set (\\" h\\ " , {
244+ kind: \\" const\\ " ,
245+ getValue : () => {
246+ return h ;
247+ }
248+ });
249+ }
250+ }
251+ return lastStatementResult ;
252+ })();
253+ } )();
254+ ",
255+ "visualiseListResult": Array [],
256+ }
257+ `;
258+
70259exports[`Error when accessing inherited property of object: expectParsedError 1`] = `
71260Object {
72261 " alertResult" : Array [],
@@ -3097,6 +3286,28 @@ Object {
30973286 " parsedErrors" : " Line 1: Expected number on right hand side of operation, got string." ,
30983287 " result" : undefined ,
30993288 " resultStatus" : " error" ,
3289+ " transpiled" : " const native = $$NATIVE_STORAGE;
3290+ const callIfFuncAndRightArgs = native .operators .get (\\" callIfFuncAndRightArgs\\ " );
3291+ const boolOrErr = native .operators .get (\\" boolOrErr\\ " );
3292+ const wrap = native .operators .get (\\" wrap\\ " );
3293+ const unaryOp = native .operators .get (\\" unaryOp\\ " );
3294+ const binaryOp = native .operators .get (\\" binaryOp\\ " );
3295+ const throwIfTimeout = native .operators .get (\\" throwIfTimeout\\ " );
3296+ const setProp = native .operators .get (\\" setProp\\ " );
3297+ const getProp = native .operators .get (\\" getProp\\ " );
3298+ let lastStatementResult = undefined ;
3299+ const globals = $NATIVE_STORAGE .globals ;
3300+ (( <globals redacted > ) => {
3301+ return (() => {
3302+ {
3303+ {
3304+ lastStatementResult = eval (\\" binaryOp(\\\\\\ " * \\\\\\" , 12, 'string', 1, 0);\\ " );
3305+ }
3306+ }
3307+ return lastStatementResult ;
3308+ })();
3309+ })();
3310+ " ,
31003311 " visualiseListResult" : Array [],
31013312}
31023313`;
0 commit comments