Sha256: f221d0c3562bee3066c5d5b41ac9dcec310b12f09a420b4ca1f75ff98084131a

Contents?: true

Size: 1.26 KB

Versions: 11

Compression:

Stored size: 1.26 KB

Contents

"use strict";

var _test = require("tap").test;
var is = require("../");

function test(name, fn) {
    return _test(name, function(t) {
        fn(t, t.ok.bind(t), t.notOk.bind(t));
    });
}

test("various", function(t, yes, no) {
    function fn() {
    }

    yes(is.nan(NaN));
    no(is.nan(1));
    no(is.nan("asdf"));

    yes(is.boolean(true));
    no(is.boolean(new Boolean(true)));

    yes(is.number(1));
    no(is.number(new Number(1)));

    yes(is.string("asdf"));
    no(is.string(new String("asdf")));

    yes(is.fn(fn));
    no(is.fn({}));

    yes(is.object({}));
    no(is.object(null));
    no(is.object(fn));

    yes([null, undefined, true, 1, "asdf"].every(is.primitive));
    no([{}, fn, new Number(1), /regexp/].some(is.primitive));

    yes(is.array([]));

    yes(is.finitenumber(1));
    yes(is.finitenumber(1.1));
    no(is.finitenumber(NaN));
    no(is.finitenumber(Infinity));
    no(is.finitenumber(-Infinity));
    no(is.finitenumber("1"));

    yes(is.someof(1, [-1, 1, 3]));
    yes(is.someof("x", [0, 1, "x"]));
    no(is.someof(1, ["1"]));

    no(is.noneof(1, [-1, 1, 3]));
    no(is.noneof("x", [0, 1, "x"]));
    yes(is.noneof(1, ["1"]));

    yes(is.own({a: 1}, "a"));
    no(is.own({a: 1}, "b"));
    no(is.own({a: 1}, "toString"));

    t.end();
});

Version data entries

11 entries across 11 versions & 4 rubygems

Version Path
ilog-0.4.1 node_modules/simple-is/test/simple-is-tests.js
ilog-0.4.0 node_modules/simple-is/test/simple-is-tests.js
ilog-0.3.3 node_modules/simple-is/test/simple-is-tests.js
xcodebuild-helper-1.2.5 externals/ios-sim-master/node_modules/simple-is/test/simple-is-tests.js
xcodebuild-helper-1.2.3 externals/ios-sim-master/node_modules/simple-is/test/simple-is-tests.js
es6_tilt-0.1.2 test/dummy/app/assets/javascripts/node_modules/simple-is/test/simple-is-tests.js
es6_tilt-0.1.1 test/dummy/app/assets/javascripts/node_modules/simple-is/test/simple-is-tests.js
es6_tilt-0.1.0 test/dummy/app/assets/javascripts/node_modules/simple-is/test/simple-is-tests.js
gulp_assets-1.0.0.pre.5 template/node_modules/babel-core/node_modules/regenerator/node_modules/defs/node_modules/simple-is/test/simple-is-tests.js
gulp_assets-1.0.0.pre.4 template/node_modules/babel-core/node_modules/regenerator/node_modules/defs/node_modules/simple-is/test/simple-is-tests.js
gulp_assets-1.0.0.pre.3 template/node_modules/babel-core/node_modules/regenerator/node_modules/defs/node_modules/simple-is/test/simple-is-tests.js