diff tests/automated/lisp-tests.el @ 5244:04811a268716

Be clearer in our error messages, #'canonicalize-inst-pair, #'canonicalize-spec lisp/ChangeLog addition: 2010-08-15 Aidan Kehoe <kehoea@parhasard.net> * specifier.el (canonicalize-inst-pair, canonicalize-spec): If a specifier tag set is correct, but an instantiator is not in an accepted format, don't error with the message "Invalid specifier tag set". Also, when we error, use error-symbols, for better structured error handling and more ease when testing. tests/ChangeLog addition: 2010-08-15 Aidan Kehoe <kehoea@parhasard.net> * automated/lisp-tests.el: (not, not, invalid-argument, invalid-argument): Check that error messages from the image specifier instantiator code are clearer than they used to be.
author Aidan Kehoe <kehoea@parhasard.net>
date Sun, 15 Aug 2010 15:42:45 +0100
parents 808131ba4a57
children be436ac36ba4 308d34e9f07d
line wrap: on
line diff
--- a/tests/automated/lisp-tests.el	Sun Aug 15 13:29:10 2010 +0100
+++ b/tests/automated/lisp-tests.el	Sun Aug 15 15:42:45 2010 +0100
@@ -2374,6 +2374,35 @@
 				     (garbage-collect))))))
  "checking we can amputate lists without crashing #'reduce")
 
+(Assert (not (eq t (canonicalize-inst-list
+		    `(((mswindows) . [string :data ,(make-string 20 0)])
+		      ((tty) . [string :data " "])) 'image t)))
+	"checking mswindows is always available as a specifier tag")
+
+(Assert (not (eq t (canonicalize-inst-list
+		    `(((mswindows) . [nothing])
+		      ((tty) . [string :data " "]))
+		    'image t)))
+	"checking the correct syntax for a nothing image specifier works")
+
+(Check-Error-Message invalid-argument "^Invalid specifier tag set"
+		     (canonicalize-inst-list
+		      `(((,(gensym)) . [nothing])
+			((tty) . [string :data " "]))
+		      'image))
+
+(Check-Error-Message invalid-argument "^Unrecognized keyword"
+		     (canonicalize-inst-list
+		      `(((mswindows) . [nothing :data "hi there"])
+			((tty) . [string :data " "])) 'image))
+
+;; If we combine both the specifier inst list problems, we get the
+;; unrecognized keyword error first, not the invalid specifier tag set
+;; error. This is a little unintuitive; the specifier tag set thing is
+;; processed first, and would seem to be more important. But anyone writing
+;; code needs to solve both problems, it's reasonable to ask them to do it
+;; in series rather than in parallel.
+
 (when (featurep 'ratio)
   (Assert (not (eql '1/2 (read (prin1-to-string (intern "1/2")))))
 	  "checking symbols with ratio-like names are printed distinctly")