Fork me on GitHub
#yamlscript
<
2023-10-03
>
Ingy döt Net20:10:28

A ton of work on the YS ecosystem has happened over the last month, but not much useful to show yet. Today I reached a big milestone in that I got the simplest test form to go through all 7 stages of compilation 🙂 This is the compiler flow https://github.com/yaml/yamlscript/blob/clojure/clojure/src/yamlscript/compiler.clj#L22-L28

Ingy döt Net20:10:43

One thing I added to the python binding is the compile method which returns the Clojure code value of the YS input

$ python3 -c 'import yamlscript; print(yamlscript.compile("inc: 41"))'
(inc 41)

$ python3 -c 'import yamlscript; print(yamlscript.load("inc: 41"))'
42

Ingy döt Net20:10:56

Also all the compilation phases have tests now. They are defined here: https://github.com/yaml/yamlscript/blob/clojure/clojure/test/data.yaml

Ingy döt Net20:10:35

I have a pretty cool way of turning that one file into unit tests for each stage of compilation. For example to test the resolver stage I have this file: https://github.com/yaml/yamlscript/blob/clojure/clojure/test/yamlscript/resolver_test.clj

Ingy döt Net20:10:19

Here's the output of a test run:

$ TEST_VERBOSE=1 make test
lein test

lein test yamlscript.builder-test
* test-3: Basic function call with 2 args (test all phases)

lein test yamlscript.compiler-test
* test-3: Basic function call with 2 args (test all phases)

lein test yamlscript.composer-test
* test-3: Basic function call with 2 args (test all phases)
* test-1: Most YAML syntax forms in one example

lein test yamlscript.constructor-test
* test-3: Basic function call with 2 args (test all phases)

lein test yamlscript.core-test
* test-3: Basic function call with 2 args (test all phases)

lein test yamlscript.expander-test
* test-3: Basic function call with 2 args (test all phases)

lein test yamlscript.parser-test
* test-3: Basic function call with 2 args (test all phases)
* test-1: Most YAML syntax forms in one example
* test-2: Nested parse events test

lein test yamlscript.printer-test
* test-3: Basic function call with 2 args (test all phases)

lein test yamlscript.resolver-test
* test-3: Basic function call with 2 args (test all phases)

Ran 12 tests containing 12 assertions.
0 failures, 0 errors.

🎉 2