1(import chicken.irregex chicken.platform chicken.keyword chicken.string)
2
3(let* ((version-tokens (string-split (chicken-version) "."))
4       (major (string->number (car version-tokens)))
5       (minor (string->number (cadr version-tokens))))
6
7  (display "Checking major and minor version numbers against chicken-version... ")
8  (assert (= (foreign-value "C_MAJOR_VERSION" int) major))
9  (assert (= (foreign-value "C_MINOR_VERSION" int) minor))
10  (print "ok")
11
12  (display "Checking the registered feature chicken-<major>.<minor>... ")
13  (let loop ((features (features)))
14    (if (null? features)
15        (error "Could not find feature chicken-<major>.<minor>")
16        (let ((feature (keyword->string (car features))))
17          (cond ((irregex-match "chicken-(\\d+)\\.(\\d+)" feature)
18                 => (lambda (match)
19                      (assert (= (string->number
20                                  (irregex-match-substring match 1))
21                                 major))
22                      (assert (= (string->number
23                                  (irregex-match-substring match 2))
24                                 minor))))
25                (else (loop (cdr features)))))))
26
27  (display "Checking the registered feature chicken-<major>... ")
28  (let loop ((features (features)))
29    (if (null? features)
30        (error "Could not find feature chicken-<major>")
31        (let ((feature (keyword->string (car features))))
32          (cond ((irregex-match "chicken-(\\d+)" feature)
33                 => (lambda (match)
34                      (assert (= (string->number
35                                  (irregex-match-substring match 1))
36                                 major))))
37                (else (loop (cdr features)))))))
38  (print "ok"))
39