Skip to content

Commit 999e6c5

Browse files
committed
feat(testing): disallow nesting of test suites
1 parent 1c51061 commit 999e6c5

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

Testing.ark

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# internal, do not use
22
(let _make_suite (fun (name) {
3+
(mut active false)
34
(mut passed 0)
45
(mut failed 0)
56
(mut failures [])
@@ -33,6 +34,9 @@
3334
(let need_case? (fun ()
3435
(and (not (empty? case_desc)) (!= case_pointer (len cases)))))
3536

37+
(let set_active (fun (bool)
38+
(set active bool)))
39+
3640
(fun (
3741
&name
3842
&passed
@@ -49,19 +53,23 @@
4953
&add_case
5054
&pop_case
5155
&update_case_ptr
52-
&need_case?)
56+
&need_case?
57+
&active
58+
&set_active)
5359
()) }))
5460

5561
# internal, do not use
5662
(mut _suite nil)
5763

5864
# internal, do not use
5965
(let _runner (fun (_name _callable) {
66+
(_suite.set_active true)
6067
(let _start_time (time))
6168

6269
# run test
6370
(_callable)
6471
(let _end_time (time))
72+
(_suite.set_active false)
6573

6674
# no newline, yet
6775
(puts _name)
@@ -238,6 +246,7 @@
238246
# =end
239247
# @author https://github.com/SuperFola
240248
(macro test:suite (_name _body) {
249+
(assert (or (nil? testing:_suite) (not testing:_suite.active)) "Can not nest multiple test suites together!")
241250
(set testing:_suite (testing:_make_suite ($repr _name)))
242251

243252
(let ($symcat _name "-output") (testing:_runner

0 commit comments

Comments
 (0)