parent
da3caf4f5b
commit
fc88c1907a
|
@ -26,45 +26,45 @@
|
|||
;; --- is the <counter> incremented correct ---
|
||||
|
||||
(add-test! 'counter-inc-test 'awk
|
||||
(lambda ()
|
||||
(let ((read '())
|
||||
(string (let loop ((i 0))
|
||||
(if (not (= 9 i))
|
||||
(begin
|
||||
(string-append "test-zeile\n"
|
||||
(loop (+ i 1))))
|
||||
""))))
|
||||
((lambda (in-port)
|
||||
(awk (read-line in-port) (line) counter ()
|
||||
(#t (set! read (cons counter read)))))
|
||||
(make-string-input-port string))
|
||||
(equal? read '(9 8 7 6 5 4 3 2 1)))))
|
||||
(lambda ()
|
||||
(let ((read '())
|
||||
(string (let loop ((i 0))
|
||||
(if (not (= 9 i))
|
||||
(begin
|
||||
(string-append "test-zeile\n"
|
||||
(loop (+ i 1))))
|
||||
""))))
|
||||
((lambda (in-port)
|
||||
(awk (read-line in-port) (line) counter ()
|
||||
(#t (set! read (cons counter read)))))
|
||||
(make-string-input-port string))
|
||||
(equal? read '(9 8 7 6 5 4 3 2 1)))))
|
||||
|
||||
;; --- does the "int-test" work properly ---
|
||||
|
||||
(add-test! 'int-test-test 'awk
|
||||
(lambda ()
|
||||
(let ((read '())
|
||||
(string (let loop ((i 0))
|
||||
(if (not (= 9 i))
|
||||
(begin
|
||||
(string-append "test-zeile\n"
|
||||
(loop (+ i 1))))
|
||||
""))))
|
||||
((lambda (in-port)
|
||||
(awk (read-line in-port) (line) counter ()
|
||||
(1 (set! read (cons 1 read)))
|
||||
(2 (set! read (cons 2 read)))
|
||||
(3 (set! read (cons 3 read)))
|
||||
(4 (set! read (cons 4 read)))
|
||||
(5 (set! read (cons 5 read)))
|
||||
(6 (set! read (cons 6 read)))
|
||||
(7 (set! read (cons 7 read)))
|
||||
(8 (set! read (cons 8 read)))
|
||||
(9 (set! read (cons 9 read)))
|
||||
(0 (set! read (cons 0 read)))))
|
||||
(make-string-input-port string))
|
||||
(equal? read '(9 8 7 6 5 4 3 2 1)))))
|
||||
(lambda ()
|
||||
(let ((read '())
|
||||
(string (let loop ((i 0))
|
||||
(if (not (= 9 i))
|
||||
(begin
|
||||
(string-append "test-zeile\n"
|
||||
(loop (+ i 1))))
|
||||
""))))
|
||||
((lambda (in-port)
|
||||
(awk (read-line in-port) (line) counter ()
|
||||
(1 (set! read (cons 1 read)))
|
||||
(2 (set! read (cons 2 read)))
|
||||
(3 (set! read (cons 3 read)))
|
||||
(4 (set! read (cons 4 read)))
|
||||
(5 (set! read (cons 5 read)))
|
||||
(6 (set! read (cons 6 read)))
|
||||
(7 (set! read (cons 7 read)))
|
||||
(8 (set! read (cons 8 read)))
|
||||
(9 (set! read (cons 9 read)))
|
||||
(0 (set! read (cons 0 read)))))
|
||||
(make-string-input-port string))
|
||||
(equal? read '(9 8 7 6 5 4 3 2 1)))))
|
||||
|
||||
;; --- big line ---
|
||||
|
||||
|
@ -88,346 +88,352 @@
|
|||
;; --- special signs ---
|
||||
|
||||
(add-test! 'read-special-signs 'awk
|
||||
(lambda ()
|
||||
(let (( strange-sign-line
|
||||
(let loop ((i 0))
|
||||
(if (= i 256)
|
||||
""
|
||||
(if (= i 10) ;; works with everything but line-feed
|
||||
(loop (+ i 1))
|
||||
(string-append (ascii->string i)
|
||||
(loop (+ i 1)))))))
|
||||
(read '()))
|
||||
((lambda (in-port)
|
||||
(awk (read-line in-port) (line) ()
|
||||
(#t (set! read line))))
|
||||
(make-string-input-port strange-sign-line))
|
||||
(equal? read strange-sign-line))))
|
||||
(lambda ()
|
||||
(let (( strange-sign-line
|
||||
(let loop ((i 0))
|
||||
(if (= i 256)
|
||||
""
|
||||
(if (= i 10) ;; works with everything but line-feed
|
||||
(loop (+ i 1))
|
||||
(string-append (ascii->string i)
|
||||
(loop (+ i 1)))))))
|
||||
(read '()))
|
||||
((lambda (in-port)
|
||||
(awk (read-line in-port) (line) ()
|
||||
(#t (set! read line))))
|
||||
(make-string-input-port strange-sign-line))
|
||||
(equal? read strange-sign-line))))
|
||||
|
||||
;; --- sre-expr-test ---
|
||||
|
||||
(add-test! 'sre-expr-test-test 'awk
|
||||
(lambda ()
|
||||
(let ((read '())
|
||||
(str (string-append "ein paar testzeilen, um\n"
|
||||
"sre-expr-test zu prüfen:\n"
|
||||
"EINE ZEILE GRO/3...\n"
|
||||
"eine zeile klein...\n"
|
||||
"eine zeile mit zeichen...\n"
|
||||
"*+#'~,;:.-_<>|!§$%&/()=?\"\\[]{}\n")))
|
||||
((lambda (in-port)
|
||||
(awk (read-line in-port) (line) ()
|
||||
(("sre" "zu") (set! read (cons 'sre-zu read)))
|
||||
("eine" (set! read (cons 'eine read)))
|
||||
("EINE" (set! read (cons 'EINE read)))
|
||||
((* "3") (set! read (cons '*3 read)))
|
||||
((? "s") (set! read (cons '?s read)))
|
||||
((+ "+") (set! read (cons '++ read)))))
|
||||
(make-string-input-port str))
|
||||
;; |z6 |z5 |z4 |z3 |z2 |z1 |
|
||||
(equal? (list '++ '?s '*3 '?s '*3 'eine 'sre-zu '?s '*3 'eine 'sre-zu '?s '*3 'EINE '?s '*3 'sre-zu '?s '*3 'sre-zu)
|
||||
read))))
|
||||
(lambda ()
|
||||
(let ((read '())
|
||||
(str (string-append "ein paar testzeilen, um\n"
|
||||
"sre-expr-test zu prüfen:\n"
|
||||
"EINE ZEILE GRO/3...\n"
|
||||
"eine zeile klein...\n"
|
||||
"eine zeile mit zeichen...\n"
|
||||
"*+#'~,;:.-_<>|!§$%&/()=?\"\\[]{}\n")))
|
||||
((lambda (in-port)
|
||||
(awk (read-line in-port) (line) ()
|
||||
(("sre" "zu") (set! read (cons 'sre-zu read)))
|
||||
("eine" (set! read (cons 'eine read)))
|
||||
("EINE" (set! read (cons 'EINE read)))
|
||||
((* "3") (set! read (cons '*3 read)))
|
||||
((? "s") (set! read (cons '?s read)))
|
||||
((+ "+") (set! read (cons '++ read)))))
|
||||
(make-string-input-port str))
|
||||
;; |z6 |z5 |z4
|
||||
(equal? (list '++ '?s '*3 '?s '*3 'eine 'sre-zu '?s '*3 'eine 'sre-zu
|
||||
;; |z3 |z2 |z1 |
|
||||
'?s '*3 'EINE '?s '*3 'sre-zu '?s '*3 'sre-zu)
|
||||
read))))
|
||||
|
||||
;; --- when-test ---
|
||||
|
||||
(add-test! 'when-bool-exp-test-test 'awk
|
||||
(lambda ()
|
||||
(let ((read '())
|
||||
(str (string-append "ein paar testzeilen, um\n"
|
||||
"when-bool-expr-test zu prüfen:\n"
|
||||
"EINE ZEILE GRO/3...\n"
|
||||
"eine zeile klein...\n"
|
||||
"eine zeile mit zeichen...\n"
|
||||
"*+#'~,;:.-_<>|!§$%&/()=?\"\\[]{}\n")))
|
||||
((lambda (in-port)
|
||||
(awk (read-line in-port) (line) counter ()
|
||||
((when (= counter 1))
|
||||
(set! read (cons 'first-clause read)))
|
||||
((when (equal? line
|
||||
"when-bool-expr-test zu prüfen:"))
|
||||
(set! read (cons 'second-clause read)))
|
||||
((when (> counter 2))
|
||||
(set! read (cons 'third-clause read)))))
|
||||
(make-string-input-port str))
|
||||
(equal? read
|
||||
(list 'third-clause 'third-clause 'third-clause 'third-clause 'second-clause 'first-clause)))))
|
||||
(lambda ()
|
||||
(let ((read '())
|
||||
(str (string-append "ein paar testzeilen, um\n"
|
||||
"when-bool-expr-test zu prüfen:\n"
|
||||
"EINE ZEILE GRO/3...\n"
|
||||
"eine zeile klein...\n"
|
||||
"eine zeile mit zeichen...\n"
|
||||
"*+#'~,;:.-_<>|!§$%&/()=?\"\\[]{}\n")))
|
||||
((lambda (in-port)
|
||||
(awk (read-line in-port) (line) counter ()
|
||||
((when (= counter 1))
|
||||
(set! read (cons 'first-clause read)))
|
||||
((when (equal? line
|
||||
"when-bool-expr-test zu prüfen:"))
|
||||
(set! read (cons 'second-clause read)))
|
||||
((when (> counter 2))
|
||||
(set! read (cons 'third-clause read)))))
|
||||
(make-string-input-port str))
|
||||
(equal? read
|
||||
(list 'third-clause 'third-clause 'third-clause
|
||||
'third-clause 'second-clause 'first-clause)))))
|
||||
|
||||
;; --- expr-test-test ---
|
||||
|
||||
(add-test! 'expr-test-test 'awk
|
||||
(lambda ()
|
||||
(let ((read '())
|
||||
(str (string-append "ein paar testzeilen, um\n"
|
||||
"expr-test zu prüfen:\n"
|
||||
"EINE ZEILE GRO/3...\n"
|
||||
"eine zeile klein...\n"
|
||||
"eine zeile mit zeichen...\n"
|
||||
"*+#'~,;:.-_<>|!§$%&/()=?\"\\[]{}\n")))
|
||||
((lambda (in-port)
|
||||
(awk (read-line in-port) (line) counter ()
|
||||
("paar" (set! read (cons 'first-clause read)))
|
||||
((equal? line
|
||||
"expr-test zu prüfen:")
|
||||
(set! line (cons 'second-clause read)))
|
||||
((> counter 5)
|
||||
(set! read (cons 'third-clause read)))
|
||||
((+ "3") ;; makes problems here, but was ok in sre-xpr-test ;;FIXXX it
|
||||
(set! read (cons 'fourth-clause read)))))
|
||||
(make-string-input-port str))
|
||||
(equal? read
|
||||
(list 'third-clause 'fourth-clause 'second-clause 'first-clause)))))
|
||||
(lambda ()
|
||||
(let ((read '())
|
||||
(str (string-append "ein paar testzeilen, um\n"
|
||||
"expr-test zu prüfen:\n"
|
||||
"EINE ZEILE GRO/3...\n"
|
||||
"eine zeile klein...\n"
|
||||
"eine zeile mit zeichen...\n"
|
||||
"*+#'~,;:.-_<>|!§$%&/()=?\"\\[]{}\n")))
|
||||
((lambda (in-port)
|
||||
(awk (read-line in-port) (line) counter ()
|
||||
("paar" (set! read (cons 'first-clause read)))
|
||||
((equal? line
|
||||
"expr-test zu prüfen:")
|
||||
(set! line (cons 'second-clause read)))
|
||||
((> counter 5)
|
||||
(set! read (cons 'third-clause read)))
|
||||
((+ "3")
|
||||
;; ^^^^^ makes problems here, but was ok in sre-expr-test ;;FIXXX it
|
||||
(set! read (cons 'fourth-clause read)))))
|
||||
(make-string-input-port str))
|
||||
(equal? read
|
||||
(list 'third-clause 'fourth-clause 'second-clause 'first-clause)))))
|
||||
|
||||
;; --- several-bodys-in-clause-test ---
|
||||
;; XX to do: only for <test>s that were ok till now (int, when)
|
||||
|
||||
(add-test! 'several-bodys-in-clause-test 'awk
|
||||
(lambda ()
|
||||
(let ((read '())
|
||||
(str (string-append "ein paar testzeilen, um\n"
|
||||
"expr-test zu prüfen:\n"
|
||||
"EINE ZEILE GRO/3...\n"
|
||||
"eine zeile klein...\n"
|
||||
"eine zeile mit zeichen...\n"
|
||||
"*+#'~,;:.-_<>|!§$%&/()=?\"\\[]{}\n")))
|
||||
((lambda (in-port)
|
||||
(awk (read-line in-port) (line) counter ()
|
||||
(1 (set! read (cons 'clause-one-body-one read))
|
||||
(set! read (cons 'clause-one-body-two read))
|
||||
(set! read (cons 'clause-one-body-three read)))
|
||||
((when (equal? line
|
||||
"eine zeile klein..."))
|
||||
(set! read (cons 'clause-two-body-one read))
|
||||
(set! read (cons 'clause-two-body-two read))
|
||||
(set! read (cons 'clause-two-body-three read)))))
|
||||
(make-string-input-port str))
|
||||
(equal? read
|
||||
(list 'clause-two-body-three 'clause-two-body-two 'clause-two-body-one
|
||||
'clause-one-body-three 'clause-one-body-two 'clause-one-body-one)))))
|
||||
(lambda ()
|
||||
(let ((read '())
|
||||
(str (string-append "ein paar testzeilen, um\n"
|
||||
"expr-test zu prüfen:\n"
|
||||
"EINE ZEILE GRO/3...\n"
|
||||
"eine zeile klein...\n"
|
||||
"eine zeile mit zeichen...\n"
|
||||
"*+#'~,;:.-_<>|!§$%&/()=?\"\\[]{}\n")))
|
||||
((lambda (in-port)
|
||||
(awk (read-line in-port) (line) counter ()
|
||||
(1 (set! read (cons 'clause-one-body-one read))
|
||||
(set! read (cons 'clause-one-body-two read))
|
||||
(set! read (cons 'clause-one-body-three read)))
|
||||
((when (equal? line
|
||||
"eine zeile klein..."))
|
||||
(set! read (cons 'clause-two-body-one read))
|
||||
(set! read (cons 'clause-two-body-two read))
|
||||
(set! read (cons 'clause-two-body-three read)))))
|
||||
(make-string-input-port str))
|
||||
(equal? read
|
||||
(list 'clause-two-body-three 'clause-two-body-two 'clause-two-body-one
|
||||
'clause-one-body-three 'clause-one-body-two 'clause-one-body-one)))))
|
||||
|
||||
;; --- range-wo-begin-wo-end-test ---
|
||||
;; XX to do: only ok <test>s ... s.u.
|
||||
|
||||
(add-test! 'range-wo-begin-wo-end-test 'awk
|
||||
(lambda ()
|
||||
(let ((read '())
|
||||
(str (string-append "ein paar testzeilen, um\n"
|
||||
"expr-test zu prüfen:\n"
|
||||
"EINE ZEILE GRO/3...\n"
|
||||
"eine zeile klein...\n"
|
||||
"eine zeile mit zeichen...\n"
|
||||
"*+#'~,;:.-_<>|!§$%&/()=?\"\\[]{}\n")))
|
||||
((lambda (in-port)
|
||||
(awk (read-line in-port) (line) counter ()
|
||||
(range 1 3 (set! read (cons 'first-clause read)))
|
||||
(range (when (equal? line
|
||||
"EINE ZEILE GRO/3..."))
|
||||
(when (equal? line
|
||||
"*+#'~,;:.-_<>|!§$%&/()=?\"\\[]{}"))
|
||||
(set! read (cons 'second-clause read)))
|
||||
(range (when (equal? line
|
||||
"expr-test zu prüfen:"))
|
||||
4
|
||||
(set! read (cons 'third-clause read)))))
|
||||
(make-string-input-port str))
|
||||
(equal? read
|
||||
(list 'second-clause 'second-clause 'third-clause 'first-clause)))))
|
||||
(lambda ()
|
||||
(let ((read '())
|
||||
(str (string-append "ein paar testzeilen, um\n"
|
||||
"expr-test zu prüfen:\n"
|
||||
"EINE ZEILE GRO/3...\n"
|
||||
"eine zeile klein...\n"
|
||||
"eine zeile mit zeichen...\n"
|
||||
"*+#'~,;:.-_<>|!§$%&/()=?\"\\[]{}\n")))
|
||||
((lambda (in-port)
|
||||
(awk (read-line in-port) (line) counter ()
|
||||
(range 1 3 (set! read (cons 'first-clause read)))
|
||||
(range (when (equal? line
|
||||
"EINE ZEILE GRO/3..."))
|
||||
(when (equal? line
|
||||
"*+#'~,;:.-_<>|!§$%&/()=?\"\\[]{}"))
|
||||
(set! read (cons 'second-clause read)))
|
||||
(range (when (equal? line
|
||||
"expr-test zu prüfen:"))
|
||||
4
|
||||
(set! read (cons 'third-clause read)))))
|
||||
(make-string-input-port str))
|
||||
(equal? read
|
||||
(list 'second-clause 'second-clause 'third-clause 'first-clause)))))
|
||||
|
||||
;; --- range-w-begin-wo-end-test ---
|
||||
;; XX to do: only ok <test>s ... s.u.
|
||||
|
||||
(add-test! 'range-w-begin-wo-end-test 'awk
|
||||
(lambda ()
|
||||
(let ((read '())
|
||||
(str (string-append "ein paar testzeilen, um\n"
|
||||
"expr-test zu prüfen:\n"
|
||||
"EINE ZEILE GRO/3...\n"
|
||||
"eine zeile klein...\n"
|
||||
"eine zeile mit zeichen...\n"
|
||||
"*+#'~,;:.-_<>|!§$%&/()=?\"\\[]{}\n")))
|
||||
((lambda (in-port)
|
||||
(awk (read-line in-port) (line) counter ()
|
||||
(:range 1 3 (set! read (cons 'first-clause read)))
|
||||
(:range (when (equal? line
|
||||
"EINE ZEILE GRO/3..."))
|
||||
(when (equal? line
|
||||
"*+#'~,;:.-_<>|!§$%&/()=?\"\\[]{}"))
|
||||
(set! read (cons 'second-clause read)))
|
||||
(:range (when (equal? line
|
||||
"expr-test zu prüfen:"))
|
||||
4
|
||||
(set! read (cons 'third-clause read)))))
|
||||
(make-string-input-port str))
|
||||
(equal? read
|
||||
(list 'second-clause 'second-clause 'third-clause 'second-clause 'third-clause 'first-clause 'first-clause)))))
|
||||
(lambda ()
|
||||
(let ((read '())
|
||||
(str (string-append "ein paar testzeilen, um\n"
|
||||
"expr-test zu prüfen:\n"
|
||||
"EINE ZEILE GRO/3...\n"
|
||||
"eine zeile klein...\n"
|
||||
"eine zeile mit zeichen...\n"
|
||||
"*+#'~,;:.-_<>|!§$%&/()=?\"\\[]{}\n")))
|
||||
((lambda (in-port)
|
||||
(awk (read-line in-port) (line) counter ()
|
||||
(:range 1 3 (set! read (cons 'first-clause read)))
|
||||
(:range (when (equal? line
|
||||
"EINE ZEILE GRO/3..."))
|
||||
(when (equal? line
|
||||
"*+#'~,;:.-_<>|!§$%&/()=?\"\\[]{}"))
|
||||
(set! read (cons 'second-clause read)))
|
||||
(:range (when (equal? line
|
||||
"expr-test zu prüfen:"))
|
||||
4
|
||||
(set! read (cons 'third-clause read)))))
|
||||
(make-string-input-port str))
|
||||
(equal? read
|
||||
(list 'second-clause 'second-clause 'third-clause 'second-clause
|
||||
'third-clause 'first-clause 'first-clause)))))
|
||||
|
||||
;; --- range-wo-begin-w-end-test ---
|
||||
;; XX to do: only ok <test>s ... s.u.
|
||||
|
||||
(add-test! 'range-wo-begin-w-end-test 'awk
|
||||
(lambda ()
|
||||
(let ((read '())
|
||||
(str (string-append "ein paar testzeilen, um\n"
|
||||
"expr-test zu prüfen:\n"
|
||||
"EINE ZEILE GRO/3...\n"
|
||||
"eine zeile klein...\n"
|
||||
"eine zeile mit zeichen...\n"
|
||||
"*+#'~,;:.-_<>|!§$%&/()=?\"\\[]{}\n")))
|
||||
((lambda (in-port)
|
||||
(awk (read-line in-port) (line) counter ()
|
||||
(range: 1 3 (set! read (cons 'first-clause read)))
|
||||
(range: (when (equal? line
|
||||
"EINE ZEILE GRO/3..."))
|
||||
(when (equal? line
|
||||
"*+#'~,;:.-_<>|!§$%&/()=?\"\\[]{}"))
|
||||
(set! read (cons 'second-clause read)))
|
||||
(range: (when (equal? line
|
||||
"expr-test zu prüfen:"))
|
||||
4
|
||||
(set! read (cons 'third-clause read)))))
|
||||
(make-string-input-port str))
|
||||
(equal? read
|
||||
(list 'second-clause 'second-clause 'third-clause 'second-clause 'third-clause 'first-clause 'first-clause)))))
|
||||
(lambda ()
|
||||
(let ((read '())
|
||||
(str (string-append "ein paar testzeilen, um\n"
|
||||
"expr-test zu prüfen:\n"
|
||||
"EINE ZEILE GRO/3...\n"
|
||||
"eine zeile klein...\n"
|
||||
"eine zeile mit zeichen...\n"
|
||||
"*+#'~,;:.-_<>|!§$%&/()=?\"\\[]{}\n")))
|
||||
((lambda (in-port)
|
||||
(awk (read-line in-port) (line) counter ()
|
||||
(range: 1 3 (set! read (cons 'first-clause read)))
|
||||
(range: (when (equal? line
|
||||
"EINE ZEILE GRO/3..."))
|
||||
(when (equal? line
|
||||
"*+#'~,;:.-_<>|!§$%&/()=?\"\\[]{}"))
|
||||
(set! read (cons 'second-clause read)))
|
||||
(range: (when (equal? line
|
||||
"expr-test zu prüfen:"))
|
||||
4
|
||||
(set! read (cons 'third-clause read)))))
|
||||
(make-string-input-port str))
|
||||
(equal? read
|
||||
(list 'second-clause 'second-clause 'third-clause 'second-clause
|
||||
'third-clause 'first-clause 'first-clause)))))
|
||||
|
||||
;; --- range-w-begin-w-end-test ---
|
||||
;; XX to do: only ok <test>s ... s.u.
|
||||
|
||||
(add-test! 'range-w-begin-w-end-test 'awk
|
||||
(lambda ()
|
||||
(let ((read '())
|
||||
(str (string-append "ein paar testzeilen, um\n"
|
||||
"expr-test zu prüfen:\n"
|
||||
"EINE ZEILE GRO/3...\n"
|
||||
"eine zeile klein...\n"
|
||||
"eine zeile mit zeichen...\n"
|
||||
"*+#'~,;:.-_<>|!§$%&/()=?\"\\[]{}\n")))
|
||||
((lambda (in-port)
|
||||
(awk (read-line in-port) (line) counter ()
|
||||
(:range: 1 3 (set! read (cons 'first-clause read)))
|
||||
(:range: (when (equal? line
|
||||
"EINE ZEILE GRO/3..."))
|
||||
(when (equal? line
|
||||
"*+#'~,;:.-_<>|!§$%&/()=?\"\\[]{}"))
|
||||
(set! read (cons 'second-clause read)))
|
||||
(:range: (when (equal? line
|
||||
"expr-test zu prüfen:"))
|
||||
4
|
||||
(set! read (cons 'third-clause read)))))
|
||||
(make-string-input-port str))
|
||||
(equal? read
|
||||
(list 'second-clause 'second-clause 'third-clause 'second-clause 'third-clause
|
||||
'second-clause 'first-clause 'third-clause 'first-clause 'first-clause)))))
|
||||
(lambda ()
|
||||
(let ((read '())
|
||||
(str (string-append "ein paar testzeilen, um\n"
|
||||
"expr-test zu prüfen:\n"
|
||||
"EINE ZEILE GRO/3...\n"
|
||||
"eine zeile klein...\n"
|
||||
"eine zeile mit zeichen...\n"
|
||||
"*+#'~,;:.-_<>|!§$%&/()=?\"\\[]{}\n")))
|
||||
((lambda (in-port)
|
||||
(awk (read-line in-port) (line) counter ()
|
||||
(:range: 1 3 (set! read (cons 'first-clause read)))
|
||||
(:range: (when (equal? line
|
||||
"EINE ZEILE GRO/3..."))
|
||||
(when (equal? line
|
||||
"*+#'~,;:.-_<>|!§$%&/()=?\"\\[]{}"))
|
||||
(set! read (cons 'second-clause read)))
|
||||
(:range: (when (equal? line
|
||||
"expr-test zu prüfen:"))
|
||||
4
|
||||
(set! read (cons 'third-clause read)))))
|
||||
(make-string-input-port str))
|
||||
(equal? read
|
||||
(list 'second-clause 'second-clause 'third-clause 'second-clause 'third-clause
|
||||
'second-clause 'first-clause 'third-clause 'first-clause 'first-clause)))))
|
||||
|
||||
;; --- else-test ---
|
||||
|
||||
(add-test! 'else-test 'awk
|
||||
(lambda ()
|
||||
(let ((read '())
|
||||
(str (string-append "ein paar testzeilen, um\n"
|
||||
"expr-test zu prüfen:\n"
|
||||
"EINE ZEILE GRO/3...\n"
|
||||
"eine zeile klein...\n"
|
||||
"eine zeile mit zeichen...\n"
|
||||
"*+#'~,;:.-_<>|!§$%&/()=?\"\\[]{}\n")))
|
||||
((lambda (in-port)
|
||||
(awk (read-line in-port) (line) ()
|
||||
(1 (set! read (cons 'first-clause read)))
|
||||
(else (set! read (cons 'second-clause read)))
|
||||
(4 (set! read (cons 'third-clause read)))
|
||||
(5 (set! read (cons 'fourth-clause read)))
|
||||
(else (set! read (cons 'fifth-clause read)))))
|
||||
(make-string-input-port str))
|
||||
(equal? read
|
||||
(list 'fifth-clause 'second-clause 'fourth-clause 'second-clause 'third-clause
|
||||
'second-clause 'fifth-clause 'second-clause 'fifth-clause 'second-clause
|
||||
'fifth-clause 'first-clause)))))
|
||||
(lambda ()
|
||||
(let ((read '())
|
||||
(str (string-append "ein paar testzeilen, um\n"
|
||||
"expr-test zu prüfen:\n"
|
||||
"EINE ZEILE GRO/3...\n"
|
||||
"eine zeile klein...\n"
|
||||
"eine zeile mit zeichen...\n"
|
||||
"*+#'~,;:.-_<>|!§$%&/()=?\"\\[]{}\n")))
|
||||
((lambda (in-port)
|
||||
(awk (read-line in-port) (line) ()
|
||||
(1 (set! read (cons 'first-clause read)))
|
||||
(else (set! read (cons 'second-clause read)))
|
||||
(4 (set! read (cons 'third-clause read)))
|
||||
(5 (set! read (cons 'fourth-clause read)))
|
||||
(else (set! read (cons 'fifth-clause read)))))
|
||||
(make-string-input-port str))
|
||||
(equal? read
|
||||
(list 'fifth-clause 'second-clause 'fourth-clause 'second-clause 'third-clause
|
||||
'second-clause 'fifth-clause 'second-clause 'fifth-clause 'second-clause
|
||||
'fifth-clause 'first-clause)))))
|
||||
|
||||
|
||||
;; --- test=>expr-test ---
|
||||
|
||||
(add-test! 'test=>expr-test 'awk
|
||||
(lambda ()
|
||||
(let ((read '())
|
||||
(str (string-append "ein paar testzeilen, um\n"
|
||||
"expr-test zu prüfen:\n"
|
||||
"EINE ZEILE GRO/3...\n"
|
||||
"eine zeile klein...\n"
|
||||
"eine zeile mit zeichen...\n"
|
||||
"*+#'~,;:.-_<>|!§$%&/()=?\"\\[]{}\n")))
|
||||
((lambda (in-port)
|
||||
(awk (read-line in-port) (line) counter ()
|
||||
(counter => (lambda (c)
|
||||
(set! read (cons c read))))
|
||||
(#f => (lambda (c)
|
||||
(set! read (cons c read))))))
|
||||
(make-string-input-port str))
|
||||
(equal? read (list 6 5 4 3 2 1)))))
|
||||
(lambda ()
|
||||
(let ((read '())
|
||||
(str (string-append "ein paar testzeilen, um\n"
|
||||
"expr-test zu prüfen:\n"
|
||||
"EINE ZEILE GRO/3...\n"
|
||||
"eine zeile klein...\n"
|
||||
"eine zeile mit zeichen...\n"
|
||||
"*+#'~,;:.-_<>|!§$%&/()=?\"\\[]{}\n")))
|
||||
((lambda (in-port)
|
||||
(awk (read-line in-port) (line) counter ()
|
||||
(counter => (lambda (c)
|
||||
(set! read (cons c read))))
|
||||
(#f => (lambda (c)
|
||||
(set! read (cons c read))))))
|
||||
(make-string-input-port str))
|
||||
(equal? read (list 6 5 4 3 2 1)))))
|
||||
|
||||
|
||||
;; --- after-test ---
|
||||
|
||||
(add-test! 'after-test 'awk
|
||||
(lambda ()
|
||||
(let ((read '())
|
||||
(str (string-append "ein paar testzeilen, um\n"
|
||||
"expr-test zu prüfen:\n"
|
||||
"EINE ZEILE GRO/3...\n"
|
||||
"eine zeile klein...\n"
|
||||
"eine zeile mit zeichen...\n"
|
||||
"*+#'~,;:.-_<>|!§$%&/()=?\"\\[]{}\n")))
|
||||
(set! read
|
||||
((lambda (in-port)
|
||||
(awk (read-line in-port) (line) ()
|
||||
(1 (set! read 1))
|
||||
(2 (set! read 2))
|
||||
(after 'return)))
|
||||
(make-string-input-port str)))
|
||||
(equal? read 'return))))
|
||||
(lambda ()
|
||||
(let ((read '())
|
||||
(str (string-append "ein paar testzeilen, um\n"
|
||||
"expr-test zu prüfen:\n"
|
||||
"EINE ZEILE GRO/3...\n"
|
||||
"eine zeile klein...\n"
|
||||
"eine zeile mit zeichen...\n"
|
||||
"*+#'~,;:.-_<>|!§$%&/()=?\"\\[]{}\n")))
|
||||
(set! read
|
||||
((lambda (in-port)
|
||||
(awk (read-line in-port) (line) ()
|
||||
(1 (set! read 1))
|
||||
(2 (set! read 2))
|
||||
(after 'return)))
|
||||
(make-string-input-port str)))
|
||||
(equal? read 'return))))
|
||||
|
||||
|
||||
;; --- var-decl-test ---
|
||||
|
||||
(add-test! 'var-decl-test 'awk
|
||||
(lambda ()
|
||||
(let ((read 0)
|
||||
(str (string-append "ein paar testzeilen, um\n"
|
||||
"expr-test zu prüfen:\n"
|
||||
"EINE ZEILE GRO/3...\n"
|
||||
"eine zeile klein...\n"
|
||||
"eine zeile mit zeichen...\n"
|
||||
"*+#'~,;:.-_<>|!§$%&/()=?\"\\[]{}\n")))
|
||||
((lambda (in-port)
|
||||
(awk (read-line in-port) (line) counter ((i 0)
|
||||
(x 2)
|
||||
(y 3))
|
||||
(1 (values (+ x y) x y))
|
||||
(2 (values i (+ i y) y))
|
||||
(3 (values (* i 2) x y))
|
||||
(4 (values (- i y) x y))
|
||||
(5 (values (* i x) x y))
|
||||
(6 (set! read i)
|
||||
(values i x y))))
|
||||
(make-string-input-port str))
|
||||
(= read 56))))
|
||||
(lambda ()
|
||||
(let ((read 0)
|
||||
(str (string-append "ein paar testzeilen, um\n"
|
||||
"expr-test zu prüfen:\n"
|
||||
"EINE ZEILE GRO/3...\n"
|
||||
"eine zeile klein...\n"
|
||||
"eine zeile mit zeichen...\n"
|
||||
"*+#'~,;:.-_<>|!§$%&/()=?\"\\[]{}\n")))
|
||||
((lambda (in-port)
|
||||
(awk (read-line in-port) (line) counter ((i 0)
|
||||
(x 2)
|
||||
(y 3))
|
||||
(1 (values (+ x y) x y))
|
||||
(2 (values i (+ i y) y))
|
||||
(3 (values (* i 2) x y))
|
||||
(4 (values (- i y) x y))
|
||||
(5 (values (* i x) x y))
|
||||
(6 (set! read i)
|
||||
(values i x y))))
|
||||
(make-string-input-port str))
|
||||
(= read 56))))
|
||||
|
||||
|
||||
;; --- multiple-return-values-of-next-record-test ---
|
||||
|
||||
(add-test! 'multiple-return-values-of-next-record-test 'awk
|
||||
(lambda ()
|
||||
(let ((read '())
|
||||
(str (string-append "ein paar testzeilen, um\n"
|
||||
"expr-test zu prüfen:\n"
|
||||
"EINE ZEILE GRO/3...\n"
|
||||
"eine zeile klein...\n"
|
||||
"eine zeile mit zeichen...\n"
|
||||
"*+#'~,;:.-_<>|!§$%&/()=?\"\\[]{}\n")))
|
||||
((lambda (in-port)
|
||||
(awk ((lambda ()
|
||||
(values (read-line in-port)1 2 'a 'b))) (line x y a b) counter ()
|
||||
(1 (set! read (cons x read)))
|
||||
(2 (set! read (cons y read)))
|
||||
(3 (set! read (cons a read)))
|
||||
(4 (set! read (cons b read)))))
|
||||
(make-string-input-port str))
|
||||
(equal? read
|
||||
(list 'b 'a 2 1)))))
|
||||
(lambda ()
|
||||
(let ((read '())
|
||||
(str (string-append "ein paar testzeilen, um\n"
|
||||
"expr-test zu prüfen:\n"
|
||||
"EINE ZEILE GRO/3...\n"
|
||||
"eine zeile klein...\n"
|
||||
"eine zeile mit zeichen...\n"
|
||||
"*+#'~,;:.-_<>|!§$%&/()=?\"\\[]{}\n")))
|
||||
((lambda (in-port)
|
||||
(awk ((lambda ()
|
||||
(values (read-line in-port)1 2 'a 'b))) (line x y a b) counter ()
|
||||
(1 (set! read (cons x read)))
|
||||
(2 (set! read (cons y read)))
|
||||
(3 (set! read (cons a read)))
|
||||
(4 (set! read (cons b read)))))
|
||||
(make-string-input-port str))
|
||||
(equal? read
|
||||
(list 'b 'a 2 1)))))
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
;;; Test for the bug reports from user- and hacker-archives
|
||||
;;; Author: Christoph Hetz
|
||||
|
||||
;; for testing: (certainly the path will be an other on other systems...)
|
||||
|
||||
;; ,open define-record-types handle
|
||||
;; ,config ,load C:/cygwin/home/mephisto/cvs-scsh/scsh/scsh/test/test-packages.scm
|
||||
;; ,load C:/cygwin/home/mephisto/cvs-scsh/scsh/scsh/test/test-base.scm
|
||||
;; load this file
|
||||
;; (test-all)
|
||||
|
||||
(add-test! '2002-05-86-regexp-weirdness 'archive-users
|
||||
(lambda ()
|
||||
(let ((x (rx "{ OK=#t }")))
|
||||
(and (not (regexp-search? x "foo"))
|
||||
(regexp-search? x "...{ OK=#t }...")))))
|
||||
|
||||
(add-test! '2003-12-74-select-ports-with-zero-timeout 'archive-users
|
||||
(lambda ()
|
||||
(select-ports 0 (current-input-port))))
|
|
@ -14,188 +14,186 @@
|
|||
;; *** tests ***
|
||||
|
||||
(add-test! 'file-name-directory? 'file-name-manipulation
|
||||
(lambda ()
|
||||
(and (not (file-name-directory? "src/des"))
|
||||
(file-name-directory? "src/des/")
|
||||
(file-name-directory? "/")
|
||||
(not (file-name-directory? "."))
|
||||
(file-name-directory? ""))))
|
||||
(lambda ()
|
||||
(and (not (file-name-directory? "src/des"))
|
||||
(file-name-directory? "src/des/")
|
||||
(file-name-directory? "/")
|
||||
(not (file-name-directory? "."))
|
||||
(file-name-directory? ""))))
|
||||
|
||||
(add-test! 'file-name-non-directory? 'file-name-manipulation
|
||||
(lambda ()
|
||||
(and (file-name-non-directory? "src/des")
|
||||
(not (file-name-non-directory? "src/des/"))
|
||||
(not (file-name-non-directory? "/"))
|
||||
(file-name-non-directory? ".")
|
||||
(file-name-non-directory? ""))))
|
||||
(lambda ()
|
||||
(and (file-name-non-directory? "src/des")
|
||||
(not (file-name-non-directory? "src/des/"))
|
||||
(not (file-name-non-directory? "/"))
|
||||
(file-name-non-directory? ".")
|
||||
(file-name-non-directory? ""))))
|
||||
|
||||
(add-test! 'file-name-as-directory 'file-name-manipulation
|
||||
(lambda ()
|
||||
(and (equal? "src/des/"
|
||||
(file-name-as-directory "src/des"))
|
||||
(equal? "src/des/"
|
||||
(file-name-as-directory "src/des/"))
|
||||
(equal? ""
|
||||
(file-name-as-directory "."))
|
||||
(equal? "/"
|
||||
(file-name-as-directory "/"))
|
||||
(equal? "/"
|
||||
(file-name-as-directory "")))))
|
||||
(lambda ()
|
||||
(and (equal? "src/des/"
|
||||
(file-name-as-directory "src/des"))
|
||||
(equal? "src/des/"
|
||||
(file-name-as-directory "src/des/"))
|
||||
(equal? ""
|
||||
(file-name-as-directory "."))
|
||||
(equal? "/"
|
||||
(file-name-as-directory "/"))
|
||||
(equal? "/"
|
||||
(file-name-as-directory "")))))
|
||||
|
||||
(add-test! 'directory-as-file-name 'file-name-manipulation
|
||||
(lambda ()
|
||||
(and (equal? "foo/bar"
|
||||
(directory-as-file-name "foo/bar/"))
|
||||
(equal? "foo/bar"
|
||||
(directory-as-file-name "foo/bar"))
|
||||
(equal? "/"
|
||||
(directory-as-file-name "/"))
|
||||
(equal? "."
|
||||
(directory-as-file-name "")))))
|
||||
(lambda ()
|
||||
(and (equal? "foo/bar"
|
||||
(directory-as-file-name "foo/bar/"))
|
||||
(equal? "foo/bar"
|
||||
(directory-as-file-name "foo/bar"))
|
||||
(equal? "/"
|
||||
(directory-as-file-name "/"))
|
||||
(equal? "."
|
||||
(directory-as-file-name "")))))
|
||||
|
||||
(add-test! 'file-name-absolute? 'file-name-manipulation
|
||||
(lambda ()
|
||||
(and (file-name-absolute? "/usr/shievers")
|
||||
(not (file-name-absolute? "src/des"))
|
||||
(file-name-absolute? "/src/des")
|
||||
(file-name-absolute? ""))))
|
||||
(lambda ()
|
||||
(and (file-name-absolute? "/usr/shievers")
|
||||
(not (file-name-absolute? "src/des"))
|
||||
(file-name-absolute? "/src/des")
|
||||
(file-name-absolute? ""))))
|
||||
|
||||
(add-test! 'file-name-directory 'file-name-manipuation
|
||||
(lambda ()
|
||||
(and (equal? "/usr/"
|
||||
(file-name-directory "/usr/bcd"))
|
||||
(equal? "/usr/bcd/"
|
||||
(file-name-directory "/usr/bcd/"))
|
||||
(equal? "bdc/"
|
||||
(file-name-directory "bdc/.login"))
|
||||
(equal? ""
|
||||
(file-name-directory "main.c"))
|
||||
(equal? ""
|
||||
(file-name-directory "/"))
|
||||
(equal? ""
|
||||
(file-name-directory "")))))
|
||||
(lambda ()
|
||||
(and (equal? "/usr/"
|
||||
(file-name-directory "/usr/bcd"))
|
||||
(equal? "/usr/bcd/"
|
||||
(file-name-directory "/usr/bcd/"))
|
||||
(equal? "bdc/"
|
||||
(file-name-directory "bdc/.login"))
|
||||
(equal? ""
|
||||
(file-name-directory "main.c"))
|
||||
(equal? ""
|
||||
(file-name-directory "/"))
|
||||
(equal? ""
|
||||
(file-name-directory "")))))
|
||||
|
||||
(add-test! 'file-name-nondirectory 'file-name-manipulation
|
||||
(lambda ()
|
||||
(and (equal? "ian"
|
||||
(file-name-nondirectory "/usr/ian"))
|
||||
(equal? ""
|
||||
(file-name-nondirectory "/usr/ian/"))
|
||||
(equal? ".login"
|
||||
(file-name-nondirectory "ian/.login"))
|
||||
(equal? "main.c"
|
||||
(file-name-nondirectory "main.c"))
|
||||
(equal? ""
|
||||
(file-name-nondirectory ""))
|
||||
(equal? "/"
|
||||
(file-name-nondirectory "/")))))
|
||||
(lambda ()
|
||||
(and (equal? "ian"
|
||||
(file-name-nondirectory "/usr/ian"))
|
||||
(equal? ""
|
||||
(file-name-nondirectory "/usr/ian/"))
|
||||
(equal? ".login"
|
||||
(file-name-nondirectory "ian/.login"))
|
||||
(equal? "main.c"
|
||||
(file-name-nondirectory "main.c"))
|
||||
(equal? ""
|
||||
(file-name-nondirectory ""))
|
||||
(equal? "/"
|
||||
(file-name-nondirectory "/")))))
|
||||
|
||||
(add-test! 'split-file-name 'file-name-manipulation
|
||||
(lambda ()
|
||||
(and (equal? '("src" "des" "main.c")
|
||||
(split-file-name "src/des/main.c"))
|
||||
(equal? '("" "src" "des" "main.c")
|
||||
(split-file-name "/src/des/main.c"))
|
||||
(equal? '("main.c")
|
||||
(split-file-name "main.c"))
|
||||
(equal? '("")
|
||||
(split-file-name "/")))))
|
||||
(lambda ()
|
||||
(and (equal? '("src" "des" "main.c")
|
||||
(split-file-name "src/des/main.c"))
|
||||
(equal? '("" "src" "des" "main.c")
|
||||
(split-file-name "/src/des/main.c"))
|
||||
(equal? '("main.c")
|
||||
(split-file-name "main.c"))
|
||||
(equal? '("")
|
||||
(split-file-name "/")))))
|
||||
|
||||
(add-test! 'path-list->file-name 'file-name-manipulation
|
||||
(lambda ()
|
||||
(and (equal? "src/des/main.c"
|
||||
(path-list->file-name '("src" "des" "main.c")))
|
||||
(equal? "/src/des/main.c"
|
||||
(path-list->file-name '("" "src" "des" "main.c")))
|
||||
(equal? "/usr/shivers/src/des/main.c"
|
||||
(path-list->file-name '("src" "des" "main.c")
|
||||
"/usr/shivers")))))
|
||||
(lambda ()
|
||||
(and (equal? "src/des/main.c"
|
||||
(path-list->file-name '("src" "des" "main.c")))
|
||||
(equal? "/src/des/main.c"
|
||||
(path-list->file-name '("" "src" "des" "main.c")))
|
||||
(equal? "/usr/shivers/src/des/main.c"
|
||||
(path-list->file-name '("src" "des" "main.c")
|
||||
"/usr/shivers")))))
|
||||
|
||||
(add-test! 'file-name-extension 'file-name-manipulation
|
||||
(lambda ()
|
||||
(and (equal? ".c"
|
||||
(file-name-extension "main.c"))
|
||||
(equal? ".old"
|
||||
(file-name-extension "main.c.old"))
|
||||
(equal? ""
|
||||
(file-name-extension "/usr/shivers"))
|
||||
(equal? "."
|
||||
(file-name-extension "foo."))
|
||||
(equal? "."
|
||||
(file-name-extension "foo.."))
|
||||
(equal? ""
|
||||
(file-name-extension "/usr/shivers/.login")))))
|
||||
(lambda ()
|
||||
(and (equal? ".c"
|
||||
(file-name-extension "main.c"))
|
||||
(equal? ".old"
|
||||
(file-name-extension "main.c.old"))
|
||||
(equal? ""
|
||||
(file-name-extension "/usr/shivers"))
|
||||
(equal? "."
|
||||
(file-name-extension "foo."))
|
||||
(equal? "."
|
||||
(file-name-extension "foo.."))
|
||||
(equal? ""
|
||||
(file-name-extension "/usr/shivers/.login")))))
|
||||
|
||||
(add-test! 'file-name-sans-extension 'file-name-manipulation
|
||||
(lambda ()
|
||||
(and (equal? "main"
|
||||
(file-name-sans-extension "main.c"))
|
||||
(equal? "main.c"
|
||||
(file-name-sans-extension "main.c.old"))
|
||||
(equal? "/usr/shivers"
|
||||
(file-name-sans-extension "/usr/shivers"))
|
||||
(equal? "foo"
|
||||
(file-name-sans-extension "foo."))
|
||||
(equal? "foo."
|
||||
(file-name-sans-extension "foo.."))
|
||||
(equal? "/usr/shivers/.login"
|
||||
(file-name-sans-extension "/usr/shivers/.login")))))
|
||||
(lambda ()
|
||||
(and (equal? "main"
|
||||
(file-name-sans-extension "main.c"))
|
||||
(equal? "main.c"
|
||||
(file-name-sans-extension "main.c.old"))
|
||||
(equal? "/usr/shivers"
|
||||
(file-name-sans-extension "/usr/shivers"))
|
||||
(equal? "foo"
|
||||
(file-name-sans-extension "foo."))
|
||||
(equal? "foo."
|
||||
(file-name-sans-extension "foo.."))
|
||||
(equal? "/usr/shivers/.login"
|
||||
(file-name-sans-extension "/usr/shivers/.login")))))
|
||||
|
||||
(add-test! 'parse-file-name 'file-name-manipulation
|
||||
(lambda ()
|
||||
(let* ((fname "/usr/shivers/main.c")
|
||||
(f (file-name-nondirectory fname)))
|
||||
(equal? (list (file-name-directory fname)
|
||||
(file-name-sans-extension f)
|
||||
(file-name-extension f))
|
||||
(call-with-values
|
||||
(lambda ()
|
||||
(parse-file-name fname))
|
||||
(lambda (a b c)
|
||||
(list a b c)))))))
|
||||
(lambda ()
|
||||
(let* ((fname "/usr/shivers/main.c")
|
||||
(f (file-name-nondirectory fname)))
|
||||
(equal? (list (file-name-directory fname)
|
||||
(file-name-sans-extension f)
|
||||
(file-name-extension f))
|
||||
(call-with-values
|
||||
(lambda ()
|
||||
(parse-file-name fname))
|
||||
(lambda (a b c)
|
||||
(list a b c)))))))
|
||||
|
||||
(add-test! 'replace-extension 'file-name-manipulation
|
||||
(lambda ()
|
||||
(let ((fname "/usr/shivers/main.c")
|
||||
(ext "old"))
|
||||
(equal? (string-append (file-name-sans-extension fname) ext)
|
||||
(replace-extension fname ext)))))
|
||||
(lambda ()
|
||||
(let ((fname "/usr/shivers/main.c")
|
||||
(ext "old"))
|
||||
(equal? (string-append (file-name-sans-extension fname) ext)
|
||||
(replace-extension fname ext)))))
|
||||
|
||||
(add-test! 'simplify-file-name 'file-name-manipulation
|
||||
(lambda ()
|
||||
(and (equal? "/usr/shivers"
|
||||
(simplify-file-name "/usr/shivers"))
|
||||
(equal? "/usr/shivers"
|
||||
(simplify-file-name "////usr//shivers/"))
|
||||
(equal? "/usr/shivers/."
|
||||
(simplify-file-name "////usr/shivers/."))
|
||||
(equal? "//usr/shivers"
|
||||
(simplify-file-name "//usr/shivers/"))
|
||||
(equal? "/usr/shivers/../test"
|
||||
(simplify-file-name "////usr/shivers/../test/")))))
|
||||
|
||||
;; XX todo:
|
||||
(lambda ()
|
||||
(and (equal? "/usr/shivers"
|
||||
(simplify-file-name "/usr/shivers"))
|
||||
(equal? "/usr/shivers"
|
||||
(simplify-file-name "////usr//shivers/"))
|
||||
(equal? "/usr/shivers/."
|
||||
(simplify-file-name "////usr/shivers/."))
|
||||
(equal? "//usr/shivers"
|
||||
(simplify-file-name "//usr/shivers/"))
|
||||
(equal? "/usr/shivers/../test"
|
||||
(simplify-file-name "////usr/shivers/../test/")))))
|
||||
|
||||
(add-test! 'resolve-file-name 'file-name-manipulation
|
||||
(lambda ()
|
||||
(and (equal? (resolve-file-name "~")
|
||||
(home-dir))
|
||||
(string? (resolve-file-name "~/c/main.c" "/usr/bin")))))
|
||||
(lambda ()
|
||||
(and (equal? (resolve-file-name "~")
|
||||
(home-dir))
|
||||
(string? (resolve-file-name "~/c/main.c" "/usr/bin")))))
|
||||
|
||||
(add-test! 'expand-file-name 'file-name-manipulation
|
||||
(lambda ()
|
||||
(equal? (expand-file-name "~/..///c/bin/main.out" "/usr/bin")
|
||||
(simplify-file-name (resolve-file-name "~/..///c/bin/main.out" "/usr/bin")))))
|
||||
(lambda ()
|
||||
(equal? (expand-file-name "~/..///c/bin/main.out" "/usr/bin")
|
||||
(simplify-file-name (resolve-file-name "~/..///c/bin/main.out" "/usr/bin")))))
|
||||
|
||||
(add-test! 'absolute-file-name 'file-name-manipulation
|
||||
(lambda ()
|
||||
(equal? (absolute-file-name "~/c/bin/c.out" "/usr/local")
|
||||
"/usr/local/~/c/bin/c.out")))
|
||||
(lambda ()
|
||||
(equal? (absolute-file-name "~/c/bin/c.out" "/usr/local")
|
||||
"/usr/local/~/c/bin/c.out")))
|
||||
|
||||
;;(add-test! 'home-dir 'file-name-manipulation
|
||||
;; was tested with resolve-file-name
|
||||
|
||||
(add-test! 'home-file 'file-name-manipulation
|
||||
(lambda ()
|
||||
(equal? (home-file "man")
|
||||
(resolve-file-name "~/man"))))
|
||||
(lambda ()
|
||||
(equal? (home-file "man")
|
||||
(resolve-file-name "~/man"))))
|
|
@ -43,7 +43,8 @@
|
|||
(string-append (list->string (list (ascii->char i)))
|
||||
(loop (+ i 1))))))
|
||||
|
||||
(define test-string "Dieser Test-String wurde am 29.07.2004 um 5:23PM erstellt.\na aa aaa aaaa\nab aabb aaabbb\naba abba abbba\n1 12 123 1234\nyyyyyyyyyy\n")
|
||||
(define test-string
|
||||
"Dieser Test-String wurde am 29.07.2004 um 5:23PM erstellt.\na aa aaa aaaa\nab aabb aaabbb\naba abba abbba\n1 12 123 1234\nyyyyyyyyyy\n")
|
||||
|
||||
|
||||
;; *** tests ***
|
||||
|
@ -103,18 +104,31 @@
|
|||
|
||||
|
||||
;XXX something is wrong with this
|
||||
;(add-test! 're-vs-@re-submatch-test 'pattern-matching
|
||||
; (lambda ()
|
||||
; (let* ((f (lambda ()
|
||||
; (rx (submatch "sub-f1")
|
||||
; (submatch "sub-f2"))))
|
||||
; (re (rx (submatch (* "foo"))
|
||||
; (submatch (? "bar"))
|
||||
; ,(f)
|
||||
; (submatch "baz")))
|
||||
; (match1 (string-match ,re "foofoobarsub-f1sub-f2baz"))
|
||||
; (match2 (string-match ,@re "foofoobarsub-f1sub-f2baz")))
|
||||
; (and (...)))))
|
||||
(add-test! 're-vs-@re-submatch-test 'pattern-matching
|
||||
(lambda ()
|
||||
(let* ((f (lambda ()
|
||||
(rx (submatch "sub-f1")
|
||||
(submatch "sub-f2"))))
|
||||
(re (rx (submatch (* "foo"))
|
||||
(submatch (? "bar"))
|
||||
,(f)
|
||||
(submatch "baz")))
|
||||
(re-@ (rx (submatch (* "foo"))
|
||||
(submatch (? "bar"))
|
||||
,@(f)
|
||||
(submatch "baz")))
|
||||
(match1 (string-match re "foofoobarsub-f1sub-f2baz"))
|
||||
(match2 (string-match re-@ "foofoobarsub-f1sub-f2baz")))
|
||||
(and match1
|
||||
match2
|
||||
(equal? "baz"
|
||||
(match:substring match1 3))
|
||||
(equal? "sub-f1"
|
||||
(match:substring match2 3))
|
||||
(equal? "sub-f2"
|
||||
(match:substring match2 4))
|
||||
(equal? "baz"
|
||||
(match:substring match2 5))))))
|
||||
|
||||
(add-test! 'posix-string-test 'pattern-matching
|
||||
(lambda ()
|
||||
|
|
|
@ -265,4 +265,11 @@
|
|||
ttyl/visual-delete-line
|
||||
ttyl/alt-delete-word
|
||||
ttyl/no-kernel-status
|
||||
ttyl/case-map)))))
|
||||
ttyl/case-map)))))
|
||||
|
||||
(add-test! 'open-pty-test 'terminal-device-control
|
||||
(lambda ()
|
||||
(receive (pty-inport tty-name) (open-pty)
|
||||
(and (tty? pty-inport)
|
||||
(equal? tty-name (tty-file-name pty-inport))))))
|
||||
|
|
@ -12,35 +12,36 @@
|
|||
;; *** tests ***
|
||||
|
||||
(add-test! 'time-ticks 'time
|
||||
(lambda ()
|
||||
(call-with-values
|
||||
(lambda ()
|
||||
(time+ticks))
|
||||
(lambda (tme tcks)
|
||||
(and (number? tme)
|
||||
(number? tcks))))))
|
||||
(lambda ()
|
||||
(call-with-values
|
||||
(lambda ()
|
||||
(time+ticks))
|
||||
(lambda (tme tcks)
|
||||
(and (number? tme)
|
||||
(number? tcks))))))
|
||||
|
||||
(add-test! 'ticks/sec 'time
|
||||
(lambda ()
|
||||
(real? (ticks/sec))))
|
||||
(lambda ()
|
||||
(real? (ticks/sec))))
|
||||
|
||||
(add-test! 'date 'time
|
||||
(lambda ()
|
||||
(date? (date))))
|
||||
(lambda ()
|
||||
(date? (date))))
|
||||
|
||||
(add-test! 'time 'time
|
||||
(lambda ()
|
||||
(integer? (time))))
|
||||
(lambda ()
|
||||
(integer? (time))))
|
||||
|
||||
(add-test! 'date->string 'time
|
||||
(lambda ()
|
||||
(string? (date->string (date)))))
|
||||
(lambda ()
|
||||
(string? (date->string (date)))))
|
||||
|
||||
(add-test! 'format-date 'time
|
||||
(lambda ()
|
||||
(string? (format-date "~a ~A ~b ~B ~c ~d ~H ~I ~j ~m ~M ~p ~S ~U ~w ~W ~x ~X ~y ~Y ~Z" (date)))))
|
||||
(lambda ()
|
||||
(string? (format-date "~a ~A ~b ~B ~c ~d ~H ~I ~j ~m ~M ~p ~S ~U ~w ~W ~x ~X ~y ~Y ~Z"
|
||||
(date)))))
|
||||
|
||||
;;; fill-in-date! seems to be not implemented yet.
|
||||
;;; fill-in-date! is not implemented yet.
|
||||
;(add-test! 'fill-in-date! 'time
|
||||
; (lambda ()
|
||||
; (date? (fill-in-date! (date)))))
|
||||
|
|
|
@ -12,25 +12,25 @@
|
|||
;; *** tests ***
|
||||
|
||||
(add-test! 'user-info 'user-and-group-db-access
|
||||
(lambda ()
|
||||
(let* ((user-0 (user-info (getenv "USER")))
|
||||
(user-name (user-info:name user-0))
|
||||
(user-id (user-info:uid user-0))
|
||||
(user-gid (user-info:gid user-0))
|
||||
(user-hdir (user-info:home-dir user-0))
|
||||
(user-shell (user-info:shell user-0))
|
||||
(group-0 (group-info user-gid))
|
||||
(group-name (group-info:name group-0))
|
||||
(group-id (group-info:gid group-0))
|
||||
(group-mem (group-info:members group-0)))
|
||||
(and (string? user-name)
|
||||
(integer? user-id)
|
||||
(integer? user-gid)
|
||||
(string? user-hdir)
|
||||
(string? user-shell)
|
||||
(string? group-name)
|
||||
(integer? group-id)
|
||||
(list? group-mem)
|
||||
(equal? user-name (user-info:name (user-info user-id)))
|
||||
(equal? (user-info (getenv "USER")) (user-info:name (user-info user-id)))
|
||||
(equal? group-id (group-info:gid (group-info group-name)))))))
|
||||
(lambda ()
|
||||
(let* ((user-0 (user-info (getenv "USER")))
|
||||
(user-name (user-info:name user-0))
|
||||
(user-id (user-info:uid user-0))
|
||||
(user-gid (user-info:gid user-0))
|
||||
(user-hdir (user-info:home-dir user-0))
|
||||
(user-shell (user-info:shell user-0))
|
||||
(group-0 (group-info user-gid))
|
||||
(group-name (group-info:name group-0))
|
||||
(group-id (group-info:gid group-0))
|
||||
(group-mem (group-info:members group-0)))
|
||||
(and (string? user-name)
|
||||
(integer? user-id)
|
||||
(integer? user-gid)
|
||||
(string? user-hdir)
|
||||
(string? user-shell)
|
||||
(string? group-name)
|
||||
(integer? group-id)
|
||||
(list? group-mem)
|
||||
(equal? user-name (user-info:name (user-info user-id)))
|
||||
(equal? (user-info (getenv "USER")) (user-info:name (user-info user-id)))
|
||||
(equal? group-id (group-info:gid (group-info group-name)))))))
|
Loading…
Reference in New Issue