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.
199 lines
4.7 KiB
199 lines
4.7 KiB
import { describe, expect, it } from '@jest/globals';
|
|
import { toNOrd as $o, NOrd } from '../src/ord';
|
|
import { toBoolean as $b, fromBoolean as _b } from '../src/bool';
|
|
import { fromNumber as _n } from '../src/num';
|
|
import { toChar as $, fromChar as _, cmp, eq, ge, gt, le, lt } from '../src/char';
|
|
|
|
describe('Char', () => {
|
|
describe('toChar', () => {
|
|
it('converts "0"', () => {
|
|
expect($(_n(48))).toBe('0');
|
|
});
|
|
|
|
it('converts "a"', () => {
|
|
expect($(_n(97))).toBe('a');
|
|
});
|
|
|
|
it('converts "Z"', () => {
|
|
expect($(_n(90))).toBe('Z');
|
|
});
|
|
|
|
it('converts "-"', () => {
|
|
expect($(_n(45))).toBe('-');
|
|
});
|
|
});
|
|
|
|
describe('fromChar', () => {
|
|
it('converts "0"', () => {
|
|
expect($(_('0'))).toBe('0');
|
|
});
|
|
|
|
it('converts "a"', () => {
|
|
expect($(_('a'))).toBe('a');
|
|
});
|
|
|
|
it('converts "Z"', () => {
|
|
expect($(_('Z'))).toBe('Z');
|
|
});
|
|
|
|
it('converts "-"', () => {
|
|
expect($(_('-'))).toBe('-');
|
|
});
|
|
});
|
|
|
|
describe('cmp', () => {
|
|
it('"0" cmp "0" is EQ', () => {
|
|
expect($o(cmp._(_('0'))._(_('0')))).toBe(NOrd.EQ);
|
|
});
|
|
|
|
it('"0" cmp "a" is LT', () => {
|
|
expect($o(cmp._(_('0'))._(_('a')))).toBe(NOrd.LT);
|
|
});
|
|
|
|
it('"a" cmp "0" is GT', () => {
|
|
expect($o(cmp._(_('a'))._(_('0')))).toBe(NOrd.GT);
|
|
});
|
|
|
|
it('"z" cmp "z" is EQ', () => {
|
|
expect($o(cmp._(_('z'))._(_('z')))).toBe(NOrd.EQ);
|
|
});
|
|
|
|
it('"z" cmp "-" is GT', () => {
|
|
expect($o(cmp._(_('z'))._(_('-')))).toBe(NOrd.GT);
|
|
});
|
|
|
|
it('"-" cmp "z" is LT', () => {
|
|
expect($o(cmp._(_('-'))._(_('z')))).toBe(NOrd.LT);
|
|
});
|
|
});
|
|
|
|
describe('lt', () => {
|
|
it('"0" lt "0" is False', () => {
|
|
expect($b(lt._(_('0'))._(_('0')))).toBe(false);
|
|
});
|
|
|
|
it('"0" lt "a" is True', () => {
|
|
expect($b(lt._(_('0'))._(_('a')))).toBe(true);
|
|
});
|
|
|
|
it('"a" lt "0" is False', () => {
|
|
expect($b(lt._(_('a'))._(_('0')))).toBe(false);
|
|
});
|
|
|
|
it('"z" lt "z" is False', () => {
|
|
expect($b(lt._(_('z'))._(_('z')))).toBe(false);
|
|
});
|
|
|
|
it('"z" lt "-" is False', () => {
|
|
expect($b(lt._(_('z'))._(_('-')))).toBe(false);
|
|
});
|
|
|
|
it('"-" lt "z" is True', () => {
|
|
expect($b(lt._(_('-'))._(_('z')))).toBe(true);
|
|
});
|
|
});
|
|
|
|
describe('le', () => {
|
|
it('"0" le "0" is True', () => {
|
|
expect($b(le._(_('0'))._(_('0')))).toBe(true);
|
|
});
|
|
|
|
it('"0" le "a" is True', () => {
|
|
expect($b(le._(_('0'))._(_('a')))).toBe(true);
|
|
});
|
|
|
|
it('"a" le "0" is False', () => {
|
|
expect($b(le._(_('a'))._(_('0')))).toBe(false);
|
|
});
|
|
|
|
it('"z" le "z" is True', () => {
|
|
expect($b(le._(_('z'))._(_('z')))).toBe(true);
|
|
});
|
|
|
|
it('"z" le "-" is False', () => {
|
|
expect($b(le._(_('z'))._(_('-')))).toBe(false);
|
|
});
|
|
|
|
it('"-" le "z" is True', () => {
|
|
expect($b(le._(_('-'))._(_('z')))).toBe(true);
|
|
});
|
|
});
|
|
|
|
describe('eq', () => {
|
|
it('"0" eq "0" is True', () => {
|
|
expect($b(eq._(_('0'))._(_('0')))).toBe(true);
|
|
});
|
|
|
|
it('"0" eq "a" is False', () => {
|
|
expect($b(eq._(_('0'))._(_('a')))).toBe(false);
|
|
});
|
|
|
|
it('"a" eq "0" is False', () => {
|
|
expect($b(eq._(_('a'))._(_('0')))).toBe(false);
|
|
});
|
|
|
|
it('"z" eq "z" is True', () => {
|
|
expect($b(eq._(_('z'))._(_('z')))).toBe(true);
|
|
});
|
|
|
|
it('"z" eq "-" is False', () => {
|
|
expect($b(eq._(_('z'))._(_('-')))).toBe(false);
|
|
});
|
|
|
|
it('"-" eq "z" is False', () => {
|
|
expect($b(eq._(_('-'))._(_('z')))).toBe(false);
|
|
});
|
|
});
|
|
|
|
describe('ge', () => {
|
|
it('"0" ge "0" is True', () => {
|
|
expect($b(ge._(_('0'))._(_('0')))).toBe(true);
|
|
});
|
|
|
|
it('"0" ge "a" is False', () => {
|
|
expect($b(ge._(_('0'))._(_('a')))).toBe(false);
|
|
});
|
|
|
|
it('"a" ge "0" is True', () => {
|
|
expect($b(ge._(_('a'))._(_('0')))).toBe(true);
|
|
});
|
|
|
|
it('"z" ge "z" is True', () => {
|
|
expect($b(ge._(_('z'))._(_('z')))).toBe(true);
|
|
});
|
|
|
|
it('"z" ge "-" is True', () => {
|
|
expect($b(ge._(_('z'))._(_('-')))).toBe(true);
|
|
});
|
|
|
|
it('"-" ge "z" is False', () => {
|
|
expect($b(ge._(_('-'))._(_('z')))).toBe(false);
|
|
});
|
|
});
|
|
|
|
describe('gt', () => {
|
|
it('"0" gt "0" is False', () => {
|
|
expect($b(gt._(_('0'))._(_('0')))).toBe(false);
|
|
});
|
|
|
|
it('"0" gt "a" is False', () => {
|
|
expect($b(gt._(_('0'))._(_('a')))).toBe(false);
|
|
});
|
|
|
|
it('"a" gt "0" is True', () => {
|
|
expect($b(gt._(_('a'))._(_('0')))).toBe(true);
|
|
});
|
|
|
|
it('"z" gt "z" is False', () => {
|
|
expect($b(gt._(_('z'))._(_('z')))).toBe(false);
|
|
});
|
|
|
|
it('"z" gt "-" is True', () => {
|
|
expect($b(gt._(_('z'))._(_('-')))).toBe(true);
|
|
});
|
|
|
|
it('"-" gt "z" is False', () => {
|
|
expect($b(gt._(_('-'))._(_('z')))).toBe(false);
|
|
});
|
|
});
|
|
});
|
|
|