mike121 pushed a commit to branch wip-mingw-2025
in repository guile.

commit 68af1c93e798dfb7a260929a8511695d9e7ac01c
Author: Michael Gran <spk...@yahoo.com>
AuthorDate: Tue Jul 4 17:58:47 2023 -0700

    In i18n test, add more reasonable test passes for french currency
    
    * test-suite/tests/i18n.test ("french utf-8: number" "fraction"):
      ("positive inexact zero", "one cent", "very little money"): more
        success and failure conditions
---
 test-suite/tests/i18n.test | 108 ++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 96 insertions(+), 12 deletions(-)

diff --git a/test-suite/tests/i18n.test b/test-suite/tests/i18n.test
index e6da0863f..5c9f67af8 100644
--- a/test-suite/tests/i18n.test
+++ b/test-suite/tests/i18n.test
@@ -717,36 +717,120 @@
        (lambda ()
          (let* ((fr  (make-locale LC_ALL %french-locale-name))
                 (str (string-trim-both (monetary-amount->locale-string 123456 
#f fr))))
-           ;; Check for both NO-BREAK SPACE and SPACE.
-           (or (string=? "123 456,00 +EUR" str)
-               (string=? "123 456,00 +EUR" str))))))
+           ;; Check for
+           ;; - U+20 SPACE
+           ;; - U+00A0 NO-BREAK SPACE
+           ;; - U+202F NARROW NO BREAK SPACE
+           (or (string=? "123 456,00 +€" str)
+               (string=? "123\xA0456,00 +€" str)
+               (string=? "123\u202F456,00 +€" str)
+               (string=? "123\u202F456,00 €" str))))))
 
     (pass-if "fraction"
       (under-french-locale-or-unresolved
        (lambda ()
          (let* ((fr  (make-locale LC_ALL %french-locale-name))
                 (str (monetary-amount->locale-string 1234.567 #t fr)))
-           ;; Check for both NO-BREAK SPACE and SPACE.
+           (when (locale-currency-symbol-precedes-positive? #t fr)
+             ;; Locales that put EUR first are erroneous.
+             (throw 'unresolved))
+           ;; Check for
+           ;; - U+20 SPACE
+           ;; - U+00A0 NO-BREAK SPACE
+           ;; - U+202F NARROW NO BREAK SPACE
            (or (string=? "1 234,57 EUR " str)
                (string=? "1 234,57 EUR " str))))))
 
-    (pass-if-equal "positive inexact zero"
-        "0,00 +EUR"
-      (under-french-locale-or-unresolved
+    (pass-if "positive inexact zero"
+      (under-french-utf8-locale-or-unresolved
        (lambda ()
-         (let ((fr (make-locale LC_ALL %french-locale-name)))
-           (string-trim-both (monetary-amount->locale-string 0. #f fr))))))
+         (let* ((fr (make-locale LC_ALL %french-utf8-locale-name))
+                (str (string-trim-both (monetary-amount->locale-string 0. #f 
fr))))
+           (or (string=? "0,00 +€" str)
+               (string=? "0,00 €" str))))))
+
 
     (pass-if-equal "one cent"
         "0,01 EUR "
       (under-french-locale-or-unresolved
        (lambda ()
-         (let ((fr (make-locale LC_ALL %french-locale-name)))
+         (let ((fr (make-locale LC_ALL %french-utf8-locale-name)))
+           (when (locale-currency-symbol-precedes-positive? #t fr)
+             ;; Locales that put EUR first are erroneous.
+             (throw 'unresolved))
            (monetary-amount->locale-string .01 #t fr)))))
 
     (pass-if-equal "very little money"
         "0,00 EUR "
       (under-french-locale-or-unresolved
        (lambda ()
-         (let ((fr (make-locale LC_ALL %french-locale-name)))
-           (monetary-amount->locale-string .00003 #t fr)))))))
+         (let ((fr (make-locale LC_ALL %french-utf8-locale-name)))
+           (when (locale-currency-symbol-precedes-positive? #t fr)
+             ;; Locales that put EUR first are erroneous.
+             (throw 'unresolved))
+           (monetary-amount->locale-string .00003 #t fr))))))
+
+    (with-test-prefix "French 8-bit"
+
+      (pass-if "integer"
+        (under-french-locale-or-unresolved
+         (lambda ()
+           (let* ((fr  (make-locale LC_ALL %french-locale-name))
+                  (str (monetary-amount->locale-string 123456 #f fr)))
+             (when (locale-currency-symbol-precedes-positive? #t fr)
+               ;; Locales that put EUR first are erroneous.
+               (throw 'unresolved))
+             ;; Check for
+             ;; - no space
+             ;; - U+20 SPACE
+             ;; - U+00A0 NO-BREAK SPACE
+             (or (string=? "123456,00 +EUR " str)
+                 (string=? "123 456,00 +EUR " str)
+                 (string=? "123\xA0456,00 +EUR " str))))))
+
+      (pass-if "fraction"
+        (under-french-locale-or-unresolved
+         (lambda ()
+           (let* ((fr  (make-locale LC_ALL %french-locale-name))
+                  (str (monetary-amount->locale-string 1234.567 #t fr)))
+             (when (locale-currency-symbol-precedes-positive? #t fr)
+               ;; Locales that put EUR first are erroneous.
+               (throw 'unresolved))
+             ;; Check for
+             ;; - no space
+             ;; - U+20 SPACE
+             ;; - U+00A0 NO-BREAK SPACE
+             (or (string=? "1234,57 EUR " str)
+                 (string=? "1 234,57 EUR " str)
+                 (string=? "1\xA0234,57 EUR " str))))))
+
+      (pass-if "positive inexact zero"
+        (under-french-locale-or-unresolved
+         (lambda ()
+           (let* ((fr (make-locale LC_ALL %french-locale-name))
+                  (str (monetary-amount->locale-string 0. #f fr)))
+             (or (string=? "0,00 +EUR " str)
+                 (string=? "0,00 €" str)  ; Possible when CP1252 or ISO-8859-15
+                 )))))
+
+      (pass-if-equal "one cent"
+          "0,01 EUR "
+        (under-french-locale-or-unresolved
+         (lambda ()
+           (let* ((fr (make-locale LC_ALL %french-locale-name))
+                  (str (monetary-amount->locale-string .01 #t fr)))
+             (when (locale-currency-symbol-precedes-positive? #t fr)
+               ;; Locales that put EUR first are erroneous.
+               (throw 'unresolved))
+             str))))
+
+      (pass-if-equal "very little money"
+          "0,00 EUR "
+        (under-french-locale-or-unresolved
+         (lambda ()
+           (let* ((fr (make-locale LC_ALL %french-locale-name))
+                  (str (monetary-amount->locale-string .00003 #t fr)))
+             (when (locale-currency-symbol-precedes-positive? #t fr)
+               ;; Locales that put EUR first are erroneous.
+               (throw 'unresolved))
+             str))))))

Reply via email to