Skip to content

Commit 0e6c362

Browse files
committed
feat: adding new file Macros.ark with threading macro and partial macro
1 parent 707d8c2 commit 0e6c362

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

tests/all.ark

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ Standard library
1616
(import "functional-tests.ark")
1717
(import "lazy-tests.ark")
1818
(import "list-tests.ark")
19+
(import "macros-tests.ark")
20+
(import "math-tests.ark")
1921
(import "range-tests.ark")
2022
(import "string-tests.ark")
2123
(import "switch-tests.ark")
22-
(import "math-tests.ark")
2324

2425
(print " ------------------------------")
2526

@@ -29,10 +30,11 @@ Standard library
2930
passed-functional
3031
passed-lazy
3132
passed-list
33+
passed-macros
34+
passed-math
3235
passed-range
3336
passed-string
3437
passed-switch
35-
passed-math
3638
))
3739

3840
(print "Completed in " (* 1000 (- (time) start_time)) "ms")

tests/macros-tests.ark

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
(import "tests-tools.ark")
2+
3+
(import "Macros.ark")
4+
5+
(let macros-tests (fun () {
6+
(mut tests 0)
7+
(let start-time (time))
8+
9+
(let f1 (fun (data)
10+
(+ data "-f1")))
11+
(let f2 (fun (data)
12+
(+ data "-f2")))
13+
(let f3 (fun (data)
14+
(+ data "-f3")))
15+
16+
(set tests (assert-eq (-> "f0" f1) "f0-f1" "Threading macro threaded the given functions" tests))
17+
(set tests (assert-eq (-> "f0" f1 f2 f3) "f0-f1-f2-f3" "Threading macro threaded the given functions" tests))
18+
19+
(let test_func (fun (a b c) (* a b c)))
20+
(let test_func1 (partial test_func 1))
21+
(let test_func2 (partial test_func1 2))
22+
23+
(set tests (assert-eq (test_func1 2 3) 6 "Partial macro created a partial callable function" tests))
24+
(set tests (assert-eq (argcount test_func1) 2 "Argcount of the partial function should be 2" tests))
25+
(set tests (assert-eq (argcount test_func2) 1 "Argcount of the partial function should be 1" tests))
26+
27+
(recap "Macros tests passed" tests (- (time) start-time))
28+
29+
tests
30+
}))
31+
32+
(let passed-macros (macros-tests))

0 commit comments

Comments
 (0)