tisp

tiny lisp
git clone git://edryd.org/tisp
Log | Files | Refs | LICENSE

commit f5e7aa1f1e1d2f98a75bf61b1e24aeeeb1106b2e
parent 3107e00748d5f097eadd6639da1725f638acf093
Author: Ed van Bruggen <edvb@uw.edu>
Date:   Sun,  8 Apr 2018 22:41:14 -0700

Add rational equivalence test to = primitive

Diffstat:
t/prim/eq.expect | 8++++++++
t/prim/eq.tsp | 8++++++++
tisp.c | 4++++
3 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/t/prim/eq.expect b/t/prim/eq.expect @@ -9,6 +9,14 @@ t () t t +t +t +() +() +() +() +t +t () t () diff --git a/t/prim/eq.tsp b/t/prim/eq.tsp @@ -7,6 +7,14 @@ (= 1 1 2 1 1 1) (= 1 1 1 1 1 2) (= 2 1 1 1 1 1) +(= 4/5 4/5) +(= 2/1 2) +(= 2/4 1/2) +(= 2/4 1/2 4/8 3/6) +(= 1/2 4/5) +(= 5/4 4/5) +(= 3 3/2) +(= 3 3/2 3 3 3) (= (+ 1 1) (+ 2 0)) (= "foo" "foo") (= "foo" "bar") diff --git a/tisp.c b/tisp.c @@ -47,6 +47,10 @@ vals_eq(Val a, Val b) if (a->v.i != b->v.i) return 0; break; + case RATIONAL: + if (a->v.r.num != b->v.r.num || a->v.r.den != b->v.r.den) + return 0; + break; case SYMBOL: case STRING: if (strcmp(a->v.s, b->v.s))