Debian Codegraph @

test/macros.fnl

raw
1 ;; this module is loaded by the test suite.
2
3 (fn def [] (error "oh no") 32)
4 (fn abc [] (def) 1)
5
6 {"->1" (fn [val ...]
7 (var x val)
8 (each [_ elt (ipairs [...])]
9 (table.insert elt 2 x)
10 (set x elt))
11 x)
12 :defn1 (fn [name args ...]
13 (assert (sym? name) "defn1: function names must be symbols")
14 `(global ,name (fn ,args ,...)))
15 :inc (fn [n] "Increments n by 1"
16 (if (not (list? n)) `(+ ,n 1)
17 `(let [num# ,n] (+ num# 1))))
18 :inc! (fn [a ?n] `(set ,a (+ ,a ,(or ?n 1))))
19 :multigensym (fn []
20 `(let [x# {:abc (fn [] 518)}
21 y# {:one 1}]
22 (+ (x#:abc) y#.one)))
23 :unsandboxed (fn [] (view [:no :sandbox]))
24 :fail-one (fn [x] (when (= x 1) (abc)) true)
25 :gensym-shadow (fn []
26 (let [g (gensym)]
27 `(let [,g (let [,g 1] 2)]
28 ,g)))}