Skip to content

Commit 903c28b

Browse files
committed
Merge branch 'test-no-eval' into no-eval
Replace previous testing strategy with new simpler one
2 parents 71460f2 + 9ee652b commit 903c28b

File tree

2 files changed

+34
-3
lines changed

2 files changed

+34
-3
lines changed

test/fixtures/basic.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
var deprecate = require('../..')('basic')
3+
4+
var object = { foo: 'bar' }
5+
deprecate.property(object, 'foo')
6+
7+
function fn () {}
8+
deprecate.function(fn)

test/test.js

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@ var script = path.join(__dirname, 'fixtures', 'script.js')
1010
var spawn = require('child_process').spawn
1111
var strictlib = libs.strict
1212

13+
function isNodeVersionGE (required) {
14+
var nodeVersion = process.version.substr(1).split('.')
15+
for (var i = 0; i < required.length; i++) {
16+
if (+nodeVersion[i] < required[i]) {
17+
return false
18+
}
19+
}
20+
return true
21+
}
22+
1323
describe('depd(namespace)', function () {
1424
it('creates deprecated function', function () {
1525
assert.strictEqual(typeof depd('test'), 'function')
@@ -730,9 +740,9 @@ describe('node script.js', function () {
730740
;(function () {
731741
// --*-deprecation switches are 0.8+
732742
// no good way to feature detect this sync
733-
var describe = /^v0\.6\./.test(process.version)
734-
? global.describe.skip
735-
: global.describe
743+
var describe = isNodeVersionGE([0, 8])
744+
? global.describe
745+
: global.describe.skip
736746

737747
describe('node --no-deprecation script.js', function () {
738748
it('should suppress deprecation message', function (done) {
@@ -755,6 +765,19 @@ describe('node script.js', function () {
755765
})
756766
}())
757767

768+
describe('node --disallow-code-generation-from-strings script.js', function () {
769+
it('should run without error', function (done) {
770+
if (!isNodeVersionGE([9])) this.skip() // --disallow-code-generation-from-strings is 9+
771+
772+
var basic = path.join(__dirname, 'fixtures', 'basic.js')
773+
captureChildStderr(basic, ['--disallow-code-generation-from-strings'], function (err, stderr) {
774+
if (err) return done(err)
775+
assert.strictEqual(stderr, '')
776+
done()
777+
})
778+
})
779+
})
780+
758781
function captureChildStderr (script, opts, callback) {
759782
var chunks = []
760783
var env = { PATH: process.env.PATH }

0 commit comments

Comments
 (0)