Skip to content

Commit 0665f02

Browse files
Sannisry
authored andcommitted
GJSLint all simple tests exclude http-*, url, path
1 parent 47c40bf commit 0665f02

80 files changed

Lines changed: 975 additions & 878 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

test/common.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ var util = require('util');
1212
for (var i in util) exports[i] = util[i];
1313
//for (var i in exports) global[i] = exports[i];
1414

15-
function protoCtrChain (o) {
15+
function protoCtrChain(o) {
1616
var result = [];
1717
for (; o; o = o.__proto__) { result.push(o.constructor); }
1818
return result.join();
@@ -29,16 +29,16 @@ exports.indirectInstanceOf = function(obj, cls) {
2929
// Turn this off if the test should not check for global leaks.
3030
exports.globalCheck = true;
3131

32-
process.on('exit', function () {
32+
process.on('exit', function() {
3333
if (!exports.globalCheck) return;
34-
var knownGlobals = [ setTimeout,
35-
setInterval,
36-
clearTimeout,
37-
clearInterval,
38-
console,
39-
Buffer,
40-
process,
41-
global ];
34+
var knownGlobals = [setTimeout,
35+
setInterval,
36+
clearTimeout,
37+
clearInterval,
38+
console,
39+
Buffer,
40+
process,
41+
global];
4242

4343
for (var x in global) {
4444
var found = false;
@@ -51,7 +51,7 @@ process.on('exit', function () {
5151
}
5252

5353
if (!found) {
54-
console.error("Unknown global: %s", x);
54+
console.error('Unknown global: %s', x);
5555
exports.assert.ok(false);
5656
}
5757
}

test/simple/path.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22
// sure that require('./path') and require('path') do different things.
33
// It has to be in the same directory as the test 'test-module-loading.js'
44
// and it has to have the same name as an internal module.
5-
exports.path_func = function() { return "path_func"}
5+
exports.path_func = function() {
6+
return 'path_func';
7+
};

test/simple/test-assert.js

Lines changed: 60 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
var common = require("../common");
1+
var common = require('../common');
22
var assert = require('assert');
33
var a = require('assert');
44

5-
function makeBlock (f) {
6-
var args = Array.prototype.slice.call(arguments,1);
7-
return function () {
8-
return f.apply(this,args);
5+
function makeBlock(f) {
6+
var args = Array.prototype.slice.call(arguments, 1);
7+
return function() {
8+
return f.apply(this, args);
99
};
1010
}
1111

1212
assert.ok(common.indirectInstanceOf(a.AssertionError.prototype, Error),
13-
"a.AssertionError instanceof Error");
13+
'a.AssertionError instanceof Error');
1414

1515
assert.throws(makeBlock(a.ok, false),
16-
a.AssertionError, "ok(false)");
16+
a.AssertionError, 'ok(false)');
1717

1818
assert.doesNotThrow(makeBlock(a.ok, true),
19-
a.AssertionError, "ok(true)");
19+
a.AssertionError, 'ok(true)');
2020

21-
assert.doesNotThrow(makeBlock(a.ok, "test"), "ok('test')");
21+
assert.doesNotThrow(makeBlock(a.ok, 'test'), 'ok(\'test\')');
2222

2323
assert.throws(makeBlock(a.equal, true, false), a.AssertionError, 'equal');
2424

@@ -30,95 +30,98 @@ assert.doesNotThrow(makeBlock(a.equal, null, undefined), 'equal');
3030

3131
assert.doesNotThrow(makeBlock(a.equal, true, true), 'equal');
3232

33-
assert.doesNotThrow(makeBlock(a.equal, 2, "2"), 'equal');
33+
assert.doesNotThrow(makeBlock(a.equal, 2, '2'), 'equal');
3434

3535
assert.doesNotThrow(makeBlock(a.notEqual, true, false), 'notEqual');
3636

37-
assert.throws(makeBlock(a.notEqual, true, true), a.AssertionError, 'notEqual');
37+
assert.throws(makeBlock(a.notEqual, true, true),
38+
a.AssertionError, 'notEqual');
3839

39-
assert.throws(makeBlock(a.strictEqual, 2, "2"), a.AssertionError, 'strictEqual');
40+
assert.throws(makeBlock(a.strictEqual, 2, '2'),
41+
a.AssertionError, 'strictEqual');
4042

41-
assert.throws(makeBlock(a.strictEqual, null, undefined), a.AssertionError, 'strictEqual');
43+
assert.throws(makeBlock(a.strictEqual, null, undefined),
44+
a.AssertionError, 'strictEqual');
4245

43-
assert.doesNotThrow(makeBlock(a.notStrictEqual, 2, "2"), 'notStrictEqual');
46+
assert.doesNotThrow(makeBlock(a.notStrictEqual, 2, '2'), 'notStrictEqual');
4447

4548
// deepEquals joy!
4649
// 7.2
47-
assert.doesNotThrow(makeBlock(a.deepEqual, new Date(2000,3,14), new Date(2000,3,14)),
48-
'deepEqual date');
50+
assert.doesNotThrow(makeBlock(a.deepEqual, new Date(2000, 3, 14),
51+
new Date(2000, 3, 14)), 'deepEqual date');
4952

50-
assert.throws(makeBlock(a.deepEqual, new Date(), new Date(2000,3,14)),
53+
assert.throws(makeBlock(a.deepEqual, new Date(), new Date(2000, 3, 14)),
5154
a.AssertionError,
5255
'deepEqual date');
5356

5457
// 7.3
55-
assert.doesNotThrow(makeBlock(a.deepEqual, 4, "4"), 'deepEqual == check');
58+
assert.doesNotThrow(makeBlock(a.deepEqual, 4, '4'), 'deepEqual == check');
5659
assert.doesNotThrow(makeBlock(a.deepEqual, true, 1), 'deepEqual == check');
57-
assert.throws(makeBlock(a.deepEqual, 4, "5"),
60+
assert.throws(makeBlock(a.deepEqual, 4, '5'),
5861
a.AssertionError,
5962
'deepEqual == check');
6063

6164
// 7.4
6265
// having the same number of owned properties && the same set of keys
63-
assert.doesNotThrow(makeBlock(a.deepEqual, {a:4}, {a:4}));
64-
assert.doesNotThrow(makeBlock(a.deepEqual, {a:4,b:"2"}, {a:4,b:"2"}));
65-
assert.doesNotThrow(makeBlock(a.deepEqual, [4], ["4"]));
66-
assert.throws(makeBlock(a.deepEqual, {a:4}, {a:4,b:true}), a.AssertionError);
67-
assert.doesNotThrow(makeBlock(a.deepEqual, ["a"], {0:"a"}));
66+
assert.doesNotThrow(makeBlock(a.deepEqual, {a: 4}, {a: 4}));
67+
assert.doesNotThrow(makeBlock(a.deepEqual, {a: 4, b: '2'}, {a: 4, b: '2'}));
68+
assert.doesNotThrow(makeBlock(a.deepEqual, [4], ['4']));
69+
assert.throws(makeBlock(a.deepEqual, {a: 4}, {a: 4, b: true}),
70+
a.AssertionError);
71+
assert.doesNotThrow(makeBlock(a.deepEqual, ['a'], {0: 'a'}));
6872
//(although not necessarily the same order),
69-
assert.doesNotThrow(makeBlock(a.deepEqual, {a:4,b:"1"}, {b:"1",a:4}));
70-
var a1 = [1,2,3];
71-
var a2 = [1,2,3];
72-
a1.a = "test";
73+
assert.doesNotThrow(makeBlock(a.deepEqual, {a: 4, b: '1'}, {b: '1', a: 4}));
74+
var a1 = [1, 2, 3];
75+
var a2 = [1, 2, 3];
76+
a1.a = 'test';
7377
a1.b = true;
7478
a2.b = true;
75-
a2.a = "test";
76-
assert.throws(makeBlock(a.deepEqual,
77-
Object.keys(a1),
78-
Object.keys(a2)),
79+
a2.a = 'test';
80+
assert.throws(makeBlock(a.deepEqual, Object.keys(a1), Object.keys(a2)),
7981
a.AssertionError);
8082
assert.doesNotThrow(makeBlock(a.deepEqual, a1, a2));
8183

8284
// having an identical prototype property
8385
var nbRoot = {
84-
toString: function () { return this.first+' '+this.last; }
86+
toString: function() { return this.first + ' ' + this.last; }
8587
};
8688

87-
function nameBuilder (first,last) {
89+
function nameBuilder(first, last) {
8890
this.first = first;
8991
this.last = last;
9092
return this;
9193
}
9294
nameBuilder.prototype = nbRoot;
9395

94-
function nameBuilder2 (first,last) {
96+
function nameBuilder2(first, last) {
9597
this.first = first;
9698
this.last = last;
9799
return this;
98100
}
99101
nameBuilder2.prototype = nbRoot;
100102

101103
var nb1 = new nameBuilder('Ryan', 'Dahl');
102-
var nb2 = new nameBuilder2('Ryan','Dahl');
104+
var nb2 = new nameBuilder2('Ryan', 'Dahl');
103105

104106
assert.doesNotThrow(makeBlock(a.deepEqual, nb1, nb2));
105107

106108
nameBuilder2.prototype = Object;
107-
nb2 = new nameBuilder2('Ryan','Dahl');
109+
nb2 = new nameBuilder2('Ryan', 'Dahl');
108110
assert.throws(makeBlock(a.deepEqual, nb1, nb2), a.AssertionError);
109111

110112
// String literal + object blew up my implementation...
111113
assert.throws(makeBlock(a.deepEqual, 'a', {}), a.AssertionError);
112114

113115
// Testing the throwing
114-
function thrower (errorConstructor){
116+
function thrower(errorConstructor) {
115117
throw new errorConstructor('test');
116118
}
117119
var aethrow = makeBlock(thrower, a.AssertionError);
118120
aethrow = makeBlock(thrower, a.AssertionError);
119121

120122
// the basic calls work
121-
assert.throws(makeBlock(thrower, a.AssertionError), a.AssertionError, 'message');
123+
assert.throws(makeBlock(thrower, a.AssertionError),
124+
a.AssertionError, 'message');
122125
assert.throws(makeBlock(thrower, a.AssertionError), a.AssertionError);
123126
assert.throws(makeBlock(thrower, a.AssertionError));
124127

@@ -133,37 +136,41 @@ try {
133136
threw = true;
134137
assert.ok(e instanceof TypeError, 'type');
135138
}
136-
assert.equal(true,threw,'a.throws with an explicit error is eating extra errors', a.AssertionError);
139+
assert.equal(true, threw,
140+
'a.throws with an explicit error is eating extra errors',
141+
a.AssertionError);
137142
threw = false;
138143

139144
// doesNotThrow should pass through all errors
140145
try {
141146
a.doesNotThrow(makeBlock(thrower, TypeError), a.AssertionError);
142-
} catch(e) {
143-
threw = true
147+
} catch (e) {
148+
threw = true;
144149
assert.ok(e instanceof TypeError);
145150
}
146-
assert.equal(true,threw,'a.doesNotThrow with an explicit error is eating extra errors');
151+
assert.equal(true, threw,
152+
'a.doesNotThrow with an explicit error is eating extra errors');
147153

148154
// key difference is that throwing our correct error makes an assertion error
149155
try {
150156
a.doesNotThrow(makeBlock(thrower, TypeError), TypeError);
151-
} catch(e) {
152-
threw = true
157+
} catch (e) {
158+
threw = true;
153159
assert.ok(e instanceof a.AssertionError);
154160
}
155-
assert.equal(true,threw,'a.doesNotThrow is not catching type matching errors');
161+
assert.equal(true, threw,
162+
'a.doesNotThrow is not catching type matching errors');
156163

157-
assert.throws(function () {assert.ifError(new Error('test error'))});
158-
assert.doesNotThrow(function(){assert.ifError(null)});
159-
assert.doesNotThrow(function(){assert.ifError()});
164+
assert.throws(function() {assert.ifError(new Error('test error'))});
165+
assert.doesNotThrow(function() {assert.ifError(null)});
166+
assert.doesNotThrow(function() {assert.ifError()});
160167

161168
// use a RegExp to validate error message
162-
a.throws(makeBlock(thrower, TypeError), /test/ );
169+
a.throws(makeBlock(thrower, TypeError), /test/);
163170

164171
// use a fn to validate error object
165172
a.throws(makeBlock(thrower, TypeError), function(err) {
166-
if (!(err instanceof TypeError) || !/test/.test(err)) {
167-
return false;
168-
}
173+
if (!(err instanceof TypeError) || !/test/.test(err)) {
174+
return false;
175+
}
169176
});

0 commit comments

Comments
 (0)