Legend:
- Unmodified
- Added
- Removed
-
imaps-frontend/node_modules/which-boxed-primitive/test/index.js
r0c6b92a r79a0317 3 3 var test = require('tape'); 4 4 var inspect = require('object-inspect'); 5 var whichBoxedPrimitive = require('..'); 5 var forEach = require('for-each'); 6 var v = require('es-value-fixtures'); 6 7 7 var debug = function (v, m) { return inspect(v) + ' ' + m; }; 8 9 var forEach = function (arr, func) { 10 var i; 11 for (i = 0; i < arr.length; ++i) { 12 func(arr[i], i, arr); 13 } 14 }; 15 16 var hasSymbols = require('has-symbols')(); 17 var hasBigInts = typeof BigInt === 'function'; 18 19 var primitives = [ 20 true, 21 false, 22 42, 23 NaN, 24 Infinity, 25 '', 26 'foo' 27 ].concat( 28 hasSymbols ? [Symbol(), Symbol.iterator] : [], 29 hasBigInts ? BigInt(42) : [] 30 ); 8 var whichBoxedPrimitive = require('../'); 31 9 32 10 var objects = [ … … 36 14 [], 37 15 {} 38 ] ;16 ].concat(v.objects); 39 17 40 18 test('isBoxedPrimitive', function (t) { 41 19 t.test('unboxed primitives', function (st) { 42 forEach( [null, undefined].concat(primitives), function (primitive) {43 st.equal(null, whichBoxedPrimitive(primitive), debug(primitive, 'is a primitive, but not a boxed primitive'));20 forEach(v.primitives, function (primitive) { 21 st.equal(null, whichBoxedPrimitive(primitive), inspect(primitive) + ' is a primitive, but not a boxed primitive'); 44 22 }); 45 23 st.end(); … … 47 25 48 26 t.test('boxed primitives', function (st) { 49 forEach(primitives, function (primitive) { 50 var boxed = Object(primitive); 51 var expected = boxed.constructor.name; 52 st.equal(typeof expected, 'string', 'expected is string'); 53 st.equal(whichBoxedPrimitive(boxed), expected, debug(boxed, 'is a boxed primitive: ' + expected)); 27 forEach(v.primitives, function (primitive) { 28 if (primitive != null) { // eslint-disable-line eqeqeq 29 var boxed = Object(primitive); 30 var expected = boxed.constructor.name; 31 st.equal(typeof expected, 'string', 'expected is string'); 32 st.equal(whichBoxedPrimitive(boxed), expected, inspect(boxed) + ' is a boxed primitive: ' + expected); 33 } 54 34 }); 55 35 st.end(); … … 58 38 t.test('non-primitive objects', function (st) { 59 39 forEach(objects, function (object) { 60 st.equal(undefined, whichBoxedPrimitive(object), debug(object, 'is not a primitive, boxed or otherwise'));40 st.equal(undefined, whichBoxedPrimitive(object), inspect(object) + ' is not a primitive, boxed or otherwise'); 61 41 }); 62 42 st.end();
Note:
See TracChangeset
for help on using the changeset viewer.