It's not backwards compatible. Hence me trying to get feedback before pushing the 1.0.
The specific backwards incompatibility (I assume you got "We can't parse this as a suite body") is moving from this format for the tests:
(suite suite-name
test-name (test-body))
to the format you suggested last year:
(suite suite-name
(test test-name (test-body)))
I don't think supporting both ways of writing tests is useful. I'm also planning on migrating the anarki tests when I roll out the 1.0. Actually, I could get started on a branch even before. That'd be something to do.
If you start doing some of the migration work, push the in-progress stuff to a branch and I'll help work on it. I'll do the same if I get to it before you. Thanks.
This must be the most fun thing on my radar right now, because I got to it first thing this morning :)
; translate.arc
(def translate (expr)
(accum acc
(translate-2 expr acc)))
(def translate-2 (expr acc)
(if (atom expr)
(acc expr)
(is car.expr 'suite)
(do (acc 'suite)
(let (suite-name . suite-body) cdr.expr
(acc suite-name)
(translate-suite-body suite-body acc)))
(is car.expr 'suite-w/setup)
(do (acc 'suite-w/setup)
(let (suite-name suite-setup . suite-body) cdr.expr
(acc suite-name)
(acc suite-setup)
(translate-suite-body suite-body acc)))
'else
(map acc expr)))
(def translate-suite-body (suite-body acc)
(if suite-body
(if (acons car.suite-body)
; nested suite
(let (nested-suite . rest) suite-body
(acc (accum acc2
(translate-2 nested-suite acc2)))
(translate-suite-body rest acc))
; test name must be atomic
(let (test-name test-body . rest) suite-body
(acc `(test ,test-name ,test-body))
(translate-suite-body rest acc)))))
; bootstrap tests for a test harness :)
; suite with tests
(assert:iso '(suite a (test t1 b1) (test t2 b2))
(translate '(suite a t1 b1 t2 b2)))
; suite with tests and nested suites
(assert:iso '(suite a (test t1 b1) (suite s2 (test t3 b3)) (test t2 b2))
(translate '(suite a t1 b1 (suite s2 t3 b3) t2 b2)))
; suite with setup and tests
(assert:iso '(suite-w/setup a (x 1 y 2) (test t1 b1) (test t2 b2))
(translate '(suite-w/setup a (x 1 y 2) t1 b1 t2 b2)))
; suite with setup and tests and nested suites
(assert:iso '(suite-w/setup a (x 1 y 2) (test t1 b1) (suite s2 (test t3 b3)) (test t2 b2))
(translate '(suite-w/setup a (x 1 y 2) t1 b1 (suite s2 t3 b3) t2 b2)))
; run
(each f cdr.argv
(prn f)
(fromfile string.f
(tofile (+ string.f ".2")
(each expr (drain:read)
(let out translate.expr
(ppr out))))))
Run it like so:
$ arc translate.arc *.t lib/*.t lib/tests/*
I haven't committed it anywhere yet because I'm not too happy with the state of Anarki's pretty-printer. Would you mind if I change the indentation style for suites and tests in Anarki? I was thinking something like this: