1 ;;;; various CHARACTER tests without side effects
3 ;;;; This software is part of the SBCL system. See the README file for
6 ;;;; While most of SBCL is derived from the CMU CL system, the test
7 ;;;; files (like this one) were written from scratch after the fork
10 ;;;; This software is in the public domain and is provided with
11 ;;;; absolutely no warranty. See the COPYING and CREDITS files for
12 ;;;; more information.
14 (cl:in-package :cl-user)
16 ;;; ANSI's specification of #'CHAR-NAME imposes these constraints.
18 ;;; (Obviously, the numeric values in this test implicitly assume
19 ;;; we're using an ASCII-based character set.)
20 (dolist (i '(("Newline" 10)
21 ;; (ANSI also imposes a constraint on the "semi-standard
22 ;; character" "Linefeed", but in ASCII as interpreted by
23 ;; Unix it's shadowed by "Newline" and so doesn't exist
24 ;; as a separate character.)
31 (destructuring-bind (name code) i
32 (let ((named-char (name-char name))
33 (coded-char (code-char code)))
34 (assert (eql named-char coded-char))
35 (assert (characterp named-char))
36 (let ((coded-char-name (char-name coded-char)))
37 (assert (string= name coded-char-name))))))
39 ;;; Trivial tests for some unicode names
41 (dolist (d '(("LATIN_CAPITAL_LETTER_A" 65)
42 ("LATIN_SMALL_LETTER_A" 97)
43 ("LATIN_SMALL_LETTER_CLOSED_OPEN_E" 666)
44 ("DIGRAM_FOR_GREATER_YIN" 9871)))
45 (destructuring-bind (name code) d
46 (assert (eql (code-char code) (name-char (string-downcase name))))
47 (assert (equal name (char-name (code-char code))))))
49 ;;; bug 230: CHAR= didn't check types of &REST arguments
50 (dolist (form '((code-char char-code-limit)
62 (char-equal #\a #\a "b")
66 (assert (raises-error? (apply (car form) (mapcar 'eval (cdr form))) type-error)))
69 (let* ((char (code-char i))
70 (graphicp (graphic-char-p char))
71 (name (char-name char)))
75 (assert (null (name-char 'foo)))
77 ;;; Between 1.0.4.53 and 1.0.4.69 character untagging was broken on
78 ;;; x86-64 if the result of the VOP was allocated on the stack, failing
79 ;;; an aver in the compiler.
80 (with-test (:name :character-untagging)
82 '(lambda (c0 c1 c2 c3 c4 c5 c6 c7
83 c8 c9 ca cb cc cd ce cf)
84 (declare (type character c0 c1 c2 c3 c4 c5 c6 c7
85 c8 c9 ca cb cc cd ce cf))
86 (char< c0 c1 c2 c3 c4 c5 c6 c7
87 c8 c9 ca cb cc cd ce cf))))