Browse Source

test: fix array sorting bug

`a === a.sort()` is always true because Array#sort() does an in-place
sort.  Make a copy of the array first.
v0.11.11-release
Ben Noordhuis 11 years ago
committed by Fedor Indutny
parent
commit
6514a4128c
  1. 5
      test/simple/test-crypto.js

5
test/simple/test-crypto.js

@ -24,6 +24,7 @@
var common = require('../common'); var common = require('../common');
var assert = require('assert'); var assert = require('assert');
var util = require('util');
try { try {
var crypto = require('crypto'); var crypto = require('crypto');
@ -926,7 +927,9 @@ testPBKDF2('pass\0word', 'sa\0lt', 4096, 16,
})(); })();
function assertSorted(list) { function assertSorted(list) {
assert.deepEqual(list, list.sort()); // Array#sort() modifies the list in place so make a copy.
var sorted = util._extend([], list).sort();
assert.deepEqual(list, sorted);
} }
// Assume that we have at least AES-128-CBC. // Assume that we have at least AES-128-CBC.

Loading…
Cancel
Save