jak-project/goal_src/test/test-format.gc
2020-09-14 20:24:05 -04:00

49 lines
1.6 KiB
Common Lisp

(define-extern _format function)
(define format _format)
(format #t "test newline~%newline~%")
(format #t "test tilde ~~ ~%")
;; test g, G
(format #t "test A print boxed-string: ~a~%" "boxed string!")
(format #t "test A print symbol: ~A~%" 'a-symbol)
(format #t "test A make boxed object longer: ~17A!~%" "srt")
(format #t "test A non-default pad: ~12,'za~%" 'pad-me)
(format #t "test A shorten(4): ~4a~%" 'a234567)
(format #t "test A don'tchange(4): ~4a~%" 'a234)
(format #t "test A shorten with pad(4): ~4,'za~%" 'shorten-me)
(format #t "test A a few things ~a ~a ~a ~a~%" "one thing" 'a-second integer print)
(format #t "test S ~s ~s ~s~%" "a string" 'a-symbol "another string!")
(format #t "test C ~c ~c~%" 41 #x5d)
(format #t "test P (no type) ~p~%" print)
(format #t "test P (with type) ~`integer`p~%" print)
(format #t "test I (no type) ~i" inspect)
(format #t "test I (with type) ~`integer`i" inspect)
(format #t "test X ~x ~10x ~10,'.x ~3x ~3,'.x~%" #xbaadbeef #x2 #x3 #x0badbeef #x0badbeef)
(format #t "test D ~d ~10d ~10,'.d ~3d ~3,'.d~%" #xbaadbeef #x2 #x3 #x0badbeef #x0badbeef)
(format #t "test B ~b ~10b ~10,'.b ~3b ~3,'.b~%" #xbaadbeef #x2 #x3 #x0badbeef #x0badbeef)
;; test f, F, r, R, m, M
(format #t "test E ~E ~e ~e~%" 1 20 301)
(format #t "test pass through ~10,'b,2W~%")
(format #t "test tab~Taftertab~%")
(format #t "test many ~d ~d ~d ~d ~d~%" 1 2 3 4 5)
;; test floats
(format #t "test f ~F ~12,'0,2f ~f~%" -1.234 1.234 -1.234)
(format #t "test r ~R ~12,'0,2r ~r~%" 1.234 1.567 1.987)
(format #t "test m ~M ~12,'0,2m ~m~%" 1.234 1.567 1.987)
(format #t "test as float ~`float`P~%" -99987623.23123)
0