From 4b6a7d5209f269c72edfcabfb6e5db09154a510f Mon Sep 17 00:00:00 2001 From: alex-eg Date: Thu, 31 Jul 2025 18:57:20 +0300 Subject: [PATCH] add sex-tests --- Makefile | 10 +++++++--- Readme.org | 2 +- tests/Makefile | 1 + tests/run.scm | 36 ++++++++++++++++++++++++++++++++++++ 4 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 tests/Makefile create mode 100644 tests/run.scm diff --git a/Makefile b/Makefile index 73e593e..50d495a 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,12 @@ CHICKEN_C = csc -MODULES = sexc main modules templates utils +MODULES = sexc modules templates utils OBJ = $(MODULES:%=%.o) # chicken flags CFLAGS = -compile-syntax -sexc: $(OBJ) +sexc: main.o $(OBJ) $(CHICKEN_C) $^ -o $@ main.o: main.scm @@ -15,5 +15,9 @@ main.o: main.scm %.o: %.scm $(CHICKEN_C) $< -e -c -o $@ $(CFLAGS) +sex-tests: $(OBJ) tests/run.scm + $(CHICKEN_C) tests/run.scm -c -o sex-tests.o + $(CHICKEN_C) $(OBJ) test.o -o sex-tests + clean: - rm -f $(OBJ) sexc + rm -f $(OBJ) sexc sex-tests diff --git a/Readme.org b/Readme.org index fe97229..64f9fd5 100644 --- a/Readme.org +++ b/Readme.org @@ -14,7 +14,7 @@ By the way, there's a way to make Chicken install eggs non-globally. Refer to the documentation for more info: https://wiki.call-cc.org/man/5/Extension%20tools#changing-the-repository-location -~chicken-install fmt getopt-long brev-separate~ +~chicken-install fmt getopt-long brev-separate test~ ** Compilation ~make~ diff --git a/tests/Makefile b/tests/Makefile new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tests/Makefile @@ -0,0 +1 @@ + diff --git a/tests/run.scm b/tests/run.scm new file mode 100644 index 0000000..6aa900e --- /dev/null +++ b/tests/run.scm @@ -0,0 +1,36 @@ +(declare (uses sexc)) + +(import + (chicken process) + (chicken process-context) + srfi-1 + test) + +;;; unkebabify +(test '- (unkebabify '-)) +(test '-- (unkebabify '--)) +(test '-> (unkebabify '->)) +(test '-= (unkebabify '-=)) +(test 'kebab_case (unkebabify 'kebab-case)) +(test '_what_ (unkebabify '-what-)) +(test 'this->member (unkebabify 'this->member)) +(test '_this_->_member_ (unkebabify '-this-->-member-)) +(test '__->>> (unkebabify '--->>>)) + +;;; atom-to-fmt-c +(test '%fun (atom-to-fmt-c 'fn)) +(test '%prototype (atom-to-fmt-c 'prototype)) +(test '%var (atom-to-fmt-c 'var)) +(test '%begin (atom-to-fmt-c 'begin)) +(test '%define (atom-to-fmt-c 'define)) +(test '%pointer (atom-to-fmt-c 'pointer)) +(test '%array (atom-to-fmt-c 'array)) +(test 'vector-ref (atom-to-fmt-c '@)) +(test '%include (atom-to-fmt-c 'include)) +(test '%cast (atom-to-fmt-c 'cast)) + +;;; make-field-access +(test 'a.b (make-field-access '(.b a))) +(test 'a.b.c (make-field-access '(.c a.b))) + +(test-exit)