Skip to content

Commit a24e382

Browse files
committed
feat(macros): adding tests for unless and until macros
1 parent 78a6038 commit a24e382

File tree

2 files changed

+33
-10
lines changed

2 files changed

+33
-10
lines changed

Macros.ark

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@
5858
($ all_args (__replace_placeholders [arg_bloc] ...args))
5959
(fun (arg_bloc) (call all_args)) })
6060

61-
($ unless (cond body)
62-
(if (not cond) body))
61+
($ unless (cond ...body)
62+
(if (not cond) ...body))
6363

6464
($ until (cond body)
6565
(while (not cond) body))

tests/macros-tests.ark

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,34 @@
1616
(let test_func3 (partial2 test_func 1 _ 3))
1717

1818
(test:suite macros {
19-
(test:eq (-> "f0" f1) "f0-f1")
20-
(test:eq (-> "f0" f1 f2 f3) "f0-f1-f2-f3")
21-
(test:eq (-> "f0" f1 (apply _ f2) (apply _ f3)) "f0-f1-f2-f3")
22-
23-
(test:eq (test_func1 2 3) 6)
24-
(test:eq ($argcount test_func1) 2)
25-
(test:eq ($argcount test_func2) 1)
26-
(test:eq (test_func3 2) 6) })
19+
(test:case "->" {
20+
(test:eq (-> "f0" f1) "f0-f1")
21+
(test:eq (-> "f0" f1 f2 f3) "f0-f1-f2-f3")
22+
(test:eq (-> "f0" f1 (apply _ f2) (apply _ f3)) "f0-f1-f2-f3") })
23+
24+
(test:case "partial & partial2" {
25+
(test:eq (test_func1 2 3) 6)
26+
(test:eq ($argcount test_func1) 2)
27+
(test:eq ($argcount test_func2) 1)
28+
(test:eq (test_func3 2) 6) })
29+
30+
(test:case "unless" {
31+
(unless false
32+
(test:expect true "unless true worked")
33+
(test:expect false "this shouldn't trigger"))
34+
35+
(unless (= "abracadabra" (f1 "f0"))
36+
(test:expect true)
37+
(test:expect false "this shouldn't trigger"))
38+
39+
(unless true
40+
(test:expect true "unless with one argument")) })
41+
42+
(test:case "until" {
43+
(mut i 0)
44+
(until (= i 10) {
45+
(set i (+ 1 i)) })
46+
(test:eq i 10)
47+
48+
(until true
49+
(test:expect false "this shouldn't trigger")) })})

0 commit comments

Comments
 (0)