-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathtest.ol
35 lines (28 loc) · 1.06 KB
/
test.ol
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
(require (fs "fs")
(compiler "./compiler")
(reader "./reader")
(boot "./boot/compiler")
(util "util")
(js "./backends/js"))
(if (< process.argv.length 3)
(throw "must pass a filename"))
(let ((filename (vector-ref process.argv 2)))
(let ((src (fs.readFileSync (str "tests/" filename)
"utf-8"))
(gen (js))
;; if we're testing syntax, use the last version of the stable
;; compiler to compile the source code. the code will import the
;; current compiler and using `read` will compare the results
(comp (if (= filename "syntax.ol")
boot
compiler))
;; just kidding, always use the current compiler
(comp compiler))
;; if dumping to an external file, need to write the runtime
(gen.write-runtime "js")
(comp.set-macro-generator gen)
(let ((s (reader.read src))
(f (comp.expand s)))
(comp.compile f gen)
;;(println (gen.get-code))
((%raw "eval") (gen.get-code)))))