mirror of
https://github.com/nodejs/node.git
synced 2026-11-29 14:27:57 -05:00
test: cleanup IIFE tests
A number of test files use IIFEs to separate distinct tests from each other in the same file. The project has been moving toward using block scopes and let/const in favor of IIFEs. This commit moves IIFE tests to block scopes. Some additional cleanup such as use of strictEqual() and common.mustCall() is also included. PR-URL: https://github.com/nodejs/node/pull/7694 Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
This commit is contained in:
1 parent
11d6f1af59
commit
acb976ac26
34 files changed
+664
-749
No files matched your search
@@ -53,57 +53,57 @@ var RADIOS = 2;
|
||||
var PRE_HALF_APEX = Math.ceil(EXTERN_APEX / 2) - RADIOS;
|
||||
var PRE_3OF4_APEX = Math.ceil((EXTERN_APEX / 4) * 3) - RADIOS;
|
||||
|
||||
(function() {
|
||||
for (var j = 0; j < RADIOS * 2; j += 1) {
|
||||
var datum = b;
|
||||
var slice = datum.slice(0, PRE_HALF_APEX + j);
|
||||
var slice2 = datum.slice(0, PRE_HALF_APEX + j + 2);
|
||||
var pumped_string = slice.toString('hex');
|
||||
var pumped_string2 = slice2.toString('hex');
|
||||
var decoded = Buffer.from(pumped_string, 'hex');
|
||||
{
|
||||
for (let j = 0; j < RADIOS * 2; j += 1) {
|
||||
const datum = b;
|
||||
const slice = datum.slice(0, PRE_HALF_APEX + j);
|
||||
const slice2 = datum.slice(0, PRE_HALF_APEX + j + 2);
|
||||
const pumped_string = slice.toString('hex');
|
||||
const pumped_string2 = slice2.toString('hex');
|
||||
const decoded = Buffer.from(pumped_string, 'hex');
|
||||
|
||||
// the string are the same?
|
||||
for (var k = 0; k < pumped_string.length; ++k) {
|
||||
assert.equal(pumped_string[k], pumped_string2[k]);
|
||||
for (let k = 0; k < pumped_string.length; ++k) {
|
||||
assert.strictEqual(pumped_string[k], pumped_string2[k]);
|
||||
}
|
||||
|
||||
// the recoded buffer is the same?
|
||||
for (var i = 0; i < decoded.length; ++i) {
|
||||
assert.equal(datum[i], decoded[i]);
|
||||
for (let i = 0; i < decoded.length; ++i) {
|
||||
assert.strictEqual(datum[i], decoded[i]);
|
||||
}
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
||||
(function() {
|
||||
for (var j = 0; j < RADIOS * 2; j += 1) {
|
||||
var datum = b;
|
||||
var slice = datum.slice(0, PRE_3OF4_APEX + j);
|
||||
var slice2 = datum.slice(0, PRE_3OF4_APEX + j + 2);
|
||||
var pumped_string = slice.toString('base64');
|
||||
var pumped_string2 = slice2.toString('base64');
|
||||
var decoded = Buffer.from(pumped_string, 'base64');
|
||||
{
|
||||
for (let j = 0; j < RADIOS * 2; j += 1) {
|
||||
const datum = b;
|
||||
const slice = datum.slice(0, PRE_3OF4_APEX + j);
|
||||
const slice2 = datum.slice(0, PRE_3OF4_APEX + j + 2);
|
||||
const pumped_string = slice.toString('base64');
|
||||
const pumped_string2 = slice2.toString('base64');
|
||||
const decoded = Buffer.from(pumped_string, 'base64');
|
||||
|
||||
// the string are the same?
|
||||
for (var k = 0; k < pumped_string.length - 3; ++k) {
|
||||
assert.equal(pumped_string[k], pumped_string2[k]);
|
||||
for (let k = 0; k < pumped_string.length - 3; ++k) {
|
||||
assert.strictEqual(pumped_string[k], pumped_string2[k]);
|
||||
}
|
||||
|
||||
// the recoded buffer is the same?
|
||||
for (var i = 0; i < decoded.length; ++i) {
|
||||
assert.equal(datum[i], decoded[i]);
|
||||
for (let i = 0; i < decoded.length; ++i) {
|
||||
assert.strictEqual(datum[i], decoded[i]);
|
||||
}
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
||||
// https://github.com/nodejs/node/issues/1024
|
||||
(function() {
|
||||
var a = Array(1 << 20).join('x');
|
||||
var b = Buffer.from(a, 'ucs2').toString('ucs2');
|
||||
var c = Buffer.from(b, 'utf8').toString('utf8');
|
||||
{
|
||||
const a = Array(1 << 20).join('x');
|
||||
const b = Buffer.from(a, 'ucs2').toString('ucs2');
|
||||
const c = Buffer.from(b, 'utf8').toString('utf8');
|
||||
|
||||
assert.equal(a.length, b.length);
|
||||
assert.equal(b.length, c.length);
|
||||
assert.strictEqual(a.length, b.length);
|
||||
assert.strictEqual(b.length, c.length);
|
||||
|
||||
assert.equal(a, b);
|
||||
assert.equal(b, c);
|
||||
})();
|
||||
assert.strictEqual(a, b);
|
||||
assert.strictEqual(b, c);
|
||||
}
|
||||
Reference in new issue
Block a user