Better debugging

This commit is contained in:
2024-08-21 21:40:14 +03:00
parent df0dc199a0
commit f836e388d7
24 changed files with 275 additions and 200 deletions
+4 -4
View File
@@ -1,5 +1,5 @@
import { describe, expect, it } from '@jest/globals';
import { $, Term, _, d, g, l, m, undef } from '../src/core';
import { $, Term, _, g, l, n, undef } from '../src/core';
import { toNOrd as $o, NOrd } from '../src/ord';
import { toBoolean as $b, iif } from '../src/bool';
import { toNumber as $n, Succ, Zero, fromNumber as _n, fromNumber as _nn, cmp as cmpn, eq as eqn, even, gt as ngt, odd, succ, sum, } from '../src/num';
@@ -9,14 +9,14 @@ import { toString as $s } from '../src/string';
import { show as nshow } from '../src/num.show';
import { show } from '../src/list.show';
m('list.spec');
n('list.spec');
describe('List', () => {
const infinite: Term = g('infinite', iterate._(Succ)._(Zero));
const _na: (xs: number[]) => Term = xs => !xs.length ? Nil : Cons._(_n(xs[0]))._(d(() => _na(xs.slice(1))));
const _na: (xs: number[]) => Term = xs => !xs.length ? Nil : Cons._(_n(xs[0]))._(_(() => _na(xs.slice(1))));
const $na: (xs: Term) => number[] = xs => $(xs._(_([]))._(l('x', l('xs', d(bs => _([$n(bs['x']), ...$na(bs['xs'])]))))));
const $na: (xs: Term) => number[] = xs => $(xs._(_([]))._(l('x', l('xs', _(({ x, xs }) => _([$n(x), ...$na(xs)]))))));
describe('toArray', () => {
it('converts []', () => {
+4 -4
View File
@@ -1,15 +1,15 @@
import { describe, expect, it } from '@jest/globals';
import { Term, d, g, m, undef } from '../src/core';
import { Term, _, g, n, undef } from '../src/core';
import { toNOrd as $o, NOrd } from '../src/ord';
import { toBoolean as $b, fromBoolean as _b } from '../src/bool';
import { toNumber as $n, Succ, Zero, fromNumber as _n, cmp, div, eq, ge, gt, ifz, le, lt, mod, mul, pred, sub, succ, sum } from '../src/num';
import { toNumber as $n, Succ, Zero, fromNumber as _n, cmp, div, eq, ge, gt, ifz, le, lt, mod, mul, pred, sub, succ, sum } from '../src/num';
import { toString as $s } from '../src/string';
import { show } from '../src/num.show';
m('num.spec');
n('num.spec');
describe('Num', () => {
const infinity: Term = g('infinity', d(bs => Succ._(bs['num.spec::infinity'])));
const infinity: Term = g('infinity', _(() => Succ._('num.spec', 'infinity')));
describe('toNumber', () => {
it('converts 0', () => {
+3 -3
View File
@@ -1,5 +1,5 @@
import { describe, expect, it } from '@jest/globals';
import { Term, _, g, l, m, undef } from '../src/core';
import { Term, _, g, l, n, undef } from '../src/core';
import { NOrd, toNOrd } from '../src/ord';
import { toBoolean as $b } from '../src/bool';
import { toNumber as $n, Zero, gt as ngt } from '../src/num';
@@ -7,10 +7,10 @@ import { toChar as $c, fromChar as _c } from '../src/char';
import { toString as $s, Cons, Empty, fromString as _s, append, cmp, empty, eq, ge, gt, le, len, lt, wrap } from '../src/string';
import { show } from '../src/string.show';
m('string.spec');
n('string.spec');
describe('String', () => {
const infinite: Term = g('infinite', Cons._(_c('a'))._('string.spec::infinite'));
const infinite: Term = g('infinite', Cons._(_c('a'))._('string.spec', 'infinite'));
describe('toString', () => {
it('converts ""', () => {