Skip to content

Commit ad39367

Browse 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

File tree

1 file changed

+9
-19
lines changed

1 file changed

+9
-19
lines changed

test/parallel/test-zlib-const.js

Lines 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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy