-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpprint-table--tests.el
48 lines (40 loc) · 1.7 KB
/
pprint-table--tests.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
;; -*- mode:emacs-lisp;coding:utf-8-unix;lexical-binding:t;byte-compile-dynamic:t; -*-
(require 'pprint-table)
(require 'ert)
(ert-deftest pprint-table-to-string-rereadable ()
"Test if printed table can be re-read to give the original value."
(let ((reread-equal
(lambda (sexp)
(let ((re-read (read (pprint-table-to-string sexp))))
(if (equal re-read sexp) t
(signal 'error
(list "Reread sexp didn't match sexp"
(list 'original sexp)
(list 'reread re-read))))))))
(should (funcall reread-equal
'((simple table case)
(all regular shaped)
(all lists only))))
(should (funcall reread-equal
'((simple table case)
(irregular table shape with empty line)
())))
(should (funcall reread-equal
'((table with numbers)
(1 2 3 4)
("and" "strings"))))
(should (funcall reread-equal
'(table
with
atoms
(and lists mixed)
"in place")))
(should (funcall reread-equal
'((table with)
[vector entries])))
(should (funcall reread-equal
'[(a vector table)
(with list entries only)]))
(should (funcall reread-equal
'[[vector list]
(with vector entries)]))))