61 lines
1.3 KiB
Scheme
61 lines
1.3 KiB
Scheme
(import (scheme base)
|
|
(scheme read)
|
|
(scheme eval)
|
|
(scheme write)
|
|
(picrin readline)
|
|
(picrin readline history)
|
|
(picrin test))
|
|
|
|
|
|
;; (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")
|
|
|
|
(define testfile "./picrin_readline_test_file")
|
|
|
|
(test-begin)
|
|
|
|
(test 0 (history-length))
|
|
(add-history "0")
|
|
(test 1 (history-length))
|
|
(let loop ((n 1))
|
|
(if (> 10 n)
|
|
(begin
|
|
(add-history (number->string n))
|
|
(loop (+ n 1)))))
|
|
(test 10 (history-length))
|
|
(stifle-history 7)
|
|
(test 7 (history-length))
|
|
(add-history "10")
|
|
(test 7 (history-length))
|
|
(test #t (history-stifled?))
|
|
(unstifle-history)
|
|
(test #f (history-stifled?))
|
|
(test 7 (history-length))
|
|
(add-history "11")
|
|
(test 8 (history-length))
|
|
(test "10" (history-get 11))
|
|
(remove-history 1)
|
|
(test "10" (history-get 11))
|
|
(test 7 (history-length))
|
|
(write-history testfile)
|
|
(test 7 (history-length))
|
|
(clear-history)
|
|
(test 0 (history-length))
|
|
(read-history testfile)
|
|
(test 7 (history-length))
|
|
(clear-history)
|
|
(truncate-file testfile 5)
|
|
(read-history testfile)
|
|
(test 5 (history-length))
|
|
|
|
(test-end)
|