about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2019-01-06 21:58:11 -0800
committerKartik Agaram <vc@akkartik.com>2019-01-06 21:58:11 -0800
commita4df80db2bfaf9c5d98e10b4b35f240b71ddc4c0 (patch)
tree1e896e03908951bdc21c01354f845786f1b1a52b
parentaff782c4293e0c471505743575a1a0683a7ed096 (diff)
downloadmu-a4df80db2bfaf9c5d98e10b4b35f240b71ddc4c0.tar.gz
4912
-rw-r--r--subx/068read-line.subx120
1 files changed, 117 insertions, 3 deletions
diff --git a/subx/068read-line.subx b/subx/068read-line.subx
index 5e35ce3c..b73958f5 100644
--- a/subx/068read-line.subx
+++ b/subx/068read-line.subx
@@ -134,6 +134,13 @@ test-read-line:
     e8/call  clear-stream/disp32
     # . . discard args
     81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add to ESP
+    # . clear-stream(_test-stream-buffer)
+    # . . push args
+    68/push  _test-stream-buffer/imm32
+    # . . call
+    e8/call  clear-stream/disp32
+    # . . discard args
+    81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add to ESP
     # write(_test-stream, "ab\ncd")
     # . write(_test-stream, "ab")
     # . . push args
@@ -191,8 +198,115 @@ test-read-line:
     # end
     c3/return
 
-#? test-read-line-returns-true-on-eof:
-#? 
-#? test-read-line-reads-final-line-until-eof:
+test-read-line-returns-true-on-eof:
+    # setup
+    # . clear-stream(_test-stream)
+    # . . push args
+    68/push  _test-stream/imm32
+    # . . call
+    e8/call  clear-stream/disp32
+    # . . discard args
+    81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add to ESP
+    # . clear-stream(_test-buffered-file+4)
+    # . . push args
+    b8/copy-to-EAX  _test-buffered-file/imm32
+    05/add-to-EAX  4/imm32
+    50/push-EAX
+    # . . call
+    e8/call  clear-stream/disp32
+    # . . discard args
+    81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add to ESP
+    # . clear-stream(_test-stream-buffer)
+    # . . push args
+    68/push  _test-stream-buffer/imm32
+    # . . call
+    e8/call  clear-stream/disp32
+    # . . discard args
+    81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add to ESP
+    # write nothing
+    # EAX = read-line(_test-buffered-file, _test-stream-buffer)
+    # . . push args
+    68/push  _test-stream-buffer/imm32
+    68/push  _test-buffered-file/imm32
+    # . . call
+    e8/call  read-line/disp32
+    # . . discard args
+    81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # add to ESP
+    # check-ints-equal(EAX, eof, msg)
+    # . . push args
+    68/push  "F - test-read-line-returns-true-on-eof"/imm32
+    68/push  0xffffffff/imm32/not-at-eof
+    50/push-EAX
+    # . . call
+    e8/call  check-ints-equal/disp32
+    # . . discard args
+    81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               0xc/imm32         # add to ESP
+    # end
+    c3/return
+
+test-read-line-reads-final-line-until-eof:
+    # setup
+    # . clear-stream(_test-stream)
+    # . . push args
+    68/push  _test-stream/imm32
+    # . . call
+    e8/call  clear-stream/disp32
+    # . . discard args
+    81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add to ESP
+    # . clear-stream(_test-buffered-file+4)
+    # . . push args
+    b8/copy-to-EAX  _test-buffered-file/imm32
+    05/add-to-EAX  4/imm32
+    50/push-EAX
+    # . . call
+    e8/call  clear-stream/disp32
+    # . . discard args
+    81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add to ESP
+    # . clear-stream(_test-stream-buffer)
+    # . . push args
+    68/push  _test-stream-buffer/imm32
+    # . . call
+    e8/call  clear-stream/disp32
+    # . . discard args
+    81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add to ESP
+    # write(_test-stream, "cd")
+    # . . push args
+    68/push  "cd"/imm32
+    68/push  _test-stream/imm32
+    # . . call
+    e8/call  write/disp32
+    # . . discard args
+    81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # add to ESP
+    # read a line from _test-stream (buffered by _test-buffered-file) into _test-stream-buffer
+    # . EAX = read-line(_test-buffered-file, _test-stream-buffer)
+    # . . push args
+    68/push  _test-stream-buffer/imm32
+    68/push  _test-buffered-file/imm32
+    # . . call
+    e8/call  read-line/disp32
+    # . . discard args
+    81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # add to ESP
+    # check-ints-equal(EAX, eof, msg)
+    # . . push args
+    68/push  "F - test-read-line-reads-final-line-until-eof: return value"/imm32
+    68/push  0xffffffff/imm32/not-at-eof
+    50/push-EAX
+    # . . call
+    e8/call  check-ints-equal/disp32
+    # . . discard args
+    81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               0xc/imm32         # add to ESP
+    # check-ints-equal(*_test-stream-buffer->data, 63/c 64/d 00 00, msg)
+    # . . push args
+    68/push  "F - test-read-line-reads-final-line-until-eof"/imm32
+    68/push  0x00006463/imm32
+    # . . push *_test-stream->data
+    b8/copy-to-EAX  _test-stream-buffer/imm32
+    ff          6/subop/push        1/mod/*+disp8   0/rm32/EAX    .           .             .           .           0xc/disp8       .                 # push *(EAX+12)
+    # . . call
+    e8/call  check-ints-equal/disp32
+    # . . discard args
+    81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               0xc/imm32         # add to ESP
+    # end
+    c3/return
 
 # . . vim:nowrap:textwidth=0
title='author Kartik K. Agaram <vc@akkartik.com> 2016-05-21 17:44:53 -0700 committer Kartik K. Agaram <vc@akkartik.com> 2016-05-21 17:44:53 -0700 2996' href='/akkartik/mu/commit/html/nqueens.mu.html?h=hlt&id=2f02189ddcdeb7d25b0ca9bd5b955b764d41a1a7'>2f02189d ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166