add module testing

Also fix module import
This commit is contained in:
2026-09-14 23:35:48 +03:00
parent 5af2e99f5f
commit c976378363
5 changed files with 80 additions and 7 deletions

18
tests/modules/greet.sex Normal file
View File

@@ -0,0 +1,18 @@
;;; A module. Everything marked `pub' forms its public interface;
;;; everything else is private to this file.
;;;
;;; Importing a module does not link it: it pastes the declarations, so
;;; the compiled object still has to be handed to the C compiler. See
;;; greet-app.sex.
(include stdio.h)
(pub var greet-count int 0)
(pub fn greet ((name (* const char))) void
(++ greet-count)
(printf "hello, %s\n" name))
;;; Not `pub': invisible to importers, and static in the generated C.
(fn unused-helper () void
(printf "private\n"))