deno.land / x / rambda@v9.1.1 / source / xor.spec.js

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { xor } from './xor.js'
test('compares two values with exclusive or', () => { expect(xor(true, true)).toBeFalse() expect(xor(true, false)).toBeTrue() expect(xor(false, true)).toBeTrue() expect(xor(false, false)).toBeFalse()})
test('when both values are truthy, it should return false', () => { expect(xor(true, 'foo')).toBeFalse() expect(xor(42, true)).toBeFalse() expect(xor('foo', 42)).toBeFalse() expect(xor({}, true)).toBeFalse() expect(xor(true, [])).toBeFalse() expect(xor([], {})).toBeFalse() expect(xor(new Date(), true)).toBeFalse() expect(xor(true, Infinity)).toBeFalse() expect(xor(Infinity, new Date())).toBeFalse()})
test('when both values are falsy, it should return false', () => { expect(xor(null, false)).toBeFalse() expect(xor(false, undefined)).toBeFalse() expect(xor(undefined, null)).toBeFalse() expect(xor(0, false)).toBeFalse() expect(xor(false, NaN)).toBeFalse() expect(xor(NaN, 0)).toBeFalse() expect(xor('', false)).toBeFalse()})
test('when one argument is truthy and the other is falsy, it should return true', () => { expect(xor('foo', null)).toBeTrue() expect(xor(null, 'foo')).toBeTrue() expect(xor(undefined, 42)).toBeTrue() expect(xor(42, undefined)).toBeTrue() expect(xor(Infinity, NaN)).toBeTrue() expect(xor(NaN, Infinity)).toBeTrue() expect(xor({}, '')).toBeTrue() expect(xor('', {})).toBeTrue() expect(xor(new Date(), 0)).toBeTrue() expect(xor(0, new Date())).toBeTrue() expect(xor([], null)).toBeTrue() expect(xor(undefined, [])).toBeTrue()})
rambda

Version Info

Tagged at
2 months ago