diff --git a/test/unit/util_cast.js b/test/unit/util_cast.js index dac55f59..1d372213 100644 --- a/test/unit/util_cast.js +++ b/test/unit/util_cast.js @@ -3,72 +3,73 @@ var cast = require('../../src/util/cast'); test('toNumber', function (t) { // Numeric - t.equal(cast.toNumber(0), 0); - t.equal(cast.toNumber(1), 1); - t.equal(cast.toNumber(3.14), 3.14); + t.strictEqual(cast.toNumber(0), 0); + t.strictEqual(cast.toNumber(1), 1); + t.strictEqual(cast.toNumber(3.14), 3.14); // String - t.equal(cast.toNumber('0'), 0); - t.equal(cast.toNumber('1'), 1); - t.equal(cast.toNumber('3.14'), 3.14); - t.equal(cast.toNumber('0.1e10'), 1000000000); - t.equal(cast.toNumber('foobar'), 0); + t.strictEqual(cast.toNumber('0'), 0); + t.strictEqual(cast.toNumber('1'), 1); + t.strictEqual(cast.toNumber('3.14'), 3.14); + t.strictEqual(cast.toNumber('0.1e10'), 1000000000); + t.strictEqual(cast.toNumber('foobar'), 0); // Boolean - t.equal(cast.toNumber(true), 1); - t.equal(cast.toNumber(false), 0); - t.equal(cast.toNumber('true'), 0); - t.equal(cast.toNumber('false'), 0); + t.strictEqual(cast.toNumber(true), 1); + t.strictEqual(cast.toNumber(false), 0); + t.strictEqual(cast.toNumber('true'), 0); + t.strictEqual(cast.toNumber('false'), 0); // Undefined & object - t.equal(cast.toNumber(undefined), 0); - t.equal(cast.toNumber({}), 0); + t.strictEqual(cast.toNumber(undefined), 0); + t.strictEqual(cast.toNumber({}), 0); + t.strictEqual(cast.toNumber(NaN), 0); t.end(); }); test('toBoolean', function (t) { // Numeric - t.equal(cast.toBoolean(0), false); - t.equal(cast.toBoolean(1), true); - t.equal(cast.toBoolean(3.14), true); + t.strictEqual(cast.toBoolean(0), false); + t.strictEqual(cast.toBoolean(1), true); + t.strictEqual(cast.toBoolean(3.14), true); // String - t.equal(cast.toBoolean('0'), false); - t.equal(cast.toBoolean('1'), true); - t.equal(cast.toBoolean('3.14'), true); - t.equal(cast.toBoolean('0.1e10'), true); - t.equal(cast.toBoolean('foobar'), true); + t.strictEqual(cast.toBoolean('0'), false); + t.strictEqual(cast.toBoolean('1'), true); + t.strictEqual(cast.toBoolean('3.14'), true); + t.strictEqual(cast.toBoolean('0.1e10'), true); + t.strictEqual(cast.toBoolean('foobar'), true); // Boolean - t.equal(cast.toBoolean(true), true); - t.equal(cast.toBoolean(false), false); + t.strictEqual(cast.toBoolean(true), true); + t.strictEqual(cast.toBoolean(false), false); // Undefined & object - t.equal(cast.toBoolean(undefined), false); - t.equal(cast.toBoolean({}), true); + t.strictEqual(cast.toBoolean(undefined), false); + t.strictEqual(cast.toBoolean({}), true); t.end(); }); test('toString', function (t) { // Numeric - t.equal(cast.toString(0), '0'); - t.equal(cast.toString(1), '1'); - t.equal(cast.toString(3.14), '3.14'); + t.strictEqual(cast.toString(0), '0'); + t.strictEqual(cast.toString(1), '1'); + t.strictEqual(cast.toString(3.14), '3.14'); // String - t.equal(cast.toString('0'), '0'); - t.equal(cast.toString('1'), '1'); - t.equal(cast.toString('3.14'), '3.14'); - t.equal(cast.toString('0.1e10'), '0.1e10'); - t.equal(cast.toString('foobar'), 'foobar'); + t.strictEqual(cast.toString('0'), '0'); + t.strictEqual(cast.toString('1'), '1'); + t.strictEqual(cast.toString('3.14'), '3.14'); + t.strictEqual(cast.toString('0.1e10'), '0.1e10'); + t.strictEqual(cast.toString('foobar'), 'foobar'); // Boolean - t.equal(cast.toString(true), 'true'); - t.equal(cast.toString(false), 'false'); + t.strictEqual(cast.toString(true), 'true'); + t.strictEqual(cast.toString(false), 'false'); // Undefined & object - t.equal(cast.toString(undefined), 'undefined'); - t.equal(cast.toString({}), '[object Object]'); + t.strictEqual(cast.toString(undefined), 'undefined'); + t.strictEqual(cast.toString({}), '[object Object]'); t.end(); }); @@ -92,53 +93,53 @@ test('toRbgColorList', function (t) { test('compare', function (t) { // Numeric - t.equal(cast.compare(0, 0), 0); - t.equal(cast.compare(1, 0), 1); - t.equal(cast.compare(0, 1), -1); - t.equal(cast.compare(1, 1), 0); + t.strictEqual(cast.compare(0, 0), 0); + t.strictEqual(cast.compare(1, 0), 1); + t.strictEqual(cast.compare(0, 1), -1); + t.strictEqual(cast.compare(1, 1), 0); // String - t.equal(cast.compare('0', '0'), 0); - t.equal(cast.compare('0.1e10', '1000000000'), 0); - t.equal(cast.compare('foobar', 'FOOBAR'), 0); - t.equal(cast.compare('dog', 'cat'), 1); + t.strictEqual(cast.compare('0', '0'), 0); + t.strictEqual(cast.compare('0.1e10', '1000000000'), 0); + t.strictEqual(cast.compare('foobar', 'FOOBAR'), 0); + t.ok(cast.compare('dog', 'cat') > 0); // Boolean - t.equal(cast.compare(true, true), 0); - t.equal(cast.compare(true, false), 1); - t.equal(cast.compare(false, true), -1); - t.equal(cast.compare(true, true), 0); + t.strictEqual(cast.compare(true, true), 0); + t.strictEqual(cast.compare(true, false), 1); + t.strictEqual(cast.compare(false, true), -1); + t.strictEqual(cast.compare(true, true), 0); // Undefined & object - t.equal(cast.compare(undefined, undefined), 0); - t.equal(cast.compare(undefined, 'undefined'), 0); - t.equal(cast.compare({}, {}), 0); - t.equal(cast.compare({}, '[object Object]'), 0); + t.strictEqual(cast.compare(undefined, undefined), 0); + t.strictEqual(cast.compare(undefined, 'undefined'), 0); + t.strictEqual(cast.compare({}, {}), 0); + t.strictEqual(cast.compare({}, '[object Object]'), 0); t.end(); }); test('isInt', function (t) { // Numeric - t.equal(cast.isInt(0), true); - t.equal(cast.isInt(1), true); - t.equal(cast.isInt(0.0), true); - t.equal(cast.isInt(3.14), false); - t.equal(cast.isInt(NaN), true); + t.strictEqual(cast.isInt(0), true); + t.strictEqual(cast.isInt(1), true); + t.strictEqual(cast.isInt(0.0), true); + t.strictEqual(cast.isInt(3.14), false); + t.strictEqual(cast.isInt(NaN), true); // String - t.equal(cast.isInt('0'), true); - t.equal(cast.isInt('1'), true); - t.equal(cast.isInt('0.0'), false); // @todo This should be true - t.equal(cast.isInt('0.1e10'), false); // @todo This should be true - t.equal(cast.isInt('3.14'), false); + t.strictEqual(cast.isInt('0'), true); + t.strictEqual(cast.isInt('1'), true); + t.strictEqual(cast.isInt('0.0'), false); + t.strictEqual(cast.isInt('0.1e10'), false); + t.strictEqual(cast.isInt('3.14'), false); // Boolean - t.equal(cast.isInt(true), true); - t.equal(cast.isInt(false), true); + t.strictEqual(cast.isInt(true), true); + t.strictEqual(cast.isInt(false), true); // Undefined & object - t.equal(cast.isInt(undefined), false); - t.equal(cast.isInt({}), false); + t.strictEqual(cast.isInt(undefined), false); + t.strictEqual(cast.isInt({}), false); t.end(); }); @@ -147,32 +148,32 @@ test('toListIndex', function (t) { var empty = []; // Valid - t.equal(cast.toListIndex(1, list.length), 1); - t.equal(cast.toListIndex(6, list.length), 6); + t.strictEqual(cast.toListIndex(1, list.length), 1); + t.strictEqual(cast.toListIndex(6, list.length), 6); // Invalid - t.equal(cast.toListIndex(-1, list.length), 'INVALID'); - t.equal(cast.toListIndex(0.1, list.length), 'INVALID'); - t.equal(cast.toListIndex(0, list.length), 'INVALID'); - t.equal(cast.toListIndex(7, list.length), 'INVALID'); + t.strictEqual(cast.toListIndex(-1, list.length), cast.LIST_INVALID); + t.strictEqual(cast.toListIndex(0.1, list.length), cast.LIST_INVALID); + t.strictEqual(cast.toListIndex(0, list.length), cast.LIST_INVALID); + t.strictEqual(cast.toListIndex(7, list.length), cast.LIST_INVALID); // "all" - t.equal(cast.toListIndex('all', list.length), 'ALL'); + t.strictEqual(cast.toListIndex('all', list.length), cast.LIST_ALL); // "last" - t.equal(cast.toListIndex('last', list.length), list.length); - t.equal(cast.toListIndex('last', empty.length), 'INVALID'); + t.strictEqual(cast.toListIndex('last', list.length), list.length); + t.strictEqual(cast.toListIndex('last', empty.length), cast.LIST_INVALID); // "random" var random = cast.toListIndex('random', list.length); t.ok(random <= list.length); t.ok(random > 0); - t.equal(cast.toListIndex('random', empty.length), 'INVALID'); + t.strictEqual(cast.toListIndex('random', empty.length), cast.LIST_INVALID); // "any" (alias for "random") var any = cast.toListIndex('any', list.length); t.ok(any <= list.length); t.ok(any > 0); - t.equal(cast.toListIndex('any', empty.length), 'INVALID'); + t.strictEqual(cast.toListIndex('any', empty.length), cast.LIST_INVALID); t.end(); }); diff --git a/test/unit/util_color.js b/test/unit/util_color.js index 0558b4b3..ba7fa059 100644 --- a/test/unit/util_color.js +++ b/test/unit/util_color.js @@ -2,11 +2,11 @@ var test = require('tap').test; var color = require('../../src/util/color'); test('decimalToHex', function (t) { - t.equal(color.decimalToHex(0), '#000000'); - t.equal(color.decimalToHex(1), '#000001'); - t.equal(color.decimalToHex(16777215), '#ffffff'); - t.equal(color.decimalToHex(-16777215), '#000001'); // @todo - t.equal(color.decimalToHex(99999999), '#5f5e0ff'); // @todo + t.strictEqual(color.decimalToHex(0), '#000000'); + t.strictEqual(color.decimalToHex(1), '#000001'); + t.strictEqual(color.decimalToHex(16777215), '#ffffff'); + t.strictEqual(color.decimalToHex(-16777215), '#000001'); + t.strictEqual(color.decimalToHex(99999999), '#5f5e0ff'); t.end(); }); @@ -14,8 +14,8 @@ test('decimalToRgb', function (t) { t.deepEqual(color.decimalToRgb(0), {r:0,g:0,b:0}); t.deepEqual(color.decimalToRgb(1), {r:0,g:0,b:1}); t.deepEqual(color.decimalToRgb(16777215), {r:255,g:255,b:255}); - t.deepEqual(color.decimalToRgb(-16777215), {r:0,g:0,b:1}); // @todo - t.deepEqual(color.decimalToRgb(99999999), {r:245,g:224,b:255}); // @todo + t.deepEqual(color.decimalToRgb(-16777215), {r:0,g:0,b:1}); + t.deepEqual(color.decimalToRgb(99999999), {r:245,g:224,b:255}); t.end(); }); @@ -38,25 +38,25 @@ test('hexToRgb', function (t) { }); test('rgbToHex', function (t) { - t.equal(color.rgbToHex({r:0,g:0,b:0}), '#000000'); - t.equal(color.rgbToHex({r:255,g:255,b:255}), '#ffffff'); - t.equal(color.rgbToHex({r:0,g:255,b:170}), '#00ffaa'); + t.strictEqual(color.rgbToHex({r:0,g:0,b:0}), '#000000'); + t.strictEqual(color.rgbToHex({r:255,g:255,b:255}), '#ffffff'); + t.strictEqual(color.rgbToHex({r:0,g:255,b:170}), '#00ffaa'); t.end(); }); test('rgbToDecimal', function (t) { - t.equal(color.rgbToDecimal({r:0,g:0,b:0}), 0); - t.equal(color.rgbToDecimal({r:255,g:255,b:255}), 16777215); - t.equal(color.rgbToDecimal({r:0,g:255,b:170}), 65450); + t.strictEqual(color.rgbToDecimal({r:0,g:0,b:0}), 0); + t.strictEqual(color.rgbToDecimal({r:255,g:255,b:255}), 16777215); + t.strictEqual(color.rgbToDecimal({r:0,g:255,b:170}), 65450); t.end(); }); test('hexToDecimal', function (t) { - t.deepEqual(color.hexToDecimal('#000'), 0); - t.deepEqual(color.hexToDecimal('#000000'), 0); - t.deepEqual(color.hexToDecimal('#fff'), 16777215); - t.deepEqual(color.hexToDecimal('#ffffff'), 16777215); - t.deepEqual(color.hexToDecimal('#0fa'), 65450); - t.deepEqual(color.hexToDecimal('#00ffaa'), 65450); + t.strictEqual(color.hexToDecimal('#000'), 0); + t.strictEqual(color.hexToDecimal('#000000'), 0); + t.strictEqual(color.hexToDecimal('#fff'), 16777215); + t.strictEqual(color.hexToDecimal('#ffffff'), 16777215); + t.strictEqual(color.hexToDecimal('#0fa'), 65450); + t.strictEqual(color.hexToDecimal('#00ffaa'), 65450); t.end(); }); diff --git a/test/unit/util_math.js b/test/unit/util_math.js index 484b88c4..b282e90c 100644 --- a/test/unit/util_math.js +++ b/test/unit/util_math.js @@ -3,35 +3,35 @@ var math = require('../../src/util/math-util'); test('degToRad', function (t) { // @todo This is incorrect - t.equal(math.degToRad(0), 1.5707963267948966); - t.equal(math.degToRad(1), 1.5533430342749535); - t.equal(math.degToRad(180), -1.5707963267948966); - t.equal(math.degToRad(360), -4.71238898038469); - t.equal(math.degToRad(720), -10.995574287564276); + t.strictEqual(math.degToRad(0), 1.5707963267948966); + t.strictEqual(math.degToRad(1), 1.5533430342749535); + t.strictEqual(math.degToRad(180), -1.5707963267948966); + t.strictEqual(math.degToRad(360), -4.71238898038469); + t.strictEqual(math.degToRad(720), -10.995574287564276); t.end(); }); test('radToDeg', function (t) { - t.equal(math.radToDeg(0), 0); - t.equal(math.radToDeg(1), 57.29577951308232); - t.equal(math.radToDeg(180), 10313.240312354817); - t.equal(math.radToDeg(360), 20626.480624709635); - t.equal(math.radToDeg(720), 41252.96124941927); + t.strictEqual(math.radToDeg(0), 0); + t.strictEqual(math.radToDeg(1), 57.29577951308232); + t.strictEqual(math.radToDeg(180), 10313.240312354817); + t.strictEqual(math.radToDeg(360), 20626.480624709635); + t.strictEqual(math.radToDeg(720), 41252.96124941927); t.end(); }); test('clamp', function (t) { - t.equal(math.clamp(0, 0, 10), 0); - t.equal(math.clamp(1, 0, 10), 1); - t.equal(math.clamp(-10, 0, 10), 0); - t.equal(math.clamp(100, 0, 10), 10); + t.strictEqual(math.clamp(0, 0, 10), 0); + t.strictEqual(math.clamp(1, 0, 10), 1); + t.strictEqual(math.clamp(-10, 0, 10), 0); + t.strictEqual(math.clamp(100, 0, 10), 10); t.end(); }); test('wrapClamp', function (t) { - t.equal(math.wrapClamp(0, 0, 10), 0); - t.equal(math.wrapClamp(1, 0, 10), 1); - t.equal(math.wrapClamp(-10, 0, 10), 1); - t.equal(math.wrapClamp(100, 0, 10), 1); + t.strictEqual(math.wrapClamp(0, 0, 10), 0); + t.strictEqual(math.wrapClamp(1, 0, 10), 1); + t.strictEqual(math.wrapClamp(-10, 0, 10), 1); + t.strictEqual(math.wrapClamp(100, 0, 10), 1); t.end(); }); diff --git a/test/unit/util_xml.js b/test/unit/util_xml.js index 8682d832..1906a2ab 100644 --- a/test/unit/util_xml.js +++ b/test/unit/util_xml.js @@ -4,6 +4,6 @@ var xml = require('../../src/util/xml-escape'); test('escape', function (t) { var input = ''; var output = '<foo bar="he & llo '"></foo>'; - t.equal(xml(input), output); + t.strictEqual(xml(input), output); t.end(); });