| 1 | ;; Testing read of nil/true/false |
| 2 | nil |
| 3 | ;=>nil |
| 4 | true |
| 5 | ;=>true |
| 6 | false |
| 7 | ;=>false |
| 8 | |
| 9 | |
| 10 | ;; Testing read of numbers |
| 11 | 1 |
| 12 | ;=>1 |
| 13 | 7 |
| 14 | ;=>7 |
| 15 | 7 |
| 16 | ;=>7 |
| 17 | |
| 18 | |
| 19 | ;; Testing read of symbols |
| 20 | + |
| 21 | ;=>+ |
| 22 | abc |
| 23 | ;=>abc |
| 24 | abc |
| 25 | ;=>abc |
| 26 | abc5 |
| 27 | ;=>abc5 |
| 28 | abc-def |
| 29 | ;=>abc-def |
| 30 | |
| 31 | |
| 32 | ;; Testing read of strings |
| 33 | "abc" |
| 34 | ;=>"abc" |
| 35 | "abc" |
| 36 | ;=>"abc" |
| 37 | "abc (with parens)" |
| 38 | ;=>"abc (with parens)" |
| 39 | "abc\"def" |
| 40 | ;=>"abc\"def" |
| 41 | ;;;"abc\ndef" |
| 42 | ;;;;=>"abc\ndef" |
| 43 | "" |
| 44 | ;=>"" |
| 45 | |
| 46 | |
| 47 | ;; Testing read of lists |
| 48 | (+ 1 2) |
| 49 | ;=>(+ 1 2) |
| 50 | ((3 4)) |
| 51 | ;=>((3 4)) |
| 52 | (+ 1 (+ 2 3)) |
| 53 | ;=>(+ 1 (+ 2 3)) |
| 54 | ( + 1 (+ 2 3 ) ) |
| 55 | ;=>(+ 1 (+ 2 3)) |
| 56 | (* 1 2) |
| 57 | ;=>(* 1 2) |
| 58 | (** 1 2) |
| 59 | ;=>(** 1 2) |
| 60 | |
| 61 | ;; Test commas as whitespace |
| 62 | (1 2, 3,,,,),, |
| 63 | ;=>(1 2 3) |
| 64 | |
| 65 | ;; Testing read of quoting |
| 66 | '1 |
| 67 | ;=>(quote 1) |
| 68 | '(1 2 3) |
| 69 | ;=>(quote (1 2 3)) |
| 70 | `1 |
| 71 | ;=>(quasiquote 1) |
| 72 | `(1 2 3) |
| 73 | ;=>(quasiquote (1 2 3)) |
| 74 | ~1 |
| 75 | ;=>(unquote 1) |
| 76 | ~(1 2 3) |
| 77 | ;=>(unquote (1 2 3)) |
| 78 | ~@(1 2 3) |
| 79 | ;=>(splice-unquote (1 2 3)) |
| 80 | |
| 81 | ;; |
| 82 | ;; Testing reader errors |
| 83 | ;;; TODO: fix these so they fail correctly |
| 84 | (1 2 |
| 85 | ; expected ')', got EOF |
| 86 | [1 2 |
| 87 | ; expected ']', got EOF |
| 88 | "abc |
| 89 | ; expected '"', got EOF |
| 90 | |
| 91 | ;; |
| 92 | ;; -------- Optional Functionality -------- |
| 93 | |
| 94 | ;; Testing keywords |
| 95 | :kw |
| 96 | ;=>:kw |
| 97 | (:kw1 :kw2 :kw3) |
| 98 | ;=>(:kw1 :kw2 :kw3) |
| 99 | |
| 100 | ;; Testing read of vectors |
| 101 | [+ 1 2] |
| 102 | ;=>[+ 1 2] |
| 103 | [[3 4]] |
| 104 | ;=>[[3 4]] |
| 105 | [+ 1 [+ 2 3]] |
| 106 | ;=>[+ 1 [+ 2 3]] |
| 107 | [ + 1 [+ 2 3 ] ] |
| 108 | ;=>[+ 1 [+ 2 3]] |
| 109 | |
| 110 | ;; Testing read of hash maps |
| 111 | {"abc" 1} |
| 112 | ;=>{"abc" 1} |
| 113 | {"a" {"b" 2}} |
| 114 | ;=>{"a" {"b" 2}} |
| 115 | {"a" {"b" {"c" 3}}} |
| 116 | ;=>{"a" {"b" {"c" 3}}} |
| 117 | { "a" {"b" { "cde" 3 } }} |
| 118 | ;=>{"a" {"b" {"cde" 3}}} |
| 119 | { :a {:b { :cde 3 } }} |
| 120 | ;=>{:a {:b {:cde 3}}} |
| 121 | |
| 122 | ;; Testing read of comments |
| 123 | ;; whole line comment (not an exception) |
| 124 | 1 ; comment after expression |
| 125 | ;=>1 |
| 126 | 1; comment after expression |
| 127 | ;=>1 |
| 128 | |
| 129 | ;; Testing read of ^/metadata |
| 130 | ^{"a" 1} [1 2 3] |
| 131 | ;=>(with-meta [1 2 3] {"a" 1}) |
| 132 | |
| 133 | |
| 134 | ;; Testing read of @/deref |
| 135 | @a |
| 136 | ;=>(deref a) |