Skip to content

Commit 0529238

Browse files
committed
Whitespace and fixed array_fill_keys#0 by using equal()
Won't use node's standard assert.deepEqual cause that would rule out in-browser tests
1 parent 4c759ed commit 0529238

File tree

5 files changed

+13
-3
lines changed

5 files changed

+13
-3
lines changed

functions/array/array_count_values.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ function array_count_values (array) {
1212
// * returns 2: {3:2, 5:1, "foo":2, "bar":1}
1313
// * example 3: array_count_values([ true, 4.2, 42, "fubar" ]);
1414
// * returns 3: {42:1, "fubar":1}
15+
1516
var tmp_arr = {},
1617
key = '',
1718
t = '';
@@ -50,5 +51,6 @@ function array_count_values (array) {
5051
}
5152
}
5253
}
54+
5355
return tmp_arr;
5456
}

functions/array/array_fill_keys.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ function array_fill_keys (keys, value) {
55
// * example 1: keys = {'a': 'foo', 2: 5, 3: 10, 4: 'bar'}
66
// * example 1: array_fill_keys(keys, 'banana')
77
// * returns 1: {"foo": "banana", 5: "banana", 10: "banana", "bar": "banana"}
8+
89
var retObj = {},
910
key = '';
1011

tests/cli.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@ var FS = require('fs');
33
var glob = require('glob');
44
var path = require('path');
55
var phpjsutil = new require('./phpjsutil');
6+
var equal = require('deep-equal');
7+
68

79
var PhpjsUtil = phpjsutil({
8-
injectDependencies: [ 'ini_set', 'ini_get' ]
10+
injectDependencies: [ 'ini_set', 'ini_get' ],
11+
equal: equal
912
});
1013

1114
// Environment-specific file opener. function name needs to

tests/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
"dependencies": {
1111
"cli": "~0.4.4-2",
1212
"glob": "~3.2.1",
13-
"send": "~0.1.0"
13+
"send": "~0.1.0",
14+
"deep-equal": "~0.1.2"
1415
},
1516
"keywords": [
1617
"cli",

tests/phpjsutil.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ if (typeof require !== 'undefined') {
77

88
function PhpjsUtil(config) {
99
this.injectDependencies = [];
10+
this.equal;
1011

1112
// Overwrite properties with config
1213
for (var k in config) {
@@ -288,7 +289,9 @@ PhpjsUtil.prototype.test = function(params, cb) {
288289
var jsonExpected = JSON.stringify(test.expected, undefined, 2);
289290
var jsonResult = JSON.stringify(test.result, undefined, 2);
290291

291-
if (jsonExpected !== jsonResult) {
292+
// We cannot compare using the JSON.stringify as object order is
293+
// not guaranteed
294+
if (!self.equal(test.expected, test.result)) {
292295
err = 'expected: \n' + jsonExpected + '\n\n' +
293296
'returned: \n' + jsonResult + '\n';
294297
cb(err, test, params);

0 commit comments

Comments
 (0)