Coverage report: /home/ellis/comp/core/lib/organ/object/stat-cookie.lisp
Kind | Covered | All | % |
expression | 0 | 35 | 0.0 |
branch | 0 | 2 | 0.0 |
Key
Not instrumented
Conditionalized out
Executed
Not executed
Both branches taken
One branch taken
Neither branch taken
4
;; the logic will be a bit weird here - we store 2 numbers (completed
5
;; vs remaining) but sometimes need to parse a percentage without
6
;; actually knowing the counts of completed vs remaining. To get
7
;; around this, we'll allow a float to be stored in the N1 slot, which
8
;; indicated that we parsed a percentage without knowing our counts.
9
(define-org-object stat-cookie ((n1 0 :type number) (n2 0 :type fixnum)))
11
(defmacro matches (name)
12
`(make-matcher ,name))
14
(define-matcher stat-cookie-percent (is #\%))
16
(define-matcher stat-cookie-ratio (is #\/))
18
(define-matcher int (in #\0 #\9))
20
(define-matcher stat-cookie-start
22
(next (matches (or :int
24
:stat-cookie-percent)))))
26
(define-matcher stat-cookie-end (is #\]))
29
(define-org-parser (stat-cookie :from string)
31
(with-lexer-environment (input)
32
(when (char= #\[ (consume))
33
(let ((res (org-create :stat-cookie)))
34
(setf (org-stat-cookie-n1 res)
36
(consume-until (matches (not :int)))))
38
(#\/ (setf (org-stat-cookie-n2 res) (parse-number (consume-until (matches :stat-cookie-end)))))
39
(#\% (setf (org-stat-cookie-n1 res) (/ (org-stat-cookie-n1 res) 100))))