aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDaniel Colascione2014-04-19 19:34:22 -0700
committerDaniel Colascione2014-04-19 19:34:22 -0700
commit89a2e783c2f22b4932dd77c16a0e357c5c17a4bf (patch)
treee3cdb05ac00ce099145ac0205c6ce12da43e7f1d /test
parent6dfa19c50f75c1892f5c9a48104ddd532796d089 (diff)
downloademacs-89a2e783c2f22b4932dd77c16a0e357c5c17a4bf.tar.gz
emacs-89a2e783c2f22b4932dd77c16a0e357c5c17a4bf.zip
defstruct introspection
Diffstat (limited to 'test')
-rw-r--r--test/ChangeLog4
-rw-r--r--test/automated/cl-lib.el19
2 files changed, 23 insertions, 0 deletions
diff --git a/test/ChangeLog b/test/ChangeLog
index 338a825f51e..940ed0b0b91 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,7 @@
12014-04-20 Daniel Colascione <dancol@dancol.org>
2
3 * automated/cl-lib.el (cl-lib-struct-accessors,cl-the): New tests.
4
12014-04-19 Michael Albinus <michael.albinus@gmx.de> 52014-04-19 Michael Albinus <michael.albinus@gmx.de>
2 6
3 * automated/tramp-tests.el (tramp--test-check-files): Extend test. 7 * automated/tramp-tests.el (tramp--test-check-files): Extend test.
diff --git a/test/automated/cl-lib.el b/test/automated/cl-lib.el
index f7f4314e1cb..a0df07e54ea 100644
--- a/test/automated/cl-lib.el
+++ b/test/automated/cl-lib.el
@@ -201,4 +201,23 @@
201 :b :a :a 42) 201 :b :a :a 42)
202 '(42 :a)))) 202 '(42 :a))))
203 203
204(ert-deftest cl-lib-struct-accessors ()
205 (cl-defstruct mystruct (abc :readonly t) def)
206 (let ((x (make-mystruct :abc 1 :def 2)))
207 (should (eql (cl-struct-slot-value 'mystruct 'abc x) 1))
208 (should (eql (cl-struct-slot-value 'mystruct 'def x) 2))
209 (cl-struct-set-slot-value 'mystruct 'def x -1)
210 (should (eql (cl-struct-slot-value 'mystruct 'def x) -1))
211 (should (eql (cl-struct-slot-offset 'mystruct 'abc) 1))
212 (should-error (cl-struct-slot-offset 'mystruct 'marypoppins))
213 (should (equal (cl-struct-slot-info 'mystruct)
214 '((cl-tag-slot) (abc :readonly t) (def))))))
215
216(ert-deftest cl-the ()
217 (should (eql (the integer 42) 42))
218 (should-error (the integer "abc"))
219 (let ((sideffect 0))
220 (should (= (the integer (incf sideffect)) 1))
221 (should (= sideffect 1))))
222
204;;; cl-lib.el ends here 223;;; cl-lib.el ends here