commit 587c88e
Devie Lu Linvega
·
2025-12-23 19:28:54 +0000 UTC
parent fd86518
Improved file tests
3 files changed,
+31,
-28
+27,
-24
1@@ -7,60 +7,63 @@
2
3 @on-reset ( -> )
4 #800f DEO
5- file/test-create test/<print>
6- file/test-append test/<print>
7- file/test-load test/<print>
8- file/test-stat test/<print>
9- file/test-delete test/<print>
10+ ;dict/create file/test-create <test>
11+ ;dict/append file/test-append <test>
12+ ;dict/load file/test-load <test>
13+ ;dict/stat file/test-stat <test>
14+ ;dict/delete file/test-delete <test>
15 BRK
16
17+(
18+@|Tests )
19+
20 @file/test-create ( -- pass )
21- ;dict/create str/<print>
22- ;file/name .File/name DEO2
23+ ;&name .File/name DEO2
24 #0002 .File/length DEO2
25- ;file/a1 .File/write DEO2
26+ ;&a1 .File/write DEO2
27 .File/success DEI2 #0002 EQU2 JMP2r
28
29 @file/test-append ( -- pass )
30- ;dict/append str/<print>
31- ;file/name .File/name DEO2
32+ ;&name .File/name DEO2
33 #0002 .File/length DEO2
34 #01 .File/append DEO
35- ;file/b1 .File/write DEO2
36+ ;&b1 .File/write DEO2
37 .File/success DEI2 #0002 EQU2 JMP2r
38
39 @file/test-load ( -- pass )
40- ;dict/load str/<print>
41 ;&name .File/name DEO2
42 ( 4+2 ) #0006 .File/length DEO2
43 ;&load-buf .File/read DEO2
44 ( success ) .File/success DEI2 #0004 EQU2
45- ( a ) ;file/a1 LDA2 ;file/a2 LDA2 EQU2 AND
46- ( b ) ;file/b1 LDA2 ;file/b2 LDA2 EQU2 AND JMP2r
47+ ( a ) ;&a1 LDA2 ;&a2 LDA2 EQU2 AND
48+ ( b ) ;&b1 LDA2 ;&b2 LDA2 EQU2 AND JMP2r
49
50 @file/test-stat ( -- pass )
51- ;dict/stat str/<print>
52 ;&name .File/name DEO2
53 #0004 .File/length DEO2
54- ;file/stat-buf .File/stat DEO2
55+ ;&stat-buf .File/stat DEO2
56 ( success ) .File/success DEI2 #0004 EQU2
57- ( a ) ;file/stat-hs LDA2 LIT2 "00 EQU2 AND
58- ( b ) ;file/stat-ls LDA2 LIT2 "04 EQU2 AND JMP2r
59+ ( a ) ;&stat-hs LDA2 LIT2 "00 EQU2 AND
60+ ( b ) ;&stat-ls LDA2 LIT2 "04 EQU2 AND JMP2r
61 JMP2r
62
63 @file/test-delete ( -- pass )
64- ;dict/delete str/<print>
65 ;&name .File/name DEO2
66 #01 .File/delete DEO
67 .File/success DEI2 #0001 EQU2
68 ( | stat )
69 ;&name .File/name DEO2
70 #0002 .File/length DEO2
71- ;file/null-buf .File/stat DEO2
72- ;file/null-buf LDA2 LIT2 "!! EQU2 AND JMP2r
73+ ;&null-buf .File/stat DEO2
74+ ;&null-buf LDA2 LIT2 "!! EQU2 AND JMP2r
75+
76+(
77+@|Helpers )
78
79-@test/<print> ( pass -- )
80- ?{ #010f DEO ;dict/fail !str/<print> }
81+@<test> ( name* f -- )
82+ ?{ &fail str/<print>
83+ #010f DEO
84+ ;dict/fail !str/<print> } &pass str/<print>
85 ;dict/pass
86 ( >> )
87
88@@ -70,7 +73,7 @@
89 INC2 !/<print>
90
91 (
92-@|Data )
93+@|Assets )
94
95 @dict/create "File/create: 20 $1
96 &append "File/append: 20 $1
+2,
-2
1@@ -928,8 +928,8 @@ static unsigned int
2 file_delete(unsigned int id)
3 {
4 if(file_not_ready(id))
5- return -1;
6- return unlink(ufs[id].filepath);
7+ return 0;
8+ return !unlink(ufs[id].filepath);
9 }
10
11 static void
+2,
-2
1@@ -588,8 +588,8 @@ static unsigned int
2 file_delete(unsigned int id)
3 {
4 if(file_not_ready(id))
5- return -1;
6- return unlink(ufs[id].filepath);
7+ return 0;
8+ return !unlink(ufs[id].filepath);
9 }
10
11 static void