From ab881e4c311596236fe35ff428d7af8156d5e679 Mon Sep 17 00:00:00 2001 From: alex-eg Date: Tue, 20 Oct 2026 11:49:29 +0300 Subject: [PATCH] test semen through semen-process alone Its fn accessors, walk-form and macro-expand were exported to be called on hand-built forms, checking what every compiled function and macro already goes through; sex-fn-public? and sex-fn-body had no other caller. --- semen.scm | 14 +------------- tests/semen.scm | 42 ++---------------------------------------- 2 files changed, 3 insertions(+), 53 deletions(-) diff --git a/semen.scm b/semen.scm index e2be434a..353bc390 100644 --- a/semen.scm +++ b/semen.scm @@ -19,11 +19,7 @@ ) (export/rename (process semen-process)) -(export closure-env-declaration - ;; for the tests - sex-fn? sex-fn-public? sex-fn-name sex-fn-arglist - sex-fn-return-type sex-fn-prototype sex-fn-body - walk-form macro-expand) +(export closure-env-declaration) ;;; for lambda extraction, docstring processing, macro expansion, ;;; injection of module headers, i.e. all things that rearrange code @@ -1965,9 +1961,6 @@ Returns #f if the form is not a function, returns the form otherwise" ('extern 'fn . _)) form) (else #f))) -(define (sex-fn-public? fn-form) - (eq? (first fn-form) 'pub)) - (define (sex-fn-name fn-form) (assert (sex-fn? fn-form) (fmt #f "Form " fn-form " is not a function")) @@ -1982,8 +1975,3 @@ Returns #f if the form is not a function, returns the form otherwise" (assert (sex-fn? fn-form) (fmt #f "Form " fn-form " is not a function")) (fourth (fn-core fn-form))) - -(define (sex-fn-body fn-form) - (assert (sex-fn? fn-form) - (fmt #f "Form " fn-form " is not a function")) - (drop fn-form (fn-header-length fn-form))) diff --git a/tests/semen.scm b/tests/semen.scm index 3e685ecd..0b895549 100644 --- a/tests/semen.scm +++ b/tests/semen.scm @@ -1,35 +1,8 @@ -(import srfi-69 - semen +(import semen types) -(define print-str-fn - '(fn print-str ((s string)) void - (printf "%s" s))) - -(define sum-fn - '(pub fn sum ((a int) (b int)) float - (return (cast (+ a b) float)))) - (test-group "semen" - (test-assert (sex-fn? print-str-fn)) - (test #f (sex-fn-public? print-str-fn)) - (test 'void (sex-fn-return-type print-str-fn)) - (test 'print-str (sex-fn-name print-str-fn)) - (test '((s string)) (sex-fn-arglist print-str-fn)) - (test '(fn print-str ((s string)) void) (sex-fn-prototype print-str-fn)) - (test '((printf "%s" s)) (sex-fn-body print-str-fn)) - - (test-assert (sex-fn? sum-fn)) - (test #t (sex-fn-public? sum-fn)) - (test 'float (sex-fn-return-type sum-fn)) - (test 'sum (sex-fn-name sum-fn)) - (test '((a int) (b int)) (sex-fn-arglist sum-fn)) - (test '(pub fn sum ((a int) (b int)) float) (sex-fn-prototype sum-fn)) - (test '((return (cast (+ a b) float))) (sex-fn-body sum-fn)) - - (test-assert (sex-fn? '(extern fn foo () void))) - (test 'foo (sex-fn-name '(extern fn foo () void))) - (test #f (sex-fn? '(struct point ((x int))))) +;;; Macro expansion (let ((sex-code '((defmacro (sum-var name a b c) @@ -39,17 +12,6 @@ (test '((var v 6)) (semen-process sex-code))) -;;; Macro expansion - - (define (form-identity form env) - form) - - (test 'a (walk-form 'a form-identity (make-hash-table))) - (test '(a b c) (walk-form '(a b c) form-identity (make-hash-table))) - - (test 'a (macro-expand 'a)) - (test '(a b c) (macro-expand '(a b c))) - (let ((sex-code-macro '((defmacro (x10 a) `(* 10 ,a))