summaryrefslogtreecommitdiff
path: root/test/parallel/test-vm-low-stack-space.js
blob: 6a49a983d54f5e7c4d294faed3b776600ab27b56 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
'use strict';
require('../common');
const assert = require('assert');
const vm = require('vm');

function a() {
  try {
    return a();
  } catch {
    // Throw an exception as near to the recursion-based RangeError as possible.
    return vm.runInThisContext('() => 42')();
  }
}

assert.strictEqual(a(), 42);

function b() {
  try {
    return b();
  } catch {
    // This writes a lot of noise to stderr, but it still works.
    return vm.runInNewContext('() => 42')();
  }
}

assert.strictEqual(b(), 42);