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.
This commit is contained in:
Ben Noordhuis 2013-11-21 13:23:43 +01:00 committed by Fedor Indutny
parent 74d9aa49d5
commit 6514a4128c

View File

@ -24,6 +24,7 @@
var common = require('../common');
var assert = require('assert');
var util = require('util');
try {
var crypto = require('crypto');
@ -926,7 +927,9 @@ testPBKDF2('pass\0word', 'sa\0lt', 4096, 16,
})();
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.