comparison tests/automated/syntax-tests.el @ 4855:189fb67ca31a

Create Assert-eq, Assert-equal, etc. These are equivalent to (Assert (eq ...)) but display both the actual value and the expected value of the comparison. Use them throughout the test suite.
author Ben Wing <ben@xemacs.org>
date Thu, 14 Jan 2010 02:18:03 -0600
parents 5e526366d533
children 133e816778ed
comparison
equal deleted inserted replaced
4854:95c4ced5c07c 4855:189fb67ca31a
47 (goto-char (point-max)) 47 (goto-char (point-max))
48 (let ((point (point))) 48 (let ((point (point)))
49 (insert string) 49 (insert string)
50 (goto-char point) 50 (goto-char point)
51 (forward-word 1) 51 (forward-word 1)
52 (Assert (eq (point) (+ point stop))))) 52 (Assert-eq (point) (+ point stop))))
53 53
54 (with-temp-buffer 54 (with-temp-buffer
55 ;; -!- W NW 55 ;; -!- W NW
56 (test-forward-word "W " 1) 56 (test-forward-word "W " 1)
57 (test-forward-word "WO " 2) 57 (test-forward-word "WO " 2)
75 (defun test-backward-word (string stop) 75 (defun test-backward-word (string stop)
76 (goto-char (point-min)) 76 (goto-char (point-min))
77 (insert string) 77 (insert string)
78 (let ((point (point))) 78 (let ((point (point)))
79 (backward-word 1) 79 (backward-word 1)
80 (Assert (eq (point) (- point stop))))) 80 (Assert-eq (point) (- point stop))))
81 81
82 (with-temp-buffer 82 (with-temp-buffer
83 ;; NW W -!- 83 ;; NW W -!-
84 (test-backward-word " W" 1) 84 (test-backward-word " W" 1)
85 (test-backward-word " WO" 2) 85 (test-backward-word " WO" 2)
118 (insert string) 118 (insert string)
119 (put-text-property (+ point (car apply-pos)) (+ point (cdr apply-pos)) 119 (put-text-property (+ point (car apply-pos)) (+ point (cdr apply-pos))
120 'syntax-table apply-syntax) 120 'syntax-table apply-syntax)
121 (goto-char point) 121 (goto-char point)
122 (forward-word 1) 122 (forward-word 1)
123 (Assert (eq (point) (+ point stop)))))) 123 (Assert-eq (point) (+ point stop)))))
124 124
125 ;; test syntax-table extents 125 ;; test syntax-table extents
126 (with-temp-buffer 126 (with-temp-buffer
127 ;; Apply punctuation to word 127 ;; Apply punctuation to word
128 (test-syntax-table "WO" 1 `(,(syntax-string-to-code ".")) 1) 128 (test-syntax-table "WO" 1 `(,(syntax-string-to-code ".")) 1)
141 ;; Fixed 2007-03-25 Olivier Galibert <20070324221053.GA48218@dspnet.fr.eu.org> 141 ;; Fixed 2007-03-25 Olivier Galibert <20070324221053.GA48218@dspnet.fr.eu.org>
142 (with-temp-buffer 142 (with-temp-buffer
143 (with-syntax-table (make-syntax-table) 143 (with-syntax-table (make-syntax-table)
144 (insert "foo bar") 144 (insert "foo bar")
145 (backward-sexp 1) 145 (backward-sexp 1)
146 (Assert (eql (point) 5)))) 146 (Assert-eql (point) 5)))
147 147
148 ;; Test forward-comment at buffer boundaries 148 ;; Test forward-comment at buffer boundaries
149 ;; #### The second Assert fails (once interpreted, once compiled) on 21.4.9 149 ;; #### The second Assert fails (once interpreted, once compiled) on 21.4.9
150 ;; with sjt's version of Andy's syntax-text-property-killer patch. 150 ;; with sjt's version of Andy's syntax-text-property-killer patch.
151 (with-temp-buffer 151 (with-temp-buffer
154 "comment and parse-partial-sexp tests" 154 "comment and parse-partial-sexp tests"
155 (c-mode) 155 (c-mode)
156 156
157 (insert "// comment\n") 157 (insert "// comment\n")
158 (forward-comment -2) 158 (forward-comment -2)
159 (Assert (eq (point) (point-min))) 159 (Assert-eq (point) (point-min))
160 160
161 (let ((point (point))) 161 (let ((point (point)))
162 (insert "/* comment */") 162 (insert "/* comment */")
163 (goto-char point) 163 (goto-char point)
164 (forward-comment 2) 164 (forward-comment 2)
165 (Assert (eq (point) (point-max))) 165 (Assert-eq (point) (point-max))
166 166
167 ;; this last used to crash 167 ;; this last used to crash
168 (parse-partial-sexp point (point-max))))) 168 (parse-partial-sexp point (point-max)))))
169 169
170 ;; Test backward-up-list 170 ;; Test backward-up-list
201 ;; barring hardware error.... 201 ;; barring hardware error....
202 (Check-Error-Message syntax-error 202 (Check-Error-Message syntax-error
203 "Unbalanced parentheses" 203 "Unbalanced parentheses"
204 (backward-up-list-moves-point-from-to 25 nil)) 204 (backward-up-list-moves-point-from-to 25 nil))
205 ;; special-case check that point didn't move 205 ;; special-case check that point didn't move
206 (Assert (= (point) 25)))) 206 (Assert= (point) 25)))
207 207
208 (loop 208 (loop
209 with envvar-not-existing = (symbol-name (gensym "whatever")) 209 with envvar-not-existing = (symbol-name (gensym "whatever"))
210 with envvar-existing = (symbol-name (gensym "whatever")) 210 with envvar-existing = (symbol-name (gensym "whatever"))
211 with envvar-existing-val = (make-string #x10000 ?\xe1) 211 with envvar-existing-val = (make-string #x10000 ?\xe1)