Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Karsten Poeck
ansi-test
Commits
ebddc774
Commit
ebddc774
authored
Jan 30, 2005
by
pfdietz
Browse files
Add tests for setting syntax to single or multiple escape
parent
588fd307
Changes
1
Show whitespace changes
Inline
Side-by-side
ansi-tests/set-syntax-from-char.lsp
View file @
ebddc774
...
...
@@ -46,21 +46,63 @@
(list (symbol-name sym) (string c)))))
(t t)))
(loop for c across "!\"#$%&'()*,;<=>?@[]^_`~{}+-/abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
(loop for c across "
\\|
!\"#$%&'()*,;<=>?@[]^_`~{}+-/abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
do (eval `(def-set-syntax-from-char-alphabetic-trait-test ,c)))
;;; The invalid constituent character trait of invalid and whitespace characters
;;; is exposed when they are turned into constituent characters
(defmacro def-set-syntax-from-char-invalid-trait-test (c)
`(def-set-syntax-from-char-trait-test ,c
(
let ((form (subst c 'c '(signals-error
(
handler-case
(let* ((*package* (find-package "CL-TEST"))
(sym (read-from-string (concatenate 'string (string c) "Z"))))
sym)
reader-error))))
(multiple-value-list (eval form)))
(t)))
(reader-error (c) (declare (ignore c)) :good))
:good))
(loop for name in '("Backspace" "Tab" "Newline" "Linefeed" "Page" "Return" "Space" "Rubout")
do (eval `(def-set-syntax-from-char-invalid-trait-test ,name)))
;;; Turning characters into single escape characters
(deftest set-syntax-from-char.single-escape
(loop for c across +standard-chars+
nconc
(with-standard-io-syntax
(let ((*readtable* (copy-readtable nil))
(*package* (find-package "CL-TEST")))
(setf (readtable-case *readtable*) :preserve)
(let ((results
(list
(set-syntax-from-char c #\\)
(read-from-string (concatenate 'string (list c #\Z))))))
(unless (equal results '(t |Z|))
(list c results))))))
nil)
(deftest set-syntax-from-char.multiple-escape.1
(loop for c across +standard-chars+
nconc
(with-standard-io-syntax
(let ((*readtable* (copy-readtable nil))
(*package* (find-package "CL-TEST")))
(setf (readtable-case *readtable*) :preserve)
(let ((results
(list
(set-syntax-from-char c #\|)
(handler-case
(read-from-string (concatenate 'string (list c #\Z c)))
(error (c) c))
(handler-case
(read-from-string (concatenate 'string (list c #\Z #\|)))
(error (c) c))
(handler-case
(read-from-string (concatenate 'string (list #\| #\Z c)))
(error (c) c)))))
(unless (or (eql c #\Z) (equal results '(t |Z| |Z| |Z|)))
(list c results))))))
nil)
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment