-
Notifications
You must be signed in to change notification settings - Fork 110
/
Copy pathformat.lisp
42 lines (32 loc) · 1.25 KB
/
format.lisp
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
;;; -*- mode:lisp; coding:utf-8 -*-
(/debug "perform test/format.lisp!")
(test (string= "a" (format nil "a")))
(test (string= "~" (format nil "~~")))
(test (string= "a~a" (format nil "a~~a")))
(test (string= "a
a" (format nil "a~%a")))
(test (string= "this is foo" (format nil "this is ~a" "foo")))
(test (string= "this is foo" (format nil "this is ~A" "foo")))
(test (string= "this is \"foo\"" (format nil "this is ~s" "foo")))
(test (string= "this is \"foo\"" (format nil "this is ~S" "foo")))
(test (string= "this is 2" (format nil "this is ~*~A" 1 2)))
;;; ~C
(test (string= "a" (format nil "~C" #\a)))
(test (string= " " (format nil "~C" #\space)))
(test (string= "Space" (format nil "~:C" #\space)))
(test (string= "Newline" (format nil "~:C" #\newline)))
;;; Premature end of control string
#+jscl
(test
(string= "Premature end of control string \"result ~\""
(let ((result))
(handler-case
(progn
(format nil "its ok ~~")
(format nil "result ~"))
(error (msg)
(setq result
(format nil (simple-condition-format-control msg)
(car (simple-condition-format-arguments msg))))))
result)))
;;; EOF