picrin/contrib/10.readline/t/test.scm

60 lines
1.3 KiB
Scheme
Raw Normal View History

2014-08-07 03:35:33 -04:00
(import (scheme base)
(scheme read)
(scheme eval)
(scheme write)
2014-08-07 17:28:00 -04:00
(picrin readline)
(picrin readline history)
(picrin test))
2014-08-07 03:35:33 -04:00
2014-08-07 17:28:00 -04:00
;; (let loop ((n 1))
;; (let ((input (readline "> ")))
;; (if (eof-object? input)
;; (newline)
;; (begin
;; (add-history input)
;; (write (eval (read (open-input-string input)) '(picrin user)))
;; (newline)
;; (loop 1)))))
;; (readline "prompt")
2014-08-08 14:53:53 -04:00
(define testfile "picrin_readline_test_file")
2014-08-07 17:28:00 -04:00
(test-begin)
(test 0 (history-length))
2014-08-07 18:16:09 -04:00
(add-history "1")
2014-08-07 17:28:00 -04:00
(test 1 (history-length))
2014-08-07 18:16:09 -04:00
(let loop ((n 2))
(if (>= 10 n)
2014-08-07 17:28:00 -04:00
(begin
(add-history (number->string n))
(loop (+ n 1)))))
(test 10 (history-length))
(stifle-history 7)
2014-08-07 18:16:09 -04:00
(test 10 (history-length))
(add-history "11")
2014-08-07 17:28:00 -04:00
(test 7 (history-length))
(test #t (history-stifled?))
(unstifle-history)
(test #f (history-stifled?))
(test 7 (history-length))
2014-08-07 18:16:09 -04:00
(add-history "12")
2014-08-07 17:28:00 -04:00
(test 8 (history-length))
2014-08-07 18:16:09 -04:00
(test "11" (history-get 11))
2014-08-07 17:28:00 -04:00
(remove-history 1)
2014-08-07 18:16:09 -04:00
(test "11" (history-get 11))
2014-08-07 17:28:00 -04:00
(test 7 (history-length))
(write-history testfile)
(test 7 (history-length))
(clear-history)
(test 0 (history-length))
2014-08-08 14:53:53 -04:00
;(read-history testfile)
2014-08-07 17:28:00 -04:00
(test 7 (history-length))
(clear-history)
(truncate-file testfile 5)
2014-08-08 14:53:53 -04:00
;(read-history testfile)
2014-08-07 17:28:00 -04:00
(test 5 (history-length))
(test-end)