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: https://github.com/nodejs/node/pull/56689 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
869ea331f3
commit
08eeddfa83
@ -1,4 +1,4 @@
|
||||
/* eslint-disable strict */
|
||||
'use strict';
|
||||
require('../common');
|
||||
const assert = require('assert');
|
||||
|
||||
@ -9,27 +9,17 @@ assert.strictEqual(zlib.constants.Z_OK, 0,
|
||||
'Expected Z_OK to be 0;',
|
||||
`got ${zlib.constants.Z_OK}`,
|
||||
].join(' '));
|
||||
zlib.constants.Z_OK = 1;
|
||||
assert.strictEqual(zlib.constants.Z_OK, 0,
|
||||
[
|
||||
'Z_OK should be immutable.',
|
||||
`Expected to get 0, got ${zlib.constants.Z_OK}`,
|
||||
].join(' '));
|
||||
|
||||
assert.throws(() => { zlib.constants.Z_OK = 1; },
|
||||
TypeError, 'zlib.constants.Z_OK should be immutable');
|
||||
|
||||
assert.strictEqual(zlib.codes.Z_OK, 0,
|
||||
`Expected Z_OK to be 0; got ${zlib.codes.Z_OK}`);
|
||||
zlib.codes.Z_OK = 1;
|
||||
assert.strictEqual(zlib.codes.Z_OK, 0,
|
||||
[
|
||||
'Z_OK should be immutable.',
|
||||
`Expected to get 0, got ${zlib.codes.Z_OK}`,
|
||||
].join(' '));
|
||||
zlib.codes = { Z_OK: 1 };
|
||||
assert.strictEqual(zlib.codes.Z_OK, 0,
|
||||
[
|
||||
'Z_OK should be immutable.',
|
||||
`Expected to get 0, got ${zlib.codes.Z_OK}`,
|
||||
].join(' '));
|
||||
assert.throws(() => { zlib.codes.Z_OK = 1; },
|
||||
TypeError, 'zlib.codes.Z_OK should be immutable');
|
||||
|
||||
assert.throws(() => { zlib.codes = { Z_OK: 1 }; },
|
||||
TypeError, 'zlib.codes should be immutable');
|
||||
|
||||
assert.ok(Object.isFrozen(zlib.codes),
|
||||
[
|
||||
|
Loading…
x
Reference in New Issue
Block a user