• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3require('../common');
4
5const { Script } = require('vm');
6const assert = require('assert');
7
8const source = 'function x() {} const y = x();';
9
10const script = new Script(source);
11let cachedData = script.createCachedData();
12assert(cachedData instanceof Buffer);
13
14assert(!new Script(source, { cachedData }).cachedDataRejected);
15
16script.runInNewContext();
17
18for (let i = 0; i < 10; i += 1) {
19  cachedData = script.createCachedData();
20
21  assert(!new Script(source, { cachedData }).cachedDataRejected);
22}
23