diff options
author | Jackson Tian <puling.tyq@alibaba-inc.com> | 2015-04-07 13:48:52 +0800 |
---|---|---|
committer | Shigeki Ohtsu <ohtsu@iij.ad.jp> | 2015-04-07 23:38:55 +0900 |
commit | 372bf83818fd87bae5ad7cedadfa121ddc5d4345 (patch) | |
tree | 4d22770786a27fb489b00738cc63fbc4ea016e92 /test/parallel/test-zlib-const.js | |
parent | d726a177ed59c37cf5306983ed00ecd858cfbbef (diff) | |
download | node-new-372bf83818fd87bae5ad7cedadfa121ddc5d4345.tar.gz |
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>
Diffstat (limited to 'test/parallel/test-zlib-const.js')
-rw-r--r-- | test/parallel/test-zlib-const.js | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/test/parallel/test-zlib-const.js b/test/parallel/test-zlib-const.js new file mode 100644 index 0000000000..df9ca3d500 --- /dev/null +++ b/test/parallel/test-zlib-const.js @@ -0,0 +1,16 @@ +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'); |