@loadmill/executer 0.1.34 → 0.1.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -38,7 +38,7 @@ suite('Post Script Executor', () => {
38
38
  assert.deepStrictEqual(result.arr, [1, '2', null, {}, [], undefined]);
39
39
  });
40
40
  });
41
-
41
+
42
42
  describe('Override dynamic data', () => {
43
43
  it('should override dynamic var with user code', () => {
44
44
  const dynamicVar = 'arnon';
@@ -129,7 +129,7 @@ suite('Post Script Executor', () => {
129
129
  });
130
130
 
131
131
  describe('arrow function declarations', () => {
132
- const result = runPostScript({ staticContext: { $: {}, __: {} } }, {},
132
+ const result = runPostScript({ staticContext: { $: {}, __: {} } }, {},
133
133
  `const add = (x,y) => {
134
134
  return x + y;
135
135
  }`
@@ -200,9 +200,9 @@ suite('Post Script Executor', () => {
200
200
  a: 1,
201
201
  b: 2
202
202
  };
203
-
203
+
204
204
  it('should read values from static data', () => {
205
- const res = runPostScript({ staticContext: { $, __: {} } }, {},
205
+ const res = runPostScript({ staticContext: { $, __: {} } }, {},
206
206
  `
207
207
  resBodyCopy = $;
208
208
  a = $.a;
@@ -251,7 +251,7 @@ suite('Post Script Executor', () => {
251
251
 
252
252
  describe('code longer than 1 second throws error', () => {
253
253
  it('should throw exceeded allowed execution time error', () => {
254
- assert.throws(() => runPostScript({ staticContext: { $: {}, __: {} } }, {},
254
+ assert.throws(() => runPostScript({ staticContext: { $: {}, __: {} } }, {},
255
255
  `
256
256
  const wait = (ms) => {
257
257
  const start = Date.now();
@@ -270,7 +270,7 @@ suite('Post Script Executor', () => {
270
270
  // possible solution here is using isolated vm (seperated process --max-old-space-size)
271
271
  describe('Memory abuse', () => {
272
272
  // it('should not allow memory bomb', () => {
273
- // const res = runPostScript({ staticContext: { $: {}, __: {} } }, {},
273
+ // const res = runPostScript({ staticContext: { $: {}, __: {} } }, {},
274
274
  // `
275
275
  // (new Array(Math.pow(2, 32) - 1)).fill(1);
276
276
  // `);
@@ -324,28 +324,28 @@ suite('Post Script Executor', () => {
324
324
  const result = runPostScript({ staticContext: { $: {}, __: {} } }, {}, 'const { x } = { x: 1 };');
325
325
  assert.equal(result.x, 1);
326
326
  });
327
-
327
+
328
328
  it('should detect declaration of 2-level nested property', () => {
329
329
  const result = runPostScript({ staticContext: { $: {}, __: {} } }, {}, `
330
330
  let { x: { y } } = { x: { y: 1 } };
331
331
  `);
332
332
  assert.equal(result.y, 1);
333
333
  });
334
-
334
+
335
335
  it('should detect declaration of 3-level nested property', () => {
336
336
  const result = runPostScript({ staticContext: { $: {}, __: {} } }, {}, `
337
337
  let { x: { y: { z } } } = { x: { y: { z: 1 } } };
338
338
  `);
339
339
  assert.equal(result.z, 1);
340
340
  });
341
-
341
+
342
342
  it('should detect declaration of 4-level nested property', () => {
343
343
  const result = runPostScript({ staticContext: { $: {}, __: {} } }, {}, `
344
344
  let { x: { y: { z: { w } } } } = { x: { y: { z: { w: 1 } } } };
345
345
  `);
346
346
  assert.equal(result.w, 1);
347
347
  });
348
-
348
+
349
349
  it('should detect declaration of two (2) root properties', () => {
350
350
  const result = runPostScript({ staticContext: { $: {}, __: {} } }, {}, `
351
351
  let { x, y } = { x: 1, y: 2 };
@@ -353,7 +353,7 @@ suite('Post Script Executor', () => {
353
353
  assert.equal(result.x, 1);
354
354
  assert.equal(result.y, 2);
355
355
  });
356
-
356
+
357
357
  it('should detect declaration of a root property and a nested property', () => {
358
358
  const result = runPostScript({ staticContext: { $: {}, __: {} } }, {}, `
359
359
  let { x, y: { z } } = { x: 1, y: { z: 2 } };
@@ -361,7 +361,7 @@ suite('Post Script Executor', () => {
361
361
  assert.equal(result.x, 1);
362
362
  assert.equal(result.z, 2);
363
363
  });
364
-
364
+
365
365
  it('should detect rest element object declaration', () => {
366
366
  const result = runPostScript({ staticContext: { $: {}, __: {} } }, {}, `
367
367
  const {x, ...theRest } = { x: 1, y: 2, z: 3 };
@@ -370,22 +370,22 @@ suite('Post Script Executor', () => {
370
370
  assert.equal(result.theRest.y, 2);
371
371
  assert.equal(result.theRest.z, 3);
372
372
  });
373
-
373
+
374
374
  it('should detect implicit declaration of root property ', () => {
375
375
  const result = runPostScript({ staticContext: { $: {}, __: {} } }, {}, '({ x } = { x: 1 });');
376
376
  assert.equal(result.x, 1);
377
377
  });
378
-
378
+
379
379
  it('should detect implicit declaration of 2-level nested property ', () => {
380
380
  const result = runPostScript({ staticContext: { $: {}, __: {} } }, {}, '({ x: { y } } = { x: { y: 1 } });');
381
381
  assert.equal(result.y, 1);
382
382
  });
383
-
383
+
384
384
  it('should detect implicit declaration of 3-level nested property ', () => {
385
385
  const result = runPostScript({ staticContext: { $: {}, __: {} } }, {}, '({ x: { y: { z } } } = { x: { y: { z: 1 } } });');
386
386
  assert.equal(result.z, 1);
387
387
  });
388
-
388
+
389
389
  it('should detect implicit declaration of two (2) root properties', () => {
390
390
  const result = runPostScript({ staticContext: { $: {}, __: {} } }, {}, `
391
391
  ({ x, y } = { x: 1, y: 2 });
@@ -393,7 +393,7 @@ suite('Post Script Executor', () => {
393
393
  assert.equal(result.x, 1);
394
394
  assert.equal(result.y, 2);
395
395
  });
396
-
396
+
397
397
  it('should detect implicit declaration of a root property and a nested property', () => {
398
398
  const result = runPostScript({ staticContext: { $: {}, __: {} } }, {}, `
399
399
  ({ x, y: { z } } = { x: 1, y: { z: 2 } });
@@ -410,7 +410,7 @@ suite('Post Script Executor', () => {
410
410
  `);
411
411
  assert.equal(result.x, 1);
412
412
  });
413
-
413
+
414
414
  it('should detect 2 destructured array values', () => {
415
415
  const result = runPostScript({ staticContext: { $: {}, __: {} } }, {}, `
416
416
  const [ x, y ] = [ 1, 2 ];
@@ -418,35 +418,35 @@ suite('Post Script Executor', () => {
418
418
  assert.equal(result.x, 1);
419
419
  assert.equal(result.y, 2);
420
420
  });
421
-
421
+
422
422
  it('should detect spread array values', () => {
423
423
  const result = runPostScript({ staticContext: { $: {}, __: {} } }, {}, 'let [...elements] = [1, 2];');
424
424
  assert.equal(result.elements.length, 2);
425
425
  });
426
-
426
+
427
427
  it('should detect "regular" & spread array values', () => {
428
428
  const result = runPostScript({ staticContext: { $: {}, __: {} } }, {}, 'let [a, b, ...rest] = [10, 20, 30, 40, 50];');
429
429
  assert.equal(result.a,10);
430
430
  assert.equal(result.b,20);
431
431
  assert.equal(result.rest.length,3);
432
432
  });
433
-
433
+
434
434
  it('should detect implicit declaration of array destructuring ', () => {
435
435
  const result = runPostScript({ staticContext: { $: {}, __: {} } }, {}, '([ x ] = [ 1 ]);');
436
436
  assert.equal(result.x, 1);
437
437
  });
438
-
438
+
439
439
  it('should detect 2 implicit declarations of array destructuring ', () => {
440
440
  const result = runPostScript({ staticContext: { $: {}, __: {} } }, {}, '([ x, y ] = [ 1, 2 ]);');
441
441
  assert.equal(result.x, 1);
442
442
  assert.equal(result.y, 2);
443
443
  });
444
-
444
+
445
445
  it('should detect implicit spread array values', () => {
446
446
  const result = runPostScript({ staticContext: { $: {}, __: {} } }, {}, '[...elements] = [1, 2];');
447
447
  assert.equal(result.elements.length, 2);
448
448
  });
449
-
449
+
450
450
  it('should detect implicit "regular" & spread array values', () => {
451
451
  const result = runPostScript({ staticContext: { $: {}, __: {} } }, {}, 'let [a, b, ...rest] = [10, 20, 30, 40, 50];');
452
452
  assert.equal(result.a,10);