Skip to content

Commit

Permalink
Inline requires: cleanup bailout test case
Browse files Browse the repository at this point in the history
Summary:
Cleanup one of a set of tests intended to check that the input is *not* modified in this particular case.

The standard way to do this is to use `snapshot: false`, which checks that input == output. This test used `snapshot: true` only because the input was not correctly formatted, so the output had whitespace differences.

Allows for clearer grouping of bail-out tests as we introduce memoization later in the stack.

Changelog: Internal

Reviewed By: vzaidman

Differential Revision: D62084971

fbshipit-source-id: 2c5d856cc3a7c64feb919c46093ceb2af8c7d42b
  • Loading branch information
robhogan authored and facebook-github-bot committed Sep 3, 2024
1 parent 00df4ef commit a09e494
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,6 @@ var foo = require(\\"foo\\");
"
`;

exports[`inline-requires does not transform require calls if it is not needed: does not transform require calls if it is not needed 1`] = `
"
function test () {
function require(condition) {
if (!condition) {
throw new Error('The condition is false');
}
}
require('test');
}
↓ ↓ ↓ ↓ ↓ ↓
function test() {
function require(condition) {
if (!condition) {
throw new Error('The condition is false');
}
}
require('test');
}
"
`;

exports[`inline-requires ensures that the inlined require still points to the global require function even if local require is not called: ensures that the inlined require still points to the global require function even if local require is not called 1`] = `
"
const foo = require('foo');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,19 +146,18 @@ pluginTester<PluginOptions, State>({
snapshot: false,
},

'does not transform require calls if it is not needed': {
'does not transform require calls that are already inline': {
code: `
function test () {
function test() {
function require(condition) {
if (!condition) {
throw new Error('The condition is false');
}
}
require('test');
}
`,
snapshot: true,
snapshot: false,
},

'inlines requires that are referenced before the require statement': {
Expand Down

0 comments on commit a09e494

Please sign in to comment.