Skip to content

Commit ff65a2e

Browse files
committed
test: explain sloppy mode for test-global
Add a comment explaining why test-global runs in sloppy mode rather than strict mode. While in the file, make some minor changes to the module ordering and spacing to conform with our test writing guide. Also reordered arguments in `assert.strictEqual()` to match documentation. PR-URL: #14604 Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Gibson Fahnestock <[email protected]>
1 parent 17547c4 commit ff65a2e

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

test/parallel/test-global.js

+10-6
Original file line numberDiff line numberDiff line change
@@ -19,28 +19,32 @@
1919
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
2020
// USE OR OTHER DEALINGS IN THE SOFTWARE.
2121

22+
// This test cannot run in strict mode because it tests that `baseFoo` is
23+
// treated as a global without being declared with `var`/`let`/`const`.
24+
2225
/* eslint-disable strict */
2326
const common = require('../common');
24-
const path = require('path');
27+
2528
const assert = require('assert');
29+
const path = require('path');
2630

2731
common.globalCheck = false;
2832

2933
baseFoo = 'foo'; // eslint-disable-line no-undef
3034
global.baseBar = 'bar';
3135

32-
assert.strictEqual('foo', global.baseFoo,
36+
assert.strictEqual(global.baseFoo, 'foo',
3337
'x -> global.x in base level not working');
3438

35-
assert.strictEqual('bar',
36-
baseBar, // eslint-disable-line no-undef
39+
assert.strictEqual(baseBar, // eslint-disable-line no-undef
40+
'bar',
3741
'global.x -> x in base level not working');
3842

3943
const mod = require(path.join(common.fixturesDir, 'global', 'plain'));
4044
const fooBar = mod.fooBar;
4145

42-
assert.strictEqual('foo', fooBar.foo, 'x -> global.x in sub level not working');
46+
assert.strictEqual(fooBar.foo, 'foo', 'x -> global.x in sub level not working');
4347

44-
assert.strictEqual('bar', fooBar.bar, 'global.x -> x in sub level not working');
48+
assert.strictEqual(fooBar.bar, 'bar', 'global.x -> x in sub level not working');
4549

4650
assert.strictEqual(Object.prototype.toString.call(global), '[object global]');

0 commit comments

Comments
 (0)