~ chicken-core (chicken-5) 66e61af856ed7817dc07a0f542e9c2e27e284e36


commit 66e61af856ed7817dc07a0f542e9c2e27e284e36
Author:     Mario Domenech Goulart <mario.goulart@gmail.com>
AuthorDate: Thu Apr 17 23:32:09 2014 -0300
Commit:     Peter Bex <peter.bex@xs4all.nl>
CommitDate: Mon Apr 21 16:32:16 2014 +0200

    Add tests/version-tests.scm
    
    Basic version tests.  Check if chicken-version matches the values for
    C_MAJOR_VERSION/C_MINOR_VERSION and the registered
    chicken-<major>.<minor> feature.
    
    Signed-off-by: Peter Bex <peter.bex@xs4all.nl>

diff --git a/distribution/manifest b/distribution/manifest
index bb8f1682..5a360685 100644
--- a/distribution/manifest
+++ b/distribution/manifest
@@ -209,6 +209,7 @@ tests/reverser/tags/1.1/reverser.setup
 tests/reverser/tags/1.1/reverser.scm
 tests/rev-app.scm
 tests/signal-tests.scm
+tests/version-tests.scm
 tweaks.scm
 utils.scm
 apply-hack.x86.S
diff --git a/tests/runtests.bat b/tests/runtests.bat
index 03e76849..b037cb72 100644
--- a/tests/runtests.bat
+++ b/tests/runtests.bat
@@ -20,6 +20,10 @@ set interpret=..\csi -n -include-path %TEST_DIR%/..
 
 del /f /q *.exe *.so *.o *.import.* ..\foo.import.*
 
+echo ======================================== version tests ...
+%interpret% -s version-tests.scm
+if errorlevel 1 exit /b 1
+
 echo ======================================== compiler tests ...
 %compile% compiler-tests.scm
 if errorlevel 1 exit /b 1
diff --git a/tests/runtests.sh b/tests/runtests.sh
index b3570ded..d2ffe72c 100755
--- a/tests/runtests.sh
+++ b/tests/runtests.sh
@@ -70,6 +70,8 @@ interpret="../csi -n -include-path ${TEST_DIR}/.."
 
 rm -f *.exe *.so *.o *.import.* a.out ../foo.import.*
 
+echo "======================================== version tests ..."
+$interpret -s version-tests.scm
 
 echo "======================================== compiler tests ..."
 $compile compiler-tests.scm
diff --git a/tests/version-tests.scm b/tests/version-tests.scm
new file mode 100644
index 00000000..09769846
--- /dev/null
+++ b/tests/version-tests.scm
@@ -0,0 +1,27 @@
+(use irregex)
+
+(let* ((version-tokens (string-split (chicken-version) "."))
+       (major (string->number (car version-tokens)))
+       (minor (string->number (cadr version-tokens))))
+
+  (display "Checking major and minor version numbers against chicken-version... ")
+  ;; Those fudges are mapped to C_MAJOR_VERSION and C_MINOR_VERSION
+  (assert (= (##sys#fudge 41) major))
+  (assert (= (##sys#fudge 43) minor))
+  (print "ok")
+
+  (display "Checking the registered feature chicken-<major>.<minor>... ")
+  (let loop ((features (features)))
+    (if (null? features)
+        (error "Could not find feature chicken-<major>.<minor>")
+        (let ((feature (symbol->string (car features))))
+          (cond ((irregex-match "chicken-(\\d+)\\.(\\d+)" feature)
+                 => (lambda (match)
+                      (assert (= (string->number
+                                  (irregex-match-substring match 1))
+                                 major))
+                      (assert (= (string->number
+                                  (irregex-match-substring match 2))
+                                 minor))))
+                (else (loop (cdr features)))))))
+  (print "ok"))
Trap