Skip to content

Commit

Permalink
!32 Improve test_all and listdir
Browse files Browse the repository at this point in the history
  • Loading branch information
da-liii committed Aug 9, 2024
1 parent d3141e7 commit 43d0f79
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 15 deletions.
5 changes: 4 additions & 1 deletion goldfish/liii/list.scm
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
(export list-view
take drop take-right drop-right count fold fold-right reduce reduce-right
filter partition remove find delete take-while drop-while list-index last-pair
last)
last flatmap)
(import (srfi srfi-1))
(begin

Expand All @@ -35,6 +35,9 @@
"list-view only accepts even number of args"))))
f-inner)

(define (flatmap f seq)
(fold-right append () (map f seq)))

) ; end of begin
) ; end of library

6 changes: 6 additions & 0 deletions src/goldfish.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,12 @@ f_listdir (s7_scheme* sc, s7_pointer args) {
vector<string> entries;
s7_pointer ret= s7_make_vector (sc, 0);
tb_directory_walk (path_c, 0, tb_false, tb_directory_walk_func, &entries);

int entries_N= entries.size ();
int path_N = string (path_c).size ();
for (int i= 0; i < entries_N; i++) {
entries[i]= entries[i].substr (path_N + 1);
}
return string_vector_to_s7_vector (sc, entries);
}

Expand Down
3 changes: 0 additions & 3 deletions tests/liii/string-test.scm
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,4 @@
(import (liii check)
(liii error))

(check (mk-string " " (list 1 2 3)) => "1 2 3")
(check (mk-string " " (list )) => "")

(check-report)
24 changes: 13 additions & 11 deletions tests/test_all.scm
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,22 @@
; under the License.
;

(import (liii os)
(import (liii list)
(liii string)
(liii os)
(srfi srfi-1))

(define (listdir2 dir)
(map (lambda (x) (string-append dir "/" x))
(vector->list (listdir dir))))

; (display (listdir2 "tests"))
(define (all-tests)
(list
"tests/scheme/boot-test.scm"
"tests/scheme/case-lambda-test.scm"
"tests/scheme/process-context-test.scm"
"tests/srfi/srfi-8-test.scm"
"tests/srfi/srfi-9-test.scm"
"tests/srfi/srfi-16-test.scm"
"tests/srfi/srfi-39-test.scm"
"tests/liii/os-test.scm"
"tests/liii/uuid-test.scm"))
(((apply list-view (listdir2 "tests"))
filter isdir
flatmap listdir2
filter (lambda (x) (not (isdir x)))
filter (lambda (x) (not (string-suffix? "srfi-78-test.scm" x))))))

(define (goldfish-cmd)
(if (os-windows?)
Expand Down

0 comments on commit 43d0f79

Please sign in to comment.