;;;; srfi-29-test.scm (use test) (use srfi-29) (test-group "SRFI-29" (let ((bal1 '((foo1 . 1) ("bar1" . 2) (baz1 . 3))) (bal2 '((foo2 . 4) ("bar2" . 5) (baz2 . 6))) (bal3 '((foo3 . 7) ("bar3" . 8) (baz3 . 9))) ) (test-group "Locale" (test-assert "L1" (current-language)) (test-assert "L2" (current-country)) (test-assert "L3" (current-locale-details)) (test-assert "L4" (symbol? (current-language))) (test-assert "L5" (symbol? (current-country))) (test-assert "L6" (list? (current-locale-details))) (test-assert "L7" (current-language 'foo)) (test-assert "L8" (current-country 'bar)) (test-assert "L9" (current-locale-details '(baz))) (test "L10" 'foo (current-language)) (test "L11" 'bar (current-country)) (test "L12" '(baz) (current-locale-details)) (reset-locale-parameters) ) (test-group "Bundles" (test-assert "" (declare-bundle! '(srfi-29-test) bal1)) (test-assert "" (declare-bundle! '(srfi-29-test foo) bal2)) (test-assert "" (declare-bundle! '(srfi-29-test foo bar) bal3)) (test "declared-bundle-specifiers " '((srfi-29-test foo bar) (srfi-29-test foo) (srfi-29-test)) (declared-bundle-specifiers)) (test "declared-bundle-templates" bal1 (declared-bundle-templates '(srfi-29-test))) (test "declared-bundle-templates foo" bal2 (declared-bundle-templates '(srfi-29-test foo))) (test "declared-bundle-templates foo bar" bal3 (declared-bundle-templates '(srfi-29-test foo bar))) (test "" 1 (localized-template 'srfi-29-test 'foo1)) (test "" 2 (localized-template 'srfi-29-test "bar1")) (test "" 3 (localized-template 'srfi-29-test 'baz1)) (test-assert "" (undeclare-bundle! '(srfi-29-test))) (test-assert "" (undeclare-bundle! '(srfi-29-test foo))) (test-assert "" (undeclare-bundle! '(srfi-29-test foo bar))) (test-assert "" (not (localized-template 'srfi-29-test 'foo1))) (test-assert "" (not (localized-template 'srfi-29-test "bar1"))) (test-assert "" (not (localized-template 'srfi-29-test 'baz1))) ) (test-group "Bundles Alternate Directory" (define altdir ".") (test-assert "B1" (declare-bundle! '(srfi-29-test) bal1)) (test-assert "B2" (declare-bundle! '(srfi-29-test foo) bal2)) (test-assert "B3" (declare-bundle! '(srfi-29-test foo bar) bal3)) (test-assert "B7" (store-bundle! '(srfi-29-test) altdir)) (test-assert "B8" (store-bundle! '(srfi-29-test foo) altdir)) (test-assert "B9" (store-bundle! '(srfi-29-test foo bar) altdir)) (test-assert "B10" (remove-bundle! '(srfi-29-test) altdir)) (test-assert "B11" (remove-bundle! '(srfi-29-test foo) altdir)) (test-assert "B12" (remove-bundle! '(srfi-29-test foo bar) altdir)) (test-assert "B13" (not (load-bundle! '(srfi-29-test) altdir))) (test-assert "B14" (not (load-bundle! '(srfi-29-test foo) altdir))) (test-assert "B15" (not (load-bundle! '(srfi-29-test foo bar) altdir))) (test-assert "AltDir RmDir" (remove-bundle-directory! '(srfi-29-test foo bar) altdir)) ) (test-group "Bundles System Directory" (test-assert "B16" (declare-bundle! '(srfi-29-test) bal1)) (test-assert "B17" (declare-bundle! '(srfi-29-test foo) bal2)) (test-assert "B18" (declare-bundle! '(srfi-29-test foo bar) bal3)) (test-assert "B19" (store-bundle! '(srfi-29-test))) (test-assert "B20" (store-bundle! '(srfi-29-test foo))) (test-assert "B21" (store-bundle! '(srfi-29-test foo bar))) (test-assert "B22" (undeclare-bundle! '(srfi-29-test))) (test-assert "B23" (undeclare-bundle! '(srfi-29-test foo))) (test-assert "B24" (undeclare-bundle! '(srfi-29-test foo bar))) (test-assert "B25.1" (not (localized-template 'srfi-29-test 'foo1))) (test-assert "B26.1" (not (localized-template 'srfi-29-test "bar1"))) (test-assert "B27.1" (not (localized-template 'srfi-29-test 'baz1))) (test-assert "B22.1" (load-bundle! '(srfi-29-test))) (test-assert "B23.1" (load-bundle! '(srfi-29-test foo))) (test-assert "B24.1" (load-bundle! '(srfi-29-test foo bar))) (test "B25" 1 (localized-template 'srfi-29-test 'foo1)) (test "B26" 2 (localized-template 'srfi-29-test "bar1")) (test "B27" 3 (localized-template 'srfi-29-test 'baz1)) (test "localized-templates" bal1 (localized-templates 'srfi-29-test)) (current-language 'foo) (test "B28" 4 (localized-template 'srfi-29-test 'foo2)) (test "B29" 5 (localized-template 'srfi-29-test "bar2")) (test "B30" 6 (localized-template 'srfi-29-test 'baz2)) (test "localized-templates language foo" bal2 (localized-templates 'srfi-29-test)) (current-country 'bar) (test "B31" 7 (localized-template 'srfi-29-test 'foo3)) (test "B32" 8 (localized-template 'srfi-29-test "bar3")) (test "B33" 9 (localized-template 'srfi-29-test 'baz3)) (test "localized-templates language foo, country bar" bal3 (localized-templates 'srfi-29-test)) (test-assert "B37.1" (localized-template-set! 'srfi-29-test 'baz3 'foobar)) (test "B37.2" 'foobar (localized-template 'srfi-29-test 'baz3)) (test-assert "B37.3" (not (localized-template-set! 'foobar 'baz3 #t))) (test-assert "B37.4" (localized-template-set! 'srfi-29-test 'barf 16)) (test "B37.5" 16 (localized-template 'srfi-29-test 'barf)) (test-assert "B34" (remove-bundle! '(srfi-29-test))) (test-assert "B35" (remove-bundle! '(srfi-29-test foo))) (test-assert "B36" (remove-bundle! '(srfi-29-test foo bar))) (test-assert "SysDir RmDir" (remove-bundle-directory! '(srfi-29-test foo bar))) (reset-locale-parameters) ) ) #;(test-assert "B22.2" (load-best-available-bundle! (most-specific-bundle-specifier 'srfi-19))) #;(test "B22.3 English" "August" (localized-template 'srfi-19 'august)) #;(test "B22.4 English" "December" (localized-template 'srfi-19 'december)) )