Ignore:
Timestamp:
01/21/25 03:08:24 (3 days ago)
Author:
stefan toskovski <stefantoska84@…>
Branches:
main
Parents:
0c6b92a
Message:

F4 Finalna Verzija

File:
1 edited

Legend:

Unmodified
Added
Removed
  • imaps-frontend/node_modules/which-boxed-primitive/test/index.js

    r0c6b92a r79a0317  
    33var test = require('tape');
    44var inspect = require('object-inspect');
    5 var whichBoxedPrimitive = require('..');
     5var forEach = require('for-each');
     6var v = require('es-value-fixtures');
    67
    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 );
     8var whichBoxedPrimitive = require('../');
    319
    3210var objects = [
     
    3614        [],
    3715        {}
    38 ];
     16].concat(v.objects);
    3917
    4018test('isBoxedPrimitive', function (t) {
    4119        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');
    4422                });
    4523                st.end();
     
    4725
    4826        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                        }
    5434                });
    5535                st.end();
     
    5838        t.test('non-primitive objects', function (st) {
    5939                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');
    6141                });
    6242                st.end();
Note: See TracChangeset for help on using the changeset viewer.