-
Notifications
You must be signed in to change notification settings - Fork 4
/
symbol-test.ss
44 lines (34 loc) · 1.41 KB
/
symbol-test.ss
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#lang scheme/base
(require "symbol.ss"
"test-base.ss")
; Tests ------------------------------------------
(define/provide-test-suite symbol-tests
(test-case "symbol+false?"
(check-false (symbol+false? "dave") "string")
(check-true (symbol+false? #f) "false")
(check-true (symbol+false? 'dave) "symbol"))
(test-case "gensym/interned"
(let ([sym1 (gensym)]
[sym2 (gensym/interned)]
[sym3 (gensym/interned 'x)])
(check-false (equal? sym1 (string->symbol (symbol->string sym1))) "uninterned")
(check-true (equal? sym2 (string->symbol (symbol->string sym2))) "interned")
(check-true (and (regexp-match #rx"g[0-9]+" (symbol->string sym2)) #t) "format with default base")
(check-true (and (regexp-match #rx"x[0-9]+" (symbol->string sym3)) #t) "format with alternative base")))
(test-equal? "symbol-append"
(symbol-append 'a- 'b- 'c)
'a-b-c)
(test-case "symbol-length"
(check-equal? (symbol-length 'abc) 3)
(check-equal? (symbol-length '||) 0))
(test-equal? "symbol-upcase"
(symbol-upcase 'aBcDe12345)
'ABCDE12345)
(test-equal? "symbol-downcase"
(symbol-downcase 'aBcDe12345)
'abcde12345)
(test-case "reprovided identifiers from convert.ss"
(for-each (lambda (proc)
(check-pred procedure? proc))
(list number+false->symbol+false
symbol+false->number+false))))