Add coverage, get to near 100
[sheep] / src / main / var.lisp
index c184795552b52dff6f518d7502915fb4e6ab0178..4238762bf9bef4d55c42bbaa66a8408c7770bd5d 100644 (file)
@@ -23,7 +23,6 @@
 (defun verify-next-line (&key optional)
  (cond
   ((and optional (not (more))) t)
-  ((not (more)) (fire-error (format nil "Expected line after: ~A" (prev-line))))
   ((cl-ppcre:scan " $" (peek)) (fire-error (format nil "Can't end line with a space: ~A" (peek))))
   ((< 120 (length (peek))) (fire-error (format nil "Longer than 120 chars: ~A" (peek))))))
 
@@ -40,7 +39,7 @@
      (cons
       (format nil "~A~A~A"
        (subseq next-line 2 (length next-line))
-       (if (and (car rest-of-freeform) (string/= "" (car rest-of-freeform))) " " "")
+       (if (string/= "" (car rest-of-freeform)) " " "")
        (car rest-of-freeform))
       (cdr rest-of-freeform))))
    ((string= "" next-line)
@@ -70,6 +69,7 @@
    (process-examples))))
 
 (defun parse-examples ()
+ ; This shouldn't fire, unless there's a bug in our processing
  (when (string/= "EXAMPLES:" (next)) (fire-error (format nil "Expected EXAMPLES: instead of: ~A" (prev-line))))
  (expect-blank-line)
  (list :examples (process-examples)))
@@ -86,7 +86,6 @@
        (lambda
         (text-item)
         (cond
-         ((not (stringp text-item)) (list text-item))
          ((not (cl-ppcre:scan (cl-ppcre:quote-meta-chars (car remaining-keywords)) text-item)) (list text-item))
          (t
           (let
@@ -96,8 +95,6 @@
             (mapcar (lambda (ti) (list (list :keyword (car remaining-keywords)) ti)) (cdr split-text)))))))
        (inject-keywords text (cdr remaining-keywords)))))))
   (list :text (inject-keywords text *keywords*))))
-; (map
-; (list :text text))
 
 (defun parse-header (var)
  (verify-next-line)
   ((var-name (symbol-name var)))
   (when (not (string= var-name (peek)))
    (fire-error (format nil "First line of ~A did not match: ~A, ~A" var var-name (peek))))
-  (when (cl-ppcre:scan "[a-z]" var-name)
-   (fire-error (format nil "Variable name should be all uppercase: ~A" var-name)))
   (add-keyword var-name)
   (next)
   (expect-blank-line)
     (cond
      ((stringp text) text)
      ((and (listp text) (eql :keyword (car text))) (format nil "_~(~A~)_" (cadr text)))
+     ; This should never fire, unless there's a bug in our processor
      (t (fire-error (format nil "Don't know how to convert text: ~S" text)))))
    (cadr text))))