Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ad39367

Browse filesBrowse files
Trottmarco-ippolito
authored andcommitted
test: enforce strict mode in test-zlib-const
Instead of checking that assignments fail silently in sloppy mode, check that they throw in strict mode. PR-URL: #56689 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 9a1e314 commit ad39367
Copy full SHA for ad39367

File tree

Expand file treeCollapse file tree

1 file changed

+9
-19
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+9
-19
lines changed
Open diff view settings
Collapse file

‎test/parallel/test-zlib-const.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-zlib-const.js
+9-19Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* eslint-disable strict */
1+
'use strict';
22
require('../common');
33
const assert = require('assert');
44

@@ -9,27 +9,17 @@ assert.strictEqual(zlib.constants.Z_OK, 0,
99
'Expected Z_OK to be 0;',
1010
`got ${zlib.constants.Z_OK}`,
1111
].join(' '));
12-
zlib.constants.Z_OK = 1;
13-
assert.strictEqual(zlib.constants.Z_OK, 0,
14-
[
15-
'Z_OK should be immutable.',
16-
`Expected to get 0, got ${zlib.constants.Z_OK}`,
17-
].join(' '));
12+
13+
assert.throws(() => { zlib.constants.Z_OK = 1; },
14+
TypeError, 'zlib.constants.Z_OK should be immutable');
1815

1916
assert.strictEqual(zlib.codes.Z_OK, 0,
2017
`Expected Z_OK to be 0; got ${zlib.codes.Z_OK}`);
21-
zlib.codes.Z_OK = 1;
22-
assert.strictEqual(zlib.codes.Z_OK, 0,
23-
[
24-
'Z_OK should be immutable.',
25-
`Expected to get 0, got ${zlib.codes.Z_OK}`,
26-
].join(' '));
27-
zlib.codes = { Z_OK: 1 };
28-
assert.strictEqual(zlib.codes.Z_OK, 0,
29-
[
30-
'Z_OK should be immutable.',
31-
`Expected to get 0, got ${zlib.codes.Z_OK}`,
32-
].join(' '));
18+
assert.throws(() => { zlib.codes.Z_OK = 1; },
19+
TypeError, 'zlib.codes.Z_OK should be immutable');
20+
21+
assert.throws(() => { zlib.codes = { Z_OK: 1 }; },
22+
TypeError, 'zlib.codes should be immutable');
3323

3424
assert.ok(Object.isFrozen(zlib.codes),
3525
[

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.