node/test/parallel/test-zlib-const.js
Jackson Tian 372bf83818 zlib: make constants keep readonly
In zlib module, a dozen constants were exported to user land,
If user change the constant, maybe lead unexcepted error.

Make them readonly and freezon.

PR-URL: https://github.com/iojs/io.js/pull/1361
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
Reviewed-By: Shigeki Ohtsu <ohtsu@iij.ad.jp>
2015-04-07 23:38:55 +09:00

17 lines
510 B
JavaScript

var common = require('../common');
var assert = require('assert');
var zlib = require('zlib');
assert.equal(zlib.Z_OK, 0, 'Z_OK should be 0');
zlib.Z_OK = 1;
assert.equal(zlib.Z_OK, 0, 'Z_OK should be 0');
assert.equal(zlib.codes.Z_OK, 0, 'Z_OK should be 0');
zlib.codes.Z_OK = 1;
assert.equal(zlib.codes.Z_OK, 0, 'zlib.codes.Z_OK should be 0');
zlib.codes = {Z_OK: 1};
assert.equal(zlib.codes.Z_OK, 0, 'zlib.codes.Z_OK should be 0');
assert.ok(Object.isFrozen(zlib.codes), 'zlib.codes should be frozen');