[6a3a178] | 1 | 'use strict';
|
---|
| 2 |
|
---|
| 3 | var hasSymbols = require('has-symbols')();
|
---|
| 4 |
|
---|
| 5 | module.exports = function runTests(is, t) {
|
---|
| 6 | t.test('works with primitives', function (st) {
|
---|
| 7 | st.ok(is(), 'two absent args are the same');
|
---|
| 8 | st.ok(is(undefined), 'undefined & one absent arg are the same');
|
---|
| 9 | st.ok(is(undefined, undefined), 'undefined is undefined');
|
---|
| 10 | st.ok(is(null, null), 'null is null');
|
---|
| 11 | st.ok(is(true, true), 'true is true');
|
---|
| 12 | st.ok(is(false, false), 'false is false');
|
---|
| 13 | st.notOk(is(true, false), 'true is not false');
|
---|
| 14 | st.end();
|
---|
| 15 | });
|
---|
| 16 |
|
---|
| 17 | t.test('works with NaN', function (st) {
|
---|
| 18 | st.ok(is(NaN, NaN), 'NaN is NaN');
|
---|
| 19 | st.end();
|
---|
| 20 | });
|
---|
| 21 |
|
---|
| 22 | t.test('differentiates zeroes', function (st) {
|
---|
| 23 | st.ok(is(0, 0), '+0 is +0');
|
---|
| 24 | st.ok(is(-0, -0), '-0 is -0');
|
---|
| 25 | st.notOk(is(0, -0), '+0 is not -0');
|
---|
| 26 | st.end();
|
---|
| 27 | });
|
---|
| 28 |
|
---|
| 29 | t.test('nonzero numbers', function (st) {
|
---|
| 30 | st.ok(is(Infinity, Infinity), 'infinity is infinity');
|
---|
| 31 | st.ok(is(-Infinity, -Infinity), 'infinity is infinity');
|
---|
| 32 | st.ok(is(42, 42), '42 is 42');
|
---|
| 33 | st.notOk(is(42, -42), '42 is not -42');
|
---|
| 34 | st.end();
|
---|
| 35 | });
|
---|
| 36 |
|
---|
| 37 | t.test('strings', function (st) {
|
---|
| 38 | st.ok(is('', ''), 'empty string is empty string');
|
---|
| 39 | st.ok(is('foo', 'foo'), 'string is string');
|
---|
| 40 | st.notOk(is('foo', 'bar'), 'string is not different string');
|
---|
| 41 | st.end();
|
---|
| 42 | });
|
---|
| 43 |
|
---|
| 44 | t.test('objects', function (st) {
|
---|
| 45 | var obj = {};
|
---|
| 46 | st.ok(is(obj, obj), 'object is same object');
|
---|
| 47 | st.notOk(is(obj, {}), 'object is not different object');
|
---|
| 48 | st.end();
|
---|
| 49 | });
|
---|
| 50 |
|
---|
| 51 | t.test('Symbols', { skip: !hasSymbols }, function (st) {
|
---|
| 52 | st.ok(is(Symbol.iterator, Symbol.iterator), 'Symbol.iterator is itself');
|
---|
| 53 | st.notOk(is(Symbol(), Symbol()), 'different Symbols are not equal');
|
---|
| 54 | st.notOk(is(Symbol.iterator, Object(Symbol.iterator)), 'Symbol.iterator is not boxed form of itself');
|
---|
| 55 | st.end();
|
---|
| 56 | });
|
---|
| 57 | };
|
---|