Skip to content

Commit

Permalink
test: enforce strict mode in test-zlib-const
Browse files Browse the repository at this point in the history
Instead of checking that assignments fail silently in sloppy mode, check
that they throw in strict mode.
  • Loading branch information
Trott committed Jan 22, 2025
1 parent bf59539 commit 944fabc
Showing 1 changed file with 9 additions and 19 deletions.
28 changes: 9 additions & 19 deletions test/parallel/test-zlib-const.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable strict */
'use strict';
require('../common');
const assert = require('assert');

Expand All @@ -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),
[
Expand Down

0 comments on commit 944fabc

Please sign in to comment.