Commit 588fd307 authored by pfdietz's avatar pfdietz
Browse files

Begin adding tests for set-syntax-from-char

parent bdcdff90
......@@ -17,6 +17,7 @@
(load "get-macro-character.lsp")
(load "set-macro-character.lsp")
(load "read-suppress.lsp")
(load "set-syntax-from-char.lsp")
(load "syntax.lsp")
(load "syntax-tokens.lsp")
;-*- Mode: Lisp -*-
;;;; Author: Paul Dietz
;;;; Created: Sat Jan 29 06:37:18 2005
;;;; Contains: Tests of SET-SYNTAX-FROM-CHAR
(in-package :cl-test)
(compile-and-load "reader-aux.lsp")
(defmacro def-set-syntax-from-char-test (name form &body expected-values)
`(deftest ,name
(let ((*readtable* (copy-readtable nil)))
(setf (readtable-case *readtable*) :preserve)
;;; Test that constituent traits are not altered when a constituent character
;;; syntax type is set
(defmacro def-set-syntax-from-char-trait-test (c test-form expected-value)
(setq c (typecase c
(character c)
((or string symbol) (name-char (string c)))
(t nil)))
(when c
(format t "~A ~A~%" c (char-name c))
,(intern (concatenate 'string "SET-SYNTAX-FROM-CHAR-TRAIT-X-" (or (char-name c)
(string c)))
(let ((c ,c))
(set-syntax-from-char c #\X)
t ,expected-value)))
(defmacro def-set-syntax-from-char-alphabetic-trait-test (c)
`(def-set-syntax-from-char-trait-test ,c
(let* ((*package* (find-package "CL-TEST"))
(sym (read-from-string (string c))))
(list (let ((sym2 (find-symbol (string c))))
(or (eqt sym sym2)
(list sym sym2)))
(or (equalt (symbol-name sym) (string c))
(list (symbol-name sym) (string c)))))
(t t)))
(loop for c across "!\"#$%&'()*,;<=>?@[]^_`~{}+-/abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
do (eval `(def-set-syntax-from-char-alphabetic-trait-test ,c)))
(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
(let* ((*package* (find-package "CL-TEST"))
(sym (read-from-string (concatenate 'string (string c) "Z"))))
(multiple-value-list (eval form)))
(loop for name in '("Backspace" "Tab" "Newline" "Linefeed" "Page" "Return" "Space" "Rubout")
do (eval `(def-set-syntax-from-char-invalid-trait-test ,name)))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment