You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.6 KiB
54 lines
1.6 KiB
import { describe, expect, it } from '@jest/globals';
|
|
import { undef } from '../src/core';
|
|
import { toBoolean as $b, fromBoolean as _b, not } from '../src/bool';
|
|
import { toNumber as $n, fromNumber as _n, succ } from '../src/num';
|
|
import { Pair, both, first, fst, second, snd } from '../src/pair';
|
|
|
|
describe('Pair', () => {
|
|
describe('fst', () => {
|
|
it('returns first', () => {
|
|
expect($b(fst._(Pair._(_b(false))._(_n(0))))).toBe(false);
|
|
});
|
|
|
|
it('ignores second', () => {
|
|
expect($b(fst._(Pair._(_b(false))._(undef)))).toBe(false);
|
|
});
|
|
});
|
|
|
|
describe('snd', () => {
|
|
it('returns second', () => {
|
|
expect($n(snd._(Pair._(_b(false))._(_n(0))))).toBe(0);
|
|
});
|
|
|
|
it('ignores first', () => {
|
|
expect($n(snd._(Pair._(undef)._(_n(0))))).toBe(0);
|
|
});
|
|
});
|
|
|
|
describe('first', () => {
|
|
it('updates first', () => {
|
|
expect($b(fst._(first._(not)._(Pair._(_b(false))._(_n(0)))))).toBe(true);
|
|
});
|
|
|
|
it('ignores second', () => {
|
|
expect($b(fst._(first._(not)._(Pair._(_b(false))._(undef))))).toBe(true);
|
|
});
|
|
});
|
|
|
|
describe('second', () => {
|
|
it('updates second', () => {
|
|
expect($n(snd._(second._(succ)._(Pair._(_b(false))._(_n(0)))))).toBe(1);
|
|
});
|
|
|
|
it('ignores first', () => {
|
|
expect($n(snd._(second._(succ)._(Pair._(undef)._(_n(0)))))).toBe(1);
|
|
});
|
|
});
|
|
|
|
describe('both', () => {
|
|
it('updates both', () => {
|
|
expect($b(fst._(both._(not)._(succ)._(Pair._(_b(false))._(_n(0)))))).toBe(true);
|
|
expect($n(snd._(both._(not)._(succ)._(Pair._(_b(false))._(_n(0)))))).toBe(1);
|
|
});
|
|
});
|
|
});
|
|
|