AtlatestRepositorysigil-geometry

sigil-geometry / tree / testtest-facade.sgl

1;;; (sigil geometry) must re-export every export of the six modules.
2;;;
3;;; Reads the export lists from source (run from the package root, as
4;;; `sigil test` does) and compares them as sets.
5
6(import (sigil test)
7 (sigil io)
8 (sigil fs)
9 (sigil geometry))
11(define module-files
12 '("src/sigil/geometry/vec.sgl"
13 "src/sigil/geometry/mat3.sgl"
14 "src/sigil/geometry/mat4.sgl"
15 "src/sigil/geometry/quat.sgl"
16 "src/sigil/geometry/camera.sgl"
17 "src/sigil/geometry/ray.sgl"))
19;; Every name in every (export ...) clause of the library: a library may
20;; have more than one.
21(define (exports-of path)
22 (let ((lib (read (open-input-string (read-file-string path)))))
23 (apply append
24 (map cdr (filter (lambda (clause)
25 (and (pair? clause) (eq? (car clause) 'export)))
26 (cddr lib))))))
28(define (missing from in)
29 (filter (lambda (name) (not (memq name in))) from))
31(test-group "facade"
32 (test "the module files are where the test expects"
33 (for-each (lambda (f) (assert-true (file-exists? f))) module-files)
34 (assert-true (> (length (exports-of "src/sigil/geometry/mat4.sgl")) 10)))
36 (test "every module export is re-exported"
37 (let ((facade (exports-of "src/sigil/geometry.sgl"))
38 (all (apply append (map exports-of module-files))))
39 (assert-equal '() (missing all facade))))
41 (test "the facade exports nothing the modules lack"
42 (let ((facade (exports-of "src/sigil/geometry.sgl"))
43 (all (apply append (map exports-of module-files))))
44 (assert-equal '() (missing facade all))))
46 (test "names from each module resolve through the facade"
47 (assert-true (procedure? vec3-cross!))
48 (assert-true (procedure? mat3->std140!))
49 (assert-true (procedure? mat4-inverse!))
50 (assert-true (procedure? quat-slerp!))
51 (assert-true (procedure? mat4-look-at!))
52 (assert-true (procedure? ray-triangle-hit!))))