This repository has been archived by the owner on Jan 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
057sym.test
77 lines (57 loc) · 1.72 KB
/
057sym.test
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
(test "sym works with one arg"
:valueof (sym "abc")
:should be 'abc)
(test "sym works on empty string"
:valueof (sym "")
:should be_false)
(test "sym works with multiple args"
:valueof (string+sym "abc" 42 :def) # keyword retains colon
:should be "abc42:def")
(test "keyword? works"
:valueof (keyword? 'abc)
:should be_false)
(test "keyword? works - 2"
:valueof (keyword? :abc)
:should be_true)
(test "sym converts keywords"
:valueof (sym :abc)
:should be 'abc) # keyword loses colon
(test "< works with syms"
:valueof (< "a" 'b)
:should be_true)
(test "< treats false as a special-case"
:valueof (< false "g")
:should be_false)
(test "sort works on lists of syms"
:valueof (sort (< car) '((b 1) (c 2) (a 3)))
:should be '((a 3) (b 1) (c 2)))
(test "match? treats any sym beginning with _ as wildcard"
:valueof (match? '(1 ... _x) '(1 2 3))
:should be_true)
(test "match? manages _sym identity"
:valueof (match? '(1 _x _x) '(1 2 3))
:should be_false)
(test "match? manages _sym identity - 2"
:valueof (match? '(1 _x _x) '(1 2 2))
:should be_true)
(test "match? matches $vars with their root"
:valueof (match? 'a_ 'a3)
:should be_true)
(test "match? matches $vars with their root - 2"
:valueof (match? 'a_ 'a)
:should be_false)
(test "match? manages $var_sym identity"
:valueof (match? '(a_x a_x) '(a3 a3))
:should be_true)
(test "match? manages $var_sym identity - 2"
:valueof (match? '(a_x a_x) '(a2 a3))
:should be_false)
(test "match? manages $var_sym identity - 3"
:valueof (match? '(a_x a_x) '(a a3))
:should be_false)
(test "match integrates with test"
:valueof (list 'a3 'a3)
:should match '(a_x a_x))
(test "root works"
:valueof (root 'a3)
:should be 'a)