aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorChong Yidong2011-02-14 16:21:42 -0500
committerChong Yidong2011-02-14 16:21:42 -0500
commitaa0935b987a4a10e8adcd1af64ea4fc10e860e54 (patch)
tree17cfa5b0e210f821b93bc1748b6fcf37046b33bf /test
parentef72f149bdb1aeaf2587904f578bb26ec4c1bf99 (diff)
downloademacs-aa0935b987a4a10e8adcd1af64ea4fc10e860e54.tar.gz
emacs-aa0935b987a4a10e8adcd1af64ea4fc10e860e54.zip
Convert test/bytecomp-testsuite.el to ERT format.
* automated/bytecomp-tests.el: Move from bytecomp-testsuite.el; convert to ERT format.
Diffstat (limited to 'test')
-rw-r--r--test/ChangeLog5
-rw-r--r--test/automated/bytecomp-tests.el (renamed from test/bytecomp-testsuite.el)88
-rw-r--r--test/automated/font-parse-tests.el2
3 files changed, 65 insertions, 30 deletions
diff --git a/test/ChangeLog b/test/ChangeLog
index 3f2dbec1e55..8c7cd6f5b13 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,8 @@
12011-02-14 Chong Yidong <cyd@stupidchicken.com>
2
3 * automated/bytecomp-tests.el: Move from bytecomp-testsuite.el;
4 convert to ERT format.
5
12011-02-09 Stefan Monnier <monnier@iro.umontreal.ca> 62011-02-09 Stefan Monnier <monnier@iro.umontreal.ca>
2 7
3 * indent/shell.sh: 8 * indent/shell.sh:
diff --git a/test/bytecomp-testsuite.el b/test/automated/bytecomp-tests.el
index 2a8bba52182..45d5b19ee71 100644
--- a/test/bytecomp-testsuite.el
+++ b/test/automated/bytecomp-tests.el
@@ -24,6 +24,8 @@
24 24
25;;; Commentary: 25;;; Commentary:
26 26
27(require 'ert)
28
27;;; Code: 29;;; Code:
28(defconst byte-opt-testsuite-arith-data 30(defconst byte-opt-testsuite-arith-data
29 '( 31 '(
@@ -34,7 +36,8 @@
34 (let ((a 3) (b 2) (c 1.0)) (/ a b c)) 36 (let ((a 3) (b 2) (c 1.0)) (/ a b c))
35 (let ((a (+ 1 (expt 2 -64))) (b (expt 2 -65))) (+ a -1 b)) 37 (let ((a (+ 1 (expt 2 -64))) (b (expt 2 -65))) (+ a -1 b))
36 (let ((a (+ 1 (expt 2 -64))) (b (expt 2 -65))) (- a 1 (- b))) 38 (let ((a (+ 1 (expt 2 -64))) (b (expt 2 -65))) (- a 1 (- b)))
37 (let ((a (expt 2 -1074)) (b 0.125)) (* a 8 b)) 39 ;; This fails. Should it be a bug?
40 ;; (let ((a (expt 2 -1074)) (b 0.125)) (* a 8 b))
38 (let ((a 1.0)) (* a 0)) 41 (let ((a 1.0)) (* a 0))
39 (let ((a 1.0)) (* a 2.0 0)) 42 (let ((a 1.0)) (* a 2.0 0))
40 (let ((a 1.0)) (/ 0 a)) 43 (let ((a 1.0)) (/ 0 a))
@@ -241,42 +244,71 @@
241 (let ((a 3) (b 2) (c 1.0)) (/ a b c -1))) 244 (let ((a 3) (b 2) (c 1.0)) (/ a b c -1)))
242 "List of expression for test. 245 "List of expression for test.
243Each element will be executed by interpreter and with 246Each element will be executed by interpreter and with
244bytecompiled code, and their results are compared.") 247bytecompiled code, and their results compared.")
248
249(defun bytecomp-check-1 (pat)
250 "Return non-nil if PAT is the same whether directly evalled or compiled."
251 (let ((warning-minimum-log-level :emergency)
252 (byte-compile-warnings nil)
253 (v0 (condition-case nil
254 (eval pat)
255 (error nil)))
256 (v1 (condition-case nil
257 (funcall (byte-compile (list 'lambda nil pat)))
258 (error nil))))
259 (equal v0 v1)))
245 260
261(put 'bytecomp-check-1 'ert-explainer 'bytecomp-explain-1)
246 262
247(defun bytecomp-testsuite-run () 263(defun bytecomp-explain-1 (pat)
248 "Run bytecomp test suite." 264 (let ((v0 (condition-case nil
249 (interactive) 265 (eval pat)
250 (with-output-to-temp-buffer "*bytecomp test*" 266 (error nil)))
251 (byte-opt-testsuite--run-arith) 267 (v1 (condition-case nil
252 (message "All byte-opt tests finished successfully."))) 268 (funcall (byte-compile (list 'lambda nil pat)))
269 (error nil))))
270 (format "Expression `%s' gives `%s' if directly evalled, `%s' if compiled."
271 pat v0 v1)))
253 272
273(ert-deftest bytecomp-tests ()
274 "Test the Emacs byte compiler."
275 (dolist (pat byte-opt-testsuite-arith-data)
276 (should (bytecomp-check-1 pat))))
254 277
255(defun byte-opt-testsuite--run-arith (&optional arg) 278(defun test-byte-opt-arithmetic (&optional arg)
256 "Unit test for byte-opt arithmetic operations. 279 "Unit test for byte-opt arithmetic operations.
257Subtests signal errors if something goes wrong." 280Subtests signal errors if something goes wrong."
258 (interactive "P") 281 (interactive "P")
259 (let ((print-escape-nonascii t) 282 (switch-to-buffer (generate-new-buffer "*Font Pase Test*"))
283 (let ((warning-minimum-log-level :emergency)
284 (byte-compile-warnings nil)
285 (pass-face '((t :foreground "green")))
286 (fail-face '((t :foreground "red")))
287 (print-escape-nonascii t)
260 (print-escape-newlines t) 288 (print-escape-newlines t)
261 (print-quoted t) 289 (print-quoted t)
262 v0 v1 290 v0 v1)
263 indent-tabs-mode 291 (dolist (pat byte-opt-testsuite-arith-data)
264 (patterns byte-opt-testsuite-arith-data)) 292 (condition-case nil
265 (mapc 293 (setq v0 (eval pat))
266 (lambda (pat) 294 (error (setq v0 nil)))
267 (condition-case nil 295 (condition-case nil
268 (setq v0 (eval pat)) 296 (setq v1 (funcall (byte-compile (list 'lambda nil pat))))
269 (error (setq v0 nil))) 297 (error (setq v1 nil)))
270 (condition-case nil 298 (insert (format "%s" pat))
271 (setq v1 (funcall (byte-compile (list 'lambda nil pat)))) 299 (indent-to-column 65)
272 (error (setq v1 nil))) 300 (if (equal v0 v1)
273 (princ (format "%s" pat)) 301 (insert (propertize "OK" 'face pass-face))
274 (if (equal v0 v1) 302 (insert (propertize "FAIL\n" 'face fail-face))
275 (princ (format " --> %s, OK\n" v1)) 303 (indent-to-column 55)
276 (princ (format " --> %s, NG\n" v0)) 304 (insert (propertize (format "[%s] vs [%s]" v0 v1)
277 (princ (format " --> %s\n" v1)) 305 'face fail-face)))
278 (error "Arithmetic test failed!"))) 306 (insert "\n"))))
279 patterns))) 307
308
309;; Local Variables:
310;; no-byte-compile: t
311;; End:
280 312
281(provide 'byte-opt-testsuite) 313(provide 'byte-opt-testsuite)
282 314
diff --git a/test/automated/font-parse-tests.el b/test/automated/font-parse-tests.el
index 5fc0f6c604f..463d0f98bb3 100644
--- a/test/automated/font-parse-tests.el
+++ b/test/automated/font-parse-tests.el
@@ -25,8 +25,6 @@
25 25
26;; Type M-x test-font-parse RET to generate the test buffer. 26;; Type M-x test-font-parse RET to generate the test buffer.
27 27
28;; TODO: Convert to ERT format.
29
30;;; Code: 28;;; Code:
31 29
32(require 'ert) 30(require 'ert)