forked from pixie-lang/pixie
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-readeval.pxi
More file actions
65 lines (58 loc) · 2.54 KB
/
test-readeval.pxi
File metadata and controls
65 lines (58 loc) · 2.54 KB
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
(ns pixie.tests.test-readeval
(require pixie.test :as t))
(t/deftest test-read
(t/assert= (read-string "0xDEADBEEF") 3735928559)
(t/assert= (read-string "0xDeadBeef") 3735928559)
(t/assert= (read-string "0xdeadbeef") 3735928559)
(t/assert= (read-string "foo") 'foo)
(t/assert= (read-string "()") '())
(t/assert= (read-string "(1 2 3)") '(1 2 3))
(t/assert= (read-string "[1 2 3]") [1 2 3])
(t/assert= (read-string "{:a 1 :b 2 :c 3}") {:a 1 :b 2 :c 3})
(t/assert= (read-string "\"foo\"") "foo")
(t/assert= (read-string "\"fo\\\\o\"") "fo\\o")
(t/assert= (read-string "false") false)
(t/assert= (read-string "true") true)
(t/assert= (read-string "#{1 2 3}") #{1 2 3})
(t/assert= (read-string "(foo (bar (baz)))") '(foo (bar (baz)))))
(t/deftest test-list-unclosed-list-fail
(t/assert-throws? RuntimeException
"Unmatched list open '('"
(read-string "("))
(t/assert-throws? RuntimeException
"Unmatched list open '('"
(read-string "((foo bar)")))
(t/deftest test-vector-unclosed-list-fail
(t/assert-throws? RuntimeException
"Unmatched vector open '['"
(read-string "["))
(t/assert-throws? RuntimeException
"Unmatched vector open '['"
(read-string "[[foo bar]")))
(t/deftest test-map-unclosed-list-fail
(t/assert-throws? RuntimeException
"Unmatched map open '{'"
(read-string "{"))
(t/assert-throws? RuntimeException
"Unmatched map open '{'"
(read-string "{foo {a b}")))
(t/deftest test-set-unclosed-list-fail
(t/assert-throws? RuntimeException
"Unmatched set open '#{'"
(read-string "#{"))
(t/assert-throws? RuntimeException
"Unmatched set open '#{'"
(read-string "#{foo #{a}")))
(t/deftest test-string-unclosed-fail
(t/assert-throws? RuntimeException
"Unmatched string quote '\"'"
(read-string "\""))
(t/assert-throws? RuntimeException
"Unmatched string quote '\"'"
(read-string "\"foo")))
(t/deftest test-comments-in-forms
(t/assert= (read-string "(foo ; a comment\n )") '(foo))
(t/assert= (read-string "[foo ; a comment\n ]") '[foo])
(t/assert= (read-string "{:foo :bar ; a comment\n }") '{:foo :bar})
(t/assert= (read-string "#{:foo ; a comment\n }") '#{:foo})
(t/assert= (read-string "{:foo ; a comment\n :bar }") '{:foo :bar}))