Mercurial > core / lisp/lib/cli/tests/pkg.lisp
changeset 689: |
2e7d93b892a5 |
parent: |
517c65b51e6b
|
author: |
Richard Westhaver <ellis@rwest.io> |
date: |
Tue, 01 Oct 2024 22:29:08 -0400 |
permissions: |
-rw-r--r-- |
description: |
cli shell tests init |
1 ;;; cli/tests.lisp --- CLI Tests 7 (:use :cl :std :rt :cli :cli/shell :cli/progress :cli/spark :cli/repl :cli/ansi :cli/prompt :cli/clap :cli/tools/sbcl :dat/sxp)) 9 (in-package :cli/tests) 13 ;; TODO: needs to be compiled outside scope of test - contender for 15 (defprompt tpfoo :prompt "testing:") 17 (deftest cli-prompt (:skip t) 21 (let ((*standard-input* (make-string-input-stream 22 (format nil "~A~%~A~%~%" "foobar" "foobar")))) 24 (is (string= (tpfoo-prompt) "foobar")) 26 (completing-read "nothing: " tcoll :history thist :default "foobar"))))) 29 (flet ((%step () (cli/progress::update 1))) 30 (let ((*progress-bar-enabled* t) 32 (with-progress-bar (n "TEST: # of steps = ~a" n) 33 (dotimes (i n) (%step)))))) 37 (spark '(1 5 22 13 5)) 43 (spark '(1 2 3 4 100 5 10 20 50 300)) 55 (spark '(0 30 55 80 33 150)) 71 (spark '(0 30 55 80 33 150) :min -100) 74 (spark '(0 30 55 80 33 150) :max 50) 77 (spark '(0 30 55 80 33 150) :min 30 :max 80) 79 ;; double-float, minus 81 (spark '(1.000000000005d0 0.000000000005d0 1.0d0)) 87 (spark '(-1.000000000005d0 0.000000000005d0 -1.0d0)) 90 (let ((ternary '(-1 0 1 -1 1 0 0 -1 1 1 0))) 95 (let ((*ticks* #(#\_ #\- #\¯))) 99 (let ((*ticks* #(#\▄ #\⎯ #\▀))) 103 (let ((*ticks* #(#\E #\O))) 104 (spark '(4 8 15 22 42) :key (lambda (n) (mod n 2)))) 107 (flet ((range (start end) (loop for i from start below end collect i)) 108 (fib (n) (loop for x = 0 then y 109 and y = 1 then (+ x y) 112 (fac (n) (labels ((rec (n acc) (if (<= n 1) acc (rec (1- n) (* n acc))))) 116 :key (lambda (x) (sin (* x pi 1/4)))) 117 "▄▆█▆▄▂▁▂▄▆█▆▄▂▁▂▄▆█▆▄▂▁▂▄▆█▆▄▂▁▂▄▆█▆▄▂▁▂▄▆█▆▄▂▁▂▄▆█")) 120 :key (lambda (x) (cos (* x pi 1/4)))) 121 "█▆▄▂▁▂▄▆█▆▄▂▁▂▄▆█▆▄▂▁▂▄▆█▆▄▂▁▂▄▆█▆▄▂▁▂▄▆█▆▄▂▁▂▄▆█▆▄")) 125 :key (lambda (x) (abs (cis (* x pi 1/4))))) 126 "▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁")) 130 :key (lambda (x) (float (phase (cis (* x pi 1/4))) 1.0))) 131 "▄▅▆▇█▁▁▂▄▅▆▇█▁▁▂▄▅▆▇█▁▁▂▄▅▆▇█▁▁▂▄▅▆▇█▁▁▂▄▅▆▇█▁▁▂▄▅▆")) 134 (spark (range 1 7) :key #'log) 138 (spark (range 1 7) :key #'sqrt) 144 (spark (range 1 7) :key #'fib) 147 (spark (range 1 7) :key #'exp) 150 (spark (range 1 7) :key #'fac) 153 (spark (range 1 7) :key #'isqrt) 156 (flet ((lbits (n) (spark (map 'list #'digit-char-p (write-to-string n :base 2))))) 179 ˫-----------------------+------------------------˧ 188 ˫-----------------------+------------------------˧ 195 (vspark '(0 30 55 80 33 150)) 198 ˫-----------------------+------------------------˧ 202 ██████████████████████████▋ 204 ██████████████████████████████████████████████████ 211 (vspark '(0 30 55 80 33 150) :min -100) 214 ˫-----------------------+------------------------˧ 215 ████████████████████▏ 216 ██████████████████████████▏ 217 ███████████████████████████████▏ 218 ████████████████████████████████████▏ 219 ██████████████████████████▋ 220 ██████████████████████████████████████████████████ 224 (vspark '(0 30 55 80 33 150) :max 50) 227 ˫-----------------------+------------------------˧ 229 ██████████████████████████████▏ 230 ██████████████████████████████████████████████████ 231 ██████████████████████████████████████████████████ 232 █████████████████████████████████▏ 233 ██████████████████████████████████████████████████ 238 (vspark '(0 30 55 80 33 150) :min 30 :max 80) 241 ˫-----------------------+------------------------˧ 244 █████████████████████████▏ 245 ██████████████████████████████████████████████████ 247 ██████████████████████████████████████████████████ 252 (vspark '(1 0 .5) :labels '("on" "off" "unknown") 262 (vspark '(1 0 .5) :labels '("on" "off") 272 (vspark '(1 0) :labels '("on" "off" "unknown") 282 (vspark '(0 1 2 3 4 5 6 7 8) :key (lambda (x) (sin (* x pi 1/4)))) 285 ˫-----------------------+------------------------˧ 286 █████████████████████████▏ 287 ██████████████████████████████████████████▋ 288 ██████████████████████████████████████████████████ 289 ██████████████████████████████████████████▋ 290 █████████████████████████▏ 294 ████████████████████████▉ 299 (vspark '(0 1 2 3 4 5 6 7 8) :key (lambda (x) (sin (* x pi 1/4))) 317 (vspark '(0 1 2 3 4 5 6 7 8) :key (lambda (x) (sin (* x pi 1/4))) 333 (let ((life-expectancies '(("Africa" 56) 335 ("South-East Asia" 67) 337 ("Eastern Mediterranean" 68) 338 ("Western Pacific" 76) 342 (vspark life-expectancies :key #'second) 345 ˫-----------------------+------------------------˧ 347 ██████████████████████████████████████████████████ 348 ███████████████████████████▌ 349 ██████████████████████████████████████████████████ 350 ██████████████████████████████▏ 351 ██████████████████████████████████████████████████ 352 ███████████████████████████████████▏ 357 (vspark life-expectancies :key #'second :scale? nil :newline? nil) 359 ██████████████████████████████████████████████████ 360 ███████████████████████████▌ 361 ██████████████████████████████████████████████████ 362 ██████████████████████████████▏ 363 ██████████████████████████████████████████████████ 364 ███████████████████████████████████▏")) 368 (vspark life-expectancies :key #'second :scale? nil) 371 ██████████████████████████████████████████████████ 372 ███████████████████████████▌ 373 ██████████████████████████████████████████████████ 374 ██████████████████████████████▏ 375 ██████████████████████████████████████████████████ 376 ███████████████████████████████████▏ 381 (vspark life-expectancies 383 :labels (mapcar #'first life-expectancies)) 386 ˫------------+-------------˧ 388 Americans ████████████████████████████ 389 South-East Asia ███████████████▍ 390 Europe ████████████████████████████ 391 Eastern Mediterranean ████████████████▊ 392 Western Pacific ████████████████████████████ 393 Global ███████████████████▋ 398 (vspark life-expectancies 401 :labels (mapcar #'first life-expectancies) 402 :title "Life Expectancy") 406 ˫------------+-------------˧ 408 Americans ████████████████████████▎ 409 South-East Asia ███████████████▉ 410 Europe ████████████████████████▎ 411 Eastern Mediterranean ████████████████▊ 412 Western Pacific ████████████████████████▎ 413 Global ██████████████████▋ 417 (spark (range 0 15) :key #'fib) 421 (vspark (range 0 15) :key #'fib) 424 ˫-----------------------+------------------------˧ 438 ██████████████████████████████▉ 439 ██████████████████████████████████████████████████ 445 (ld-library-path-list) 446 (is (exec-path-list)) 447 (is (find-exe "sbcl"))) 449 (deftest sbcl-tools () 450 (with-sbcl (:noinform t :quit t)