Skip to content

Commit

Permalink
Test that polfill actually managed to be created
Browse files Browse the repository at this point in the history
  • Loading branch information
bmeck committed Aug 2, 2019
1 parent d6a11a2 commit 13ccb23
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
8 changes: 5 additions & 3 deletions test/fixtures/intrinsic-mutation.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
'use strict';
Object.defineProperty(
String.prototype,
Symbol('fake-polyfill-property'), {
Object.prototype,
'flatten', {
enumerable: false,
value: null
// purposefully named something that
// would never land in JS itself
value: function smoosh() {}
}
);
2 changes: 2 additions & 0 deletions test/fixtures/print-intrinsic-mutation-name.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
'use strict';
console.log({}.flatten.name);
21 changes: 16 additions & 5 deletions test/parallel/test-preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const fixtureB = fixtures.path('printB.js');
const fixtureC = fixtures.path('printC.js');
const fixtureD = fixtures.path('define-global.js');
const fixtureE = fixtures.path('intrinsic-mutation.js');
const fixtureF = fixtures.path('print-intrinsic-mutation-name.js');
const fixtureThrows = fixtures.path('throws_error4.js');

// Test preloading a single module works
Expand Down Expand Up @@ -65,18 +66,28 @@ childProcess.exec(

// Test that preload can be used with --frozen-intrinsics
childProcess.exec(
`"${nodeBinary}" --frozen-intrinsics ${preloadOption([fixtureE])}-e "console.log('hello');"`,
`"${nodeBinary}" --frozen-intrinsics ${
preloadOption([fixtureE])
} ${
fixtureF
}`,
function(err, stdout) {
assert.ifError(err);
assert.strictEqual(stdout, 'hello\n');
assert.strictEqual(stdout, 'smoosh\n');
}
);
const workerSrc = `const {Worker} = require('worker_threads');new Worker(${JSON.stringify(fixtureA)});`;
const workerSrc = `new (require('worker_threads').Worker)(${fixtureF});`;
childProcess.exec(
`"${nodeBinary}" --frozen-intrinsics ${preloadOption([fixtureE])}-e ${JSON.stringify(workerSrc)}`,
`"${
nodeBinary
}" --frozen-intrinsics ${
preloadOption([fixtureE])
}-e ${
workerSrc
}`,
function(err, stdout) {
assert.ifError(err);
assert.strictEqual(stdout, 'A\n');
assert.strictEqual(stdout, 'smoosh\n');
}
);

Expand Down

0 comments on commit 13ccb23

Please sign in to comment.