0.8.6.14:
[sbcl/lichteblau.git] / tests / character.pure.lisp
blob97a2590e7a0cab918e1b3954567c3e6b93e12d3c
1 ;;;; various CHARACTER tests without side effects
3 ;;;; This software is part of the SBCL system. See the README file for
4 ;;;; more information.
5 ;;;;
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
8 ;;;; from CMU CL.
9 ;;;;
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.
17 ;;;
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.)
25 ("Space" 32)
26 ("Tab" 9)
27 ("Page" 12)
28 ("Rubout" 127)
29 ("Return" 13)
30 ("Backspace" 8)))
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 ;;; bug 230: CHAR= didn't check types of &REST arguments
40 (dolist (form '((code-char char-code-limit)
41 (standard-char-p "a")
42 (graphic-char-p "a")
43 (alpha-char-p "a")
44 (upper-case-p "a")
45 (lower-case-p "a")
46 (both-case-p "a")
47 (digit-char-p "a")
48 (alphanumericp "a")
49 (char= #\a "a")
50 (char/= #\a "a")
51 (char< #\a #\b "c")
52 (char-equal #\a #\a "b")
53 (digit-char -1)
54 (digit-char 4 1)
55 (digit-char 4 37)))
56 (assert (raises-error? (apply (car form) (mapcar 'eval (cdr form))) type-error)))