Skip to content

Commit 2a219ed

Browse files
Trottaduh95
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 2b6a82d commit 2a219ed

File tree

1 file changed

+9
-19
lines changed

1 file changed

+9
-19
lines changed

test/parallel/test-zlib-const.js

+9-19
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)