Projekt

Obecné

Profil

Stáhnout (1.64 KB) Statistiky
| Větev: | Revize:
1
'use strict';
2

    
3
var test = require('tape');
4
var hasSymbols = require('has-symbols')();
5

    
6
var is = require('../');
7

    
8
test('works with primitives', function (t) {
9
	t.ok(is(), 'two absent args are the same');
10
	t.ok(is(undefined), 'undefined & one absent arg are the same');
11
	t.ok(is(undefined, undefined), 'undefined is undefined');
12
	t.ok(is(null, null), 'null is null');
13
	t.ok(is(true, true), 'true is true');
14
	t.ok(is(false, false), 'false is false');
15
	t.notOk(is(true, false), 'true is not false');
16
	t.end();
17
});
18

    
19
test('works with NaN', function (t) {
20
	t.ok(is(NaN, NaN), 'NaN is NaN');
21
	t.end();
22
});
23

    
24
test('differentiates zeroes', function (t) {
25
	t.ok(is(0, 0), '+0 is +0');
26
	t.ok(is(-0, -0), '-0 is -0');
27
	t.notOk(is(0, -0), '+0 is not -0');
28
	t.end();
29
});
30

    
31
test('nonzero numbers', function (t) {
32
	t.ok(is(Infinity, Infinity), 'infinity is infinity');
33
	t.ok(is(-Infinity, -Infinity), 'infinity is infinity');
34
	t.ok(is(42, 42), '42 is 42');
35
	t.notOk(is(42, -42), '42 is not -42');
36
	t.end();
37
});
38

    
39
test('strings', function (t) {
40
	t.ok(is('', ''), 'empty string is empty string');
41
	t.ok(is('foo', 'foo'), 'string is string');
42
	t.notOk(is('foo', 'bar'), 'string is not different string');
43
	t.end();
44
});
45

    
46
test('objects', function (t) {
47
	var obj = {};
48
	t.ok(is(obj, obj), 'object is same object');
49
	t.notOk(is(obj, {}), 'object is not different object');
50
	t.end();
51
});
52

    
53
test('Symbols', { skip: !hasSymbols }, function (t) {
54
	t.ok(is(Symbol.iterator, Symbol.iterator), 'Symbol.iterator is itself');
55
	t.notOk(is(Symbol(), Symbol()), 'different Symbols are not equal');
56
	t.notOk(is(Symbol.iterator, Object(Symbol.iterator)), 'Symbol.iterator is not boxed form of itself');
57
	t.end();
58
});
    (1-1/1)