Skip to content

Commit

Permalink
- fix infinite loop
Browse files Browse the repository at this point in the history
- add tests
  • Loading branch information
rakista112 committed Jul 30, 2021
1 parent 533b383 commit 8cdf827
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion List.ark
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@
(mut _index 0)
(mut _output [])
(mut continue true)
(while continue
(while (and (< _index (len _L)) continue)
(if (_f (@ _L _index))
{
(set _output (append _output (@ _L _index)))
Expand Down
5 changes: 5 additions & 0 deletions tests/list-tests.ark
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@
(set tests (assert-eq (list:take a 1) [1] "take" tests))
(set tests (assert-eq (list:take a 100) a "take" tests))

(set tests (assert-eq (list:takeWhile a (fun (c) (< c 0))) [] "takeWhile" tests))
(set tests (assert-eq (list:takeWhile a (fun (c) (< c 2))) [1] "takeWhile" tests))
(set tests (assert-eq (list:takeWhile a (fun (c) (< c 3))) [1 2] "takeWhile" tests))
(set tests (assert-eq (list:takeWhile a (fun (c) (< c 5))) [1 2 3] "takeWhile" tests))

(set tests (assert-eq (list:unzip zipped) [[1 2 3 4] [5 6 7 8]] "unzip" tests))
(set tests (assert-eq (list:unzip []) [[] []] "unzip" tests))

Expand Down

0 comments on commit 8cdf827

Please sign in to comment.