File: test.tst

package info (click to toggle)
clisp 1%3A2.41-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 49,804 kB
  • ctags: 16,291
  • sloc: lisp: 75,912; ansic: 49,247; xml: 24,289; asm: 21,993; sh: 11,234; fortran: 6,692; cpp: 2,660; objc: 2,481; makefile: 2,355; perl: 164; sed: 55
file content (80 lines) | stat: -rw-r--r-- 2,708 bytes parent folder | download
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
;; -*- Lisp -*-
;; some tests for READLINE
;; clisp -q -norc -i ../tests/tests -x '(run-test "readline/test")'

(let ((ver-num (and (boundp 'readline:readline-version)
                    readline:readline-version)))
  (format t "~&readline version ~S (~D=0~O=x~X)~%"
          (and (boundp 'readline:library-version) readline:library-version)
          ver-num ver-num ver-num))
nil

(if (boundp 'readline:editing-mode) readline:editing-mode 1) 1
(if (boundp 'readline:insert-mode)  readline:insert-mode 1)  1
(if (boundp 'readline:readline-name) readline:readline-name "CLISP") "CLISP"
(setq readline:readline-name "abazonk") "abazonk"
readline:readline-name                  "abazonk"

(readline:history-stifled-p)    0
(readline:stifle-history 100) NIL
(readline:history-stifled-p)    1
(abs (readline:unstifle-history)) 100 ; 5=>100, 4.2=>-100
(readline:history-stifled-p)    0

(readline:where-history)       0
(readline:history-total-bytes) 0

(defparameter *history-file* "readline-history-file") *history-file*
(readline:write-history *history-file*)            0
(readline:append-history 1000 *history-file*)      0
(readline:read-history *history-file*)             0
(readline:read-history-range *history-file* 0 -1)  0
(readline:history-truncate-file *history-file* 10) 0
(probe-file (delete-file *history-file*))          NIL

(when (zerop (logand readline:readline-state readline:STATE-INITIALIZED))
  (not (zerop (readline:initialize))))
NIL

(readline:resize-terminal) NIL

(multiple-value-bind (rows cols) (readline:get-screen-size)
  (show (list rows cols))
  (readline:set-screen-size rows cols))
NIL

;;; This tests readline-from-string, and indirectly getc-function
(progn
  (defun stuff-string (string)
    "Stuff a string (with NewLine added) to readline buffer"
    (assert (< (length string) 255)) ; stuff-char limit
    (map 'nil (lambda (char) (readline:stuff-char (char-code char))) string)
    (readline:stuff-char (char-code #\NewLine)))
  (defun readline-from-string (string)
    "Run readline:readline, with fake input."
    (stuff-string string)
    (readline:readline ""))
  (readline-from-string "test")) "test"

;;; Bind key and test that function works
(let ((a 0))
  (readline:bind-key (char-code #\t) (lambda (? ??) (incf a)))
  (readline-from-string "test")
  a) 2

;;; Now key is  unbound, but still ignored
(readline:unbind-key (char-code #\t)) 0
(readline-from-string "test") "es"

;;; Bind it back to insert-self
(progn
  (readline:parse-and-bind "\"t\": self-insert")
  (readline-from-string "test"))
"test"

(progn
  (stuff-string "(1 2")
  (stuff-string "3 4) 5")
  (read readline:*readline-input-stream*)) (1 2 3 4)

(read readline:*readline-input-stream*) 5