80 lines
1.8 KiB
Plaintext
80 lines
1.8 KiB
Plaintext
;; Function To Be Tested: string
|
|
;;
|
|
;; Source: CLtL p.
|
|
;; Chapter 18: Strings Section 3: String Construction and Manipulation
|
|
;;
|
|
;; Created By: Peter Reidy
|
|
;;
|
|
;; Creation Date: 23 July 86
|
|
;;
|
|
;; Last Update: 14 December 86
|
|
;;
|
|
;; Filed As: {eris}<lispcore>cml>test>18-3-string.test
|
|
;;
|
|
;;
|
|
;; Syntax: string x
|
|
;;
|
|
;; Function Description: makes a string of x if x is an appropriate object; signals an error otherwise.
|
|
;;
|
|
;; Argument(s): x - a string, a symbol or a character
|
|
;;
|
|
;; Returns: - if x is a string: x
|
|
;; - if x is a symbol: the printname of x
|
|
;; - if x is a character: a 1-character string consisting of the character
|
|
;;
|
|
(do-test-group string-group
|
|
:before
|
|
(test-setq
|
|
longstring "23 July 86
|
|
;;
|
|
;; Filed As: {eris}<lispcore>cml>test>18-3-string.test
|
|
;;
|
|
;;
|
|
;; Syntax: string x
|
|
;;
|
|
;; Function Description: makes a string of x if x is an appropriate object; signals an error otherwise.
|
|
;;
|
|
" ; END LONGSTRING DEFINITION
|
|
oddstring (coerce '(#\3 #\- #\page) 'string)
|
|
) ; test-setq
|
|
;;
|
|
(do-test "string returns itself if its argument is a string"
|
|
(every
|
|
#'(lambda (string)
|
|
(and
|
|
(string= string (string string))
|
|
(eq string (string string))
|
|
)
|
|
)
|
|
;; NOTE: not working 14 12; eq doesn't hold. See AR 7066.
|
|
(list
|
|
longstring
|
|
oddstring
|
|
(make-array 5 :element-type 'string-char :initial-element #\1)
|
|
(make-string 30)
|
|
)
|
|
)
|
|
)
|
|
;;
|
|
(do-test "string returns the symbol-name of a symbol"
|
|
(every
|
|
#'(lambda (string)
|
|
(string=
|
|
(symbol-name string)
|
|
(string string)
|
|
)
|
|
)
|
|
'(sym \1 |This is a symbol.| nil)
|
|
)
|
|
)
|
|
;;
|
|
(do-test "string returns a string if x is a character"
|
|
(and
|
|
(string= "1" (string #\1 #\2))
|
|
(string= (string #\page) (make-string 1 :initial-element #\page))
|
|
)
|
|
)
|
|
)
|
|
STOP
|
|
|