diff options
| author | Noam Postavsky | 2017-07-08 14:32:07 -0400 |
|---|---|---|
| committer | Noam Postavsky | 2017-07-08 14:32:07 -0400 |
| commit | 05c5e4d8181ee5274885da4ed520bb9874491aab (patch) | |
| tree | f4a20bbb987425b899943e8016e3cbfd9e62ddc4 /test | |
| parent | efaf14859ae984f17731a7471fcb9acd84f7babb (diff) | |
| parent | 06ff34cd2a86bde6ecc0baa613550bd7ed96f411 (diff) | |
| download | emacs-05c5e4d8181ee5274885da4ed520bb9874491aab.tar.gz emacs-05c5e4d8181ee5274885da4ed520bb9874491aab.zip | |
; Merge: Update and optimize UCS normalization tests
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/international/ucs-normalize-tests.el | 247 |
1 files changed, 153 insertions, 94 deletions
diff --git a/test/lisp/international/ucs-normalize-tests.el b/test/lisp/international/ucs-normalize-tests.el index d85efe2d7bf..02a4bba7a5f 100644 --- a/test/lisp/international/ucs-normalize-tests.el +++ b/test/lisp/international/ucs-normalize-tests.el | |||
| @@ -26,15 +26,13 @@ | |||
| 26 | ;; If there are lines marked as failing (see | 26 | ;; If there are lines marked as failing (see |
| 27 | ;; `ucs-normalize-tests--failing-lines-part1' and | 27 | ;; `ucs-normalize-tests--failing-lines-part1' and |
| 28 | ;; `ucs-normalize-tests--failing-lines-part2'), they may need to be | 28 | ;; `ucs-normalize-tests--failing-lines-part2'), they may need to be |
| 29 | ;; adjusted when NormalizationTest.txt is updated. To get a list of | 29 | ;; adjusted when NormalizationTest.txt is updated. Run the function |
| 30 | ;; currently failing lines, set those 2 variables to nil, run the | 30 | ;; `ucs-normalize-check-failing-lines' to see what changes are needed. |
| 31 | ;; tests, and inspect the values of | ||
| 32 | ;; `ucs-normalize-tests--part1-rule1-failed-lines' and | ||
| 33 | ;; `ucs-normalize-tests--part1-rule2-failed-chars', respectively. | ||
| 34 | 31 | ||
| 35 | ;;; Code: | 32 | ;;; Code: |
| 36 | 33 | ||
| 37 | (eval-when-compile (require 'cl-lib)) | 34 | (eval-when-compile (require 'cl-lib)) |
| 35 | (require 'seq) | ||
| 38 | (require 'ert) | 36 | (require 'ert) |
| 39 | (require 'ucs-normalize) | 37 | (require 'ucs-normalize) |
| 40 | 38 | ||
| @@ -44,83 +42,98 @@ | |||
| 44 | (defun ucs-normalize-tests--parse-column () | 42 | (defun ucs-normalize-tests--parse-column () |
| 45 | (let ((chars nil) | 43 | (let ((chars nil) |
| 46 | (term nil)) | 44 | (term nil)) |
| 47 | (while (and (not (equal term ";")) | 45 | (while (and (not (eq term ?\;)) |
| 48 | (looking-at "\\([[:xdigit:]]\\{4,6\\}\\)\\([; ]\\)")) | 46 | (looking-at "\\([[:xdigit:]]\\{4,6\\}\\)\\([; ]\\)")) |
| 49 | (let ((code-point (match-string 1))) | 47 | (let ((code-point (match-string-no-properties 1))) |
| 50 | (setq term (match-string 2)) | 48 | (setq term (char-after (match-beginning 2))) |
| 51 | (goto-char (match-end 0)) | 49 | (goto-char (match-end 0)) |
| 52 | (push (string-to-number code-point 16) chars))) | 50 | (push (string-to-number code-point 16) chars))) |
| 53 | (nreverse chars))) | 51 | (apply #'string (nreverse chars)))) |
| 54 | 52 | ||
| 55 | (defmacro ucs-normalize-tests--normalize (norm str) | 53 | (defconst ucs-normalize-tests--norm-buf (generate-new-buffer " *ucs-normalizing-buffer*")) |
| 54 | |||
| 55 | (defmacro ucs-normalize-tests--normalization-equal-p (norm str equal-to) | ||
| 56 | "Like `ucs-normalize-string' but reuse current buffer for efficiency. | 56 | "Like `ucs-normalize-string' but reuse current buffer for efficiency. |
| 57 | And NORM is one of the symbols `NFC', `NFD', `NFKC', `NFKD' for brevity." | 57 | And NORM is one of the symbols `NFC', `NFD', `NFKC', `NFKD' for brevity." |
| 58 | (let ((norm-alist '((NFC . ucs-normalize-NFC-region) | 58 | (let ((norm-alist '((NFC . ucs-normalize-NFC-region) |
| 59 | (NFD . ucs-normalize-NFD-region) | 59 | (NFD . ucs-normalize-NFD-region) |
| 60 | (NFKC . ucs-normalize-NFKC-region) | 60 | (NFKC . ucs-normalize-NFKC-region) |
| 61 | (NFKD . ucs-normalize-NFKD-region)))) | 61 | (NFKD . ucs-normalize-NFKD-region)))) |
| 62 | `(save-restriction | 62 | `(with-current-buffer ucs-normalize-tests--norm-buf |
| 63 | (narrow-to-region (point) (point)) | 63 | (erase-buffer) |
| 64 | (insert ,str) | 64 | (insert ,str) |
| 65 | (funcall #',(cdr (assq norm norm-alist)) (point-min) (point-max)) | 65 | (,(cdr (assq norm norm-alist)) (point-min) (point-max)) |
| 66 | (delete-and-extract-region (point-min) (point-max))))) | 66 | (goto-char (point-min)) |
| 67 | (insert ,equal-to) | ||
| 68 | (eq (compare-buffer-substrings nil nil (point) nil (point) nil) 0)))) | ||
| 69 | |||
| 70 | (defmacro ucs-normalize-tests--normalization-chareq-p (norm char char-eq-to) | ||
| 71 | "Like `ucs-normalize-string' but reuse current buffer for efficiency. | ||
| 72 | And NORM is one of the symbols `NFC', `NFD', `NFKC', `NFKD' for brevity." | ||
| 73 | (let ((norm-alist '((NFC . ucs-normalize-NFC-region) | ||
| 74 | (NFD . ucs-normalize-NFD-region) | ||
| 75 | (NFKC . ucs-normalize-NFKC-region) | ||
| 76 | (NFKD . ucs-normalize-NFKD-region)))) | ||
| 77 | `(with-current-buffer ucs-normalize-tests--norm-buf | ||
| 78 | (erase-buffer) | ||
| 79 | (insert ,char) | ||
| 80 | (,(cdr (assq norm norm-alist)) (point-min) (point-max)) | ||
| 81 | (and (eq (buffer-size) 1) | ||
| 82 | (eq (char-after (point-min)) ,char-eq-to))))) | ||
| 67 | 83 | ||
| 68 | (defvar ucs-normalize-tests--chars-part1 nil) | 84 | (defvar ucs-normalize-tests--chars-part1 nil) |
| 69 | 85 | ||
| 70 | (defun ucs-normalize-tests--invariants-hold-p (&rest columns) | 86 | (defsubst ucs-normalize-tests--rule1-holds-p (source nfc nfd nfkc nfkd) |
| 71 | "Check 1st conformance rule. | 87 | "Check 1st conformance rule. |
| 72 | The following invariants must be true for all conformant implementations..." | 88 | The following invariants must be true for all conformant implementations..." |
| 73 | (when ucs-normalize-tests--chars-part1 | 89 | (when ucs-normalize-tests--chars-part1 |
| 74 | ;; See `ucs-normalize-tests--invariants-rule2-hold-p'. | 90 | ;; See `ucs-normalize-tests--rule2-holds-p'. |
| 75 | (aset ucs-normalize-tests--chars-part1 | 91 | (aset ucs-normalize-tests--chars-part1 |
| 76 | (caar columns) 1)) | 92 | (aref source 0) 1)) |
| 77 | (cl-destructuring-bind (source nfc nfd nfkc nfkd) | 93 | (and |
| 78 | (mapcar (lambda (c) (apply #'string c)) columns) | 94 | ;; c2 == toNFC(c1) == toNFC(c2) == toNFC(c3) |
| 79 | (and | 95 | (ucs-normalize-tests--normalization-equal-p NFC source nfc) |
| 80 | ;; c2 == toNFC(c1) == toNFC(c2) == toNFC(c3) | 96 | (ucs-normalize-tests--normalization-equal-p NFC nfc nfc) |
| 81 | (equal nfc (ucs-normalize-tests--normalize NFC source)) | 97 | (ucs-normalize-tests--normalization-equal-p NFC nfd nfc) |
| 82 | (equal nfc (ucs-normalize-tests--normalize NFC nfc)) | 98 | ;; c4 == toNFC(c4) == toNFC(c5) |
| 83 | (equal nfc (ucs-normalize-tests--normalize NFC nfd)) | 99 | (ucs-normalize-tests--normalization-equal-p NFC nfkc nfkc) |
| 84 | ;; c4 == toNFC(c4) == toNFC(c5) | 100 | (ucs-normalize-tests--normalization-equal-p NFC nfkd nfkc) |
| 85 | (equal nfkc (ucs-normalize-tests--normalize NFC nfkc)) | 101 | |
| 86 | (equal nfkc (ucs-normalize-tests--normalize NFC nfkd)) | 102 | ;; c3 == toNFD(c1) == toNFD(c2) == toNFD(c3) |
| 87 | 103 | (ucs-normalize-tests--normalization-equal-p NFD source nfd) | |
| 88 | ;; c3 == toNFD(c1) == toNFD(c2) == toNFD(c3) | 104 | (ucs-normalize-tests--normalization-equal-p NFD nfc nfd) |
| 89 | (equal nfd (ucs-normalize-tests--normalize NFD source)) | 105 | (ucs-normalize-tests--normalization-equal-p NFD nfd nfd) |
| 90 | (equal nfd (ucs-normalize-tests--normalize NFD nfc)) | 106 | ;; c5 == toNFD(c4) == toNFD(c5) |
| 91 | (equal nfd (ucs-normalize-tests--normalize NFD nfd)) | 107 | (ucs-normalize-tests--normalization-equal-p NFD nfkc nfkd) |
| 92 | ;; c5 == toNFD(c4) == toNFD(c5) | 108 | (ucs-normalize-tests--normalization-equal-p NFD nfkd nfkd) |
| 93 | (equal nfkd (ucs-normalize-tests--normalize NFD nfkc)) | 109 | |
| 94 | (equal nfkd (ucs-normalize-tests--normalize NFD nfkd)) | 110 | ;; c4 == toNFKC(c1) == toNFKC(c2) == toNFKC(c3) == toNFKC(c4) == toNFKC(c5) |
| 95 | 111 | (ucs-normalize-tests--normalization-equal-p NFKC source nfkc) | |
| 96 | ;; c4 == toNFKC(c1) == toNFKC(c2) == toNFKC(c3) == toNFKC(c4) == toNFKC(c5) | 112 | (ucs-normalize-tests--normalization-equal-p NFKC nfc nfkc) |
| 97 | (equal nfkc (ucs-normalize-tests--normalize NFKC source)) | 113 | (ucs-normalize-tests--normalization-equal-p NFKC nfd nfkc) |
| 98 | (equal nfkc (ucs-normalize-tests--normalize NFKC nfc)) | 114 | (ucs-normalize-tests--normalization-equal-p NFKC nfkc nfkc) |
| 99 | (equal nfkc (ucs-normalize-tests--normalize NFKC nfd)) | 115 | (ucs-normalize-tests--normalization-equal-p NFKC nfkd nfkc) |
| 100 | (equal nfkc (ucs-normalize-tests--normalize NFKC nfkc)) | 116 | |
| 101 | (equal nfkc (ucs-normalize-tests--normalize NFKC nfkd)) | 117 | ;; c5 == toNFKD(c1) == toNFKD(c2) == toNFKD(c3) == toNFKD(c4) == toNFKD(c5) |
| 102 | 118 | (ucs-normalize-tests--normalization-equal-p NFKD source nfkd) | |
| 103 | ;; c5 == toNFKD(c1) == toNFKD(c2) == toNFKD(c3) == toNFKD(c4) == toNFKD(c5) | 119 | (ucs-normalize-tests--normalization-equal-p NFKD nfc nfkd) |
| 104 | (equal nfkd (ucs-normalize-tests--normalize NFKD source)) | 120 | (ucs-normalize-tests--normalization-equal-p NFKD nfd nfkd) |
| 105 | (equal nfkd (ucs-normalize-tests--normalize NFKD nfc)) | 121 | (ucs-normalize-tests--normalization-equal-p NFKD nfkc nfkd) |
| 106 | (equal nfkd (ucs-normalize-tests--normalize NFKD nfd)) | 122 | (ucs-normalize-tests--normalization-equal-p NFKD nfkd nfkd))) |
| 107 | (equal nfkd (ucs-normalize-tests--normalize NFKD nfkc)) | 123 | |
| 108 | (equal nfkd (ucs-normalize-tests--normalize NFKD nfkd))))) | 124 | (defsubst ucs-normalize-tests--rule2-holds-p (X) |
| 109 | |||
| 110 | (defun ucs-normalize-tests--invariants-rule2-hold-p (char) | ||
| 111 | "Check 2nd conformance rule. | 125 | "Check 2nd conformance rule. |
| 112 | For every code point X assigned in this version of Unicode that is not specifically | 126 | For every code point X assigned in this version of Unicode that is not specifically |
| 113 | listed in Part 1, the following invariants must be true for all conformant | 127 | listed in Part 1, the following invariants must be true for all conformant |
| 114 | implementations: | 128 | implementations: |
| 115 | 129 | ||
| 116 | X == toNFC(X) == toNFD(X) == toNFKC(X) == toNFKD(X)" | 130 | X == toNFC(X) == toNFD(X) == toNFKC(X) == toNFKD(X)" |
| 117 | (let ((X (string char))) | 131 | (and (ucs-normalize-tests--normalization-chareq-p NFC X X) |
| 118 | (and (equal X (ucs-normalize-tests--normalize NFC X)) | 132 | (ucs-normalize-tests--normalization-chareq-p NFD X X) |
| 119 | (equal X (ucs-normalize-tests--normalize NFD X)) | 133 | (ucs-normalize-tests--normalization-chareq-p NFKC X X) |
| 120 | (equal X (ucs-normalize-tests--normalize NFKC X)) | 134 | (ucs-normalize-tests--normalization-chareq-p NFKD X X))) |
| 121 | (equal X (ucs-normalize-tests--normalize NFKD X))))) | ||
| 122 | 135 | ||
| 123 | (cl-defun ucs-normalize-tests--invariants-failing-for-part (part &optional skip-lines &key progress-str) | 136 | (cl-defun ucs-normalize-tests--rule1-failing-for-partX (part &optional skip-lines &key progress-str) |
| 124 | "Returns a list of failed line numbers." | 137 | "Returns a list of failed line numbers." |
| 125 | (with-temp-buffer | 138 | (with-temp-buffer |
| 126 | (insert-file-contents ucs-normalize-test-data-file) | 139 | (insert-file-contents ucs-normalize-test-data-file) |
| @@ -136,8 +149,8 @@ implementations: | |||
| 136 | progress-str beg-line end-line | 149 | progress-str beg-line end-line |
| 137 | 0 nil 0.5)) | 150 | 0 nil 0.5)) |
| 138 | for line from beg-line to (1- end-line) | 151 | for line from beg-line to (1- end-line) |
| 139 | unless (or (= (following-char) ?#) | 152 | unless (or (eq (following-char) ?#) |
| 140 | (ucs-normalize-tests--invariants-hold-p | 153 | (ucs-normalize-tests--rule1-holds-p |
| 141 | (ucs-normalize-tests--parse-column) | 154 | (ucs-normalize-tests--parse-column) |
| 142 | (ucs-normalize-tests--parse-column) | 155 | (ucs-normalize-tests--parse-column) |
| 143 | (ucs-normalize-tests--parse-column) | 156 | (ucs-normalize-tests--parse-column) |
| @@ -148,7 +161,7 @@ implementations: | |||
| 148 | do (forward-line) | 161 | do (forward-line) |
| 149 | if reporter do (progress-reporter-update reporter line))))) | 162 | if reporter do (progress-reporter-update reporter line))))) |
| 150 | 163 | ||
| 151 | (defun ucs-normalize-tests--invariants-failing-for-lines (lines) | 164 | (defun ucs-normalize-tests--rule1-failing-for-lines (lines) |
| 152 | "Returns a list of failed line numbers." | 165 | "Returns a list of failed line numbers." |
| 153 | (with-temp-buffer | 166 | (with-temp-buffer |
| 154 | (insert-file-contents ucs-normalize-test-data-file) | 167 | (insert-file-contents ucs-normalize-test-data-file) |
| @@ -156,7 +169,7 @@ implementations: | |||
| 156 | (cl-loop for prev-line = 1 then line | 169 | (cl-loop for prev-line = 1 then line |
| 157 | for line in lines | 170 | for line in lines |
| 158 | do (forward-line (- line prev-line)) | 171 | do (forward-line (- line prev-line)) |
| 159 | unless (ucs-normalize-tests--invariants-hold-p | 172 | unless (ucs-normalize-tests--rule1-holds-p |
| 160 | (ucs-normalize-tests--parse-column) | 173 | (ucs-normalize-tests--parse-column) |
| 161 | (ucs-normalize-tests--parse-column) | 174 | (ucs-normalize-tests--parse-column) |
| 162 | (ucs-normalize-tests--parse-column) | 175 | (ucs-normalize-tests--parse-column) |
| @@ -165,7 +178,7 @@ implementations: | |||
| 165 | collect line))) | 178 | collect line))) |
| 166 | 179 | ||
| 167 | (ert-deftest ucs-normalize-part0 () | 180 | (ert-deftest ucs-normalize-part0 () |
| 168 | (should-not (ucs-normalize-tests--invariants-failing-for-part 0))) | 181 | (should-not (ucs-normalize-tests--rule1-failing-for-partX 0))) |
| 169 | 182 | ||
| 170 | (defconst ucs-normalize-tests--failing-lines-part1 | 183 | (defconst ucs-normalize-tests--failing-lines-part1 |
| 171 | (list 15131 15132 15133 15134 15135 15136 15137 15138 | 184 | (list 15131 15132 15133 15134 15135 15136 15137 15138 |
| @@ -195,6 +208,8 @@ implementations: | |||
| 195 | "A list of line numbers.") | 208 | "A list of line numbers.") |
| 196 | (defvar ucs-normalize-tests--part1-rule2-failed-chars nil | 209 | (defvar ucs-normalize-tests--part1-rule2-failed-chars nil |
| 197 | "A list of code points.") | 210 | "A list of code points.") |
| 211 | (defvar ucs-normalize-tests--part2-rule1-failed-lines nil | ||
| 212 | "A list of line numbers.") | ||
| 198 | 213 | ||
| 199 | (defun ucs-normalize-tests--part1-rule2 (chars-part1) | 214 | (defun ucs-normalize-tests--part1-rule2 (chars-part1) |
| 200 | (let ((reporter (make-progress-reporter "UCS Normalize Test Part1, rule 2" | 215 | (let ((reporter (make-progress-reporter "UCS Normalize Test Part1, rule 2" |
| @@ -204,11 +219,11 @@ implementations: | |||
| 204 | (lambda (char-range listed-in-part) | 219 | (lambda (char-range listed-in-part) |
| 205 | (unless (eq listed-in-part 1) | 220 | (unless (eq listed-in-part 1) |
| 206 | (if (characterp char-range) | 221 | (if (characterp char-range) |
| 207 | (progn (unless (ucs-normalize-tests--invariants-rule2-hold-p char-range) | 222 | (progn (unless (ucs-normalize-tests--rule2-holds-p char-range) |
| 208 | (push char-range failed-chars)) | 223 | (push char-range failed-chars)) |
| 209 | (progress-reporter-update reporter char-range)) | 224 | (progress-reporter-update reporter char-range)) |
| 210 | (cl-loop for char from (car char-range) to (cdr char-range) | 225 | (cl-loop for char from (car char-range) to (cdr char-range) |
| 211 | unless (ucs-normalize-tests--invariants-rule2-hold-p char) | 226 | unless (ucs-normalize-tests--rule2-holds-p char) |
| 212 | do (push char failed-chars) | 227 | do (push char failed-chars) |
| 213 | do (progress-reporter-update reporter char))))) | 228 | do (progress-reporter-update reporter char))))) |
| 214 | chars-part1) | 229 | chars-part1) |
| @@ -219,59 +234,103 @@ implementations: | |||
| 219 | :tags '(:expensive-test) | 234 | :tags '(:expensive-test) |
| 220 | ;; This takes a long time, so make sure we're compiled. | 235 | ;; This takes a long time, so make sure we're compiled. |
| 221 | (dolist (fun '(ucs-normalize-tests--part1-rule2 | 236 | (dolist (fun '(ucs-normalize-tests--part1-rule2 |
| 222 | ucs-normalize-tests--invariants-failing-for-part | 237 | ucs-normalize-tests--rule1-failing-for-partX |
| 223 | ucs-normalize-tests--invariants-hold-p | 238 | ucs-normalize-tests--rule1-holds-p |
| 224 | ucs-normalize-tests--invariants-rule2-hold-p)) | 239 | ucs-normalize-tests--rule2-holds-p)) |
| 225 | (or (byte-code-function-p (symbol-function fun)) | 240 | (or (byte-code-function-p (symbol-function fun)) |
| 226 | (byte-compile fun))) | 241 | (byte-compile fun))) |
| 227 | (let ((ucs-normalize-tests--chars-part1 (make-char-table 'ucs-normalize-tests t))) | 242 | (let ((ucs-normalize-tests--chars-part1 (make-char-table 'ucs-normalize-tests t))) |
| 228 | (should-not | 243 | (setq ucs-normalize-tests--part1-rule1-failed-lines |
| 229 | (setq ucs-normalize-tests--part1-rule1-failed-lines | 244 | (ucs-normalize-tests--rule1-failing-for-partX |
| 230 | (ucs-normalize-tests--invariants-failing-for-part | 245 | 1 ucs-normalize-tests--failing-lines-part1 |
| 231 | 1 ucs-normalize-tests--failing-lines-part1 | 246 | :progress-str "UCS Normalize Test Part1, rule 1")) |
| 232 | :progress-str "UCS Normalize Test Part1, rule 1"))) | 247 | (setq ucs-normalize-tests--part1-rule2-failed-chars |
| 233 | (should-not (setq ucs-normalize-tests--part1-rule2-failed-chars | 248 | (ucs-normalize-tests--part1-rule2 |
| 234 | (ucs-normalize-tests--part1-rule2 | 249 | ucs-normalize-tests--chars-part1)) |
| 235 | ucs-normalize-tests--chars-part1))))) | 250 | (should-not ucs-normalize-tests--part1-rule1-failed-lines) |
| 251 | (should-not ucs-normalize-tests--part1-rule2-failed-chars))) | ||
| 236 | 252 | ||
| 237 | (ert-deftest ucs-normalize-part1-failing () | 253 | (ert-deftest ucs-normalize-part1-failing () |
| 238 | :expected-result :failed | 254 | :expected-result :failed |
| 239 | (skip-unless ucs-normalize-tests--failing-lines-part1) | 255 | (skip-unless ucs-normalize-tests--failing-lines-part1) |
| 240 | (should-not | 256 | (should-not |
| 241 | (ucs-normalize-tests--invariants-failing-for-lines | 257 | (ucs-normalize-tests--rule1-failing-for-lines |
| 242 | ucs-normalize-tests--failing-lines-part1))) | 258 | ucs-normalize-tests--failing-lines-part1))) |
| 243 | 259 | ||
| 244 | (defconst ucs-normalize-tests--failing-lines-part2 | 260 | (defconst ucs-normalize-tests--failing-lines-part2 |
| 245 | (list 18328 18330 18332 18334 18336 18338 18340 18342 | 261 | (list 17656 17658 18006 18007 18008 18009 18010 18011 |
| 246 | 18344 18346 18348 18350 18352 18354 18356 18358 | 262 | 18012 18340 18342 18344 18346 18348 18350 18352 |
| 247 | 18360 18362 18364 18366 18368 18370 18372 18374 | 263 | 18354 18356 18358 18360 18362 18364 18366 18368 |
| 248 | 18376 18378 18380 18382 18384 18386 18388 18390 | 264 | 18370 18372 18374 18376 18378 18380 18382 18384 |
| 249 | 18392 18394 18396 18398 18400 18402 18404 18406 | 265 | 18386 18388 18390 18392 18394 18396 18398 18400 |
| 250 | 18408 18410 18412 18414 18416 18418 18420 18422 | 266 | 18402 18404 18406 18408 18410 18412 18414 18416 |
| 251 | 18424 18426 18494 18496 18498 18500 18502 18504 | 267 | 18418 18420 18422 18424 18426 18428 18430 18432 |
| 252 | 18506 18508 18510 18512 18514 18516 18518 18520 | 268 | 18434 18436 18438 18440 18442 18444 18446 18448 |
| 253 | 18522 18524 18526 18528 18530 18532 18534 18536 | 269 | 18450 18518 18520 18522 18524 18526 18528 18530 |
| 254 | 18538 18540 18542 18544 18546 18548 18550 18552 | 270 | 18532 18534 18536 18538 18540 18542 18544 18546 |
| 255 | 18554 18556 18558 18560 18562 18564 18566 18568 | 271 | 18548 18550 18552 18554 18556 18558 18560 18562 |
| 256 | 18570 18572 18574 18576 18578 18580 18582 18584 | 272 | 18564 18566 18568 18570 18572 18574 18576 18578 |
| 257 | 18586 18588 18590 18592 18594 18596)) | 273 | 18580 18582 18584 18586 18588 18590 18592 18594 |
| 274 | 18596 18598 18600 18602 18604 18606 18608 18610 | ||
| 275 | 18612 18614 18616 18618 18620)) | ||
| 258 | 276 | ||
| 259 | (ert-deftest ucs-normalize-part2 () | 277 | (ert-deftest ucs-normalize-part2 () |
| 260 | :tags '(:expensive-test) | 278 | :tags '(:expensive-test) |
| 261 | (should-not | 279 | (should-not |
| 262 | (ucs-normalize-tests--invariants-failing-for-part | 280 | (setq ucs-normalize-tests--part2-rule1-failed-lines |
| 263 | 2 ucs-normalize-tests--failing-lines-part2 | 281 | (ucs-normalize-tests--rule1-failing-for-partX |
| 264 | :progress-str "UCS Normalize Test Part2"))) | 282 | 2 ucs-normalize-tests--failing-lines-part2 |
| 283 | :progress-str "UCS Normalize Test Part2")))) | ||
| 265 | 284 | ||
| 266 | (ert-deftest ucs-normalize-part2-failing () | 285 | (ert-deftest ucs-normalize-part2-failing () |
| 267 | :expected-result :failed | 286 | :expected-result :failed |
| 268 | (skip-unless ucs-normalize-tests--failing-lines-part2) | 287 | (skip-unless ucs-normalize-tests--failing-lines-part2) |
| 269 | (should-not | 288 | (should-not |
| 270 | (ucs-normalize-tests--invariants-failing-for-lines | 289 | (ucs-normalize-tests--rule1-failing-for-lines |
| 271 | ucs-normalize-tests--failing-lines-part2))) | 290 | ucs-normalize-tests--failing-lines-part2))) |
| 272 | 291 | ||
| 273 | (ert-deftest ucs-normalize-part3 () | 292 | (ert-deftest ucs-normalize-part3 () |
| 274 | (should-not | 293 | (should-not |
| 275 | (ucs-normalize-tests--invariants-failing-for-part 3))) | 294 | (ucs-normalize-tests--rule1-failing-for-partX 3))) |
| 295 | |||
| 296 | (defun ucs-normalize-tests--insert-failing-lines (var newval) | ||
| 297 | (insert (format "`%s' should be updated to:\n | ||
| 298 | \(defconst %s | ||
| 299 | (list " var var)) | ||
| 300 | (dolist (linos (seq-partition newval 8)) | ||
| 301 | (insert (mapconcat #'number-to-string linos " ") "\n")) | ||
| 302 | (insert ")\)")) | ||
| 303 | |||
| 304 | (defun ucs-normalize-check-failing-lines () | ||
| 305 | (interactive) | ||
| 306 | (let ((ucs-normalize-tests--failing-lines-part1 nil) | ||
| 307 | (ucs-normalize-tests--failing-lines-part2 nil)) | ||
| 308 | (setq ucs-normalize-tests--part1-rule1-failed-lines nil) | ||
| 309 | (setq ucs-normalize-tests--part1-rule2-failed-chars nil) | ||
| 310 | (setq ucs-normalize-tests--part2-rule1-failed-lines nil) | ||
| 311 | (ert "\\`ucs-normalize")) | ||
| 312 | |||
| 313 | (with-current-buffer (get-buffer-create "*ucs normalize change bad lines*") | ||
| 314 | (erase-buffer) | ||
| 315 | (unless (equal ucs-normalize-tests--part1-rule1-failed-lines | ||
| 316 | ucs-normalize-tests--failing-lines-part1) | ||
| 317 | (ucs-normalize-tests--insert-failing-lines | ||
| 318 | 'ucs-normalize-tests--failing-lines-part1 | ||
| 319 | ucs-normalize-tests--part1-rule1-failed-lines)) | ||
| 320 | |||
| 321 | (when ucs-normalize-tests--part1-rule2-failed-chars | ||
| 322 | (insert (format "Some characters failed rule 2!\n\n%S" | ||
| 323 | `(list ,@ucs-normalize-tests--part1-rule2-failed-chars)))) | ||
| 324 | |||
| 325 | (unless (equal ucs-normalize-tests--part2-rule1-failed-lines | ||
| 326 | ucs-normalize-tests--failing-lines-part2) | ||
| 327 | (ucs-normalize-tests--insert-failing-lines | ||
| 328 | 'ucs-normalize-tests--failing-lines-part2 | ||
| 329 | ucs-normalize-tests--part2-rule1-failed-lines)) | ||
| 330 | (if (> (buffer-size) 0) | ||
| 331 | (if noninteractive | ||
| 332 | (princ (buffer-string) standard-output) | ||
| 333 | (display-buffer (current-buffer))) | ||
| 334 | (message "No changes to failing lines needed")))) | ||
| 276 | 335 | ||
| 277 | ;;; ucs-normalize-tests.el ends here | 336 | ;;; ucs-normalize-tests.el ends here |