@@ -21,15 +21,15 @@ fn proptest_cursor_ops(
2121) {
2222 let bytes = buf_list. clone ( ) . copy_to_bytes ( buf_list. remaining ( ) ) ;
2323 let mut buf_list_cursor = crate :: Cursor :: new ( & buf_list) ;
24- let mut upstream_cursor = io:: Cursor :: new ( bytes. as_ref ( ) ) ;
24+ let mut oracle_cursor = io:: Cursor :: new ( bytes. as_ref ( ) ) ;
2525
2626 eprintln ! ( "\n **** start!" ) ;
2727
2828 for ( index, cursor_op) in ops. into_iter ( ) . enumerate ( ) {
2929 // apply_and_compare prints out the rest of the line.
3030 eprint ! ( "** index {}, operation {:?}: " , index, cursor_op) ;
3131 cursor_op
32- . apply_and_compare ( & mut buf_list_cursor, & mut upstream_cursor )
32+ . apply_and_compare ( & mut buf_list_cursor, & mut oracle_cursor )
3333 . with_context ( || format ! ( "for index {}" , index) )
3434 . unwrap ( ) ;
3535 }
@@ -53,7 +53,7 @@ enum CursorOp {
5353 Vec < prop:: sample:: Index > ,
5454 ) ,
5555 ReadExact ( prop:: sample:: Index ) ,
56- // fill_buf can't be tested here because upstream is a contiguous block. Instead, we check its
56+ // fill_buf can't be tested here because oracle is a contiguous block. Instead, we check its
5757 // return value separately.
5858 Consume ( prop:: sample:: Index ) ,
5959 // No need to test futures03 imps since they're simple wrappers around the main imps.
@@ -69,7 +69,7 @@ impl CursorOp {
6969 self ,
7070 // The "mut" here is used in the branches corresponding to optional features.
7171 #[ allow( unused_mut) ] mut buf_list : & mut crate :: Cursor < & BufList > ,
72- #[ allow( unused_mut) ] mut upstream : & mut io:: Cursor < & [ u8 ] > ,
72+ #[ allow( unused_mut) ] mut oracle : & mut io:: Cursor < & [ u8 ] > ,
7373 ) -> Result < ( ) > {
7474 let num_bytes = buf_list. get_ref ( ) . num_bytes ( ) ;
7575 match self {
@@ -79,16 +79,16 @@ impl CursorOp {
7979 eprintln ! ( "set position: {}" , index) ;
8080
8181 buf_list. set_position ( index) ;
82- upstream . set_position ( index) ;
82+ oracle . set_position ( index) ;
8383 }
8484 Self :: SeekStart ( index) => {
8585 // Allow going past the end of the list a bit.
8686 let style = SeekFrom :: Start ( index. index ( 1 + num_bytes * 5 / 4 ) as u64 ) ;
8787 eprintln ! ( "style: {:?}" , style) ;
8888
89- let buf_list_pos = buf_list. seek ( style) ;
90- let upstream_pos = upstream . seek ( style) ;
91- Self :: assert_io_error_eq ( buf_list_pos , upstream_pos )
89+ let buf_list_res = buf_list. seek ( style) ;
90+ let oracle_res = oracle . seek ( style) ;
91+ Self :: assert_io_result_eq ( buf_list_res , oracle_res )
9292 . context ( "operation result didn't match" ) ?;
9393 }
9494 Self :: SeekEnd ( index) => {
@@ -97,9 +97,9 @@ impl CursorOp {
9797 let style = SeekFrom :: End ( index - ( 1 + num_bytes * 5 / 4 ) as i64 ) ;
9898 eprintln ! ( "style: {:?}" , style) ;
9999
100- let buf_list_pos = buf_list. seek ( style) ;
101- let upstream_pos = upstream . seek ( style) ;
102- Self :: assert_io_error_eq ( buf_list_pos , upstream_pos )
100+ let buf_list_res = buf_list. seek ( style) ;
101+ let oracle_res = oracle . seek ( style) ;
102+ Self :: assert_io_result_eq ( buf_list_res , oracle_res )
103103 . context ( "operation result didn't match" ) ?;
104104 }
105105 Self :: SeekCurrent ( index) => {
@@ -108,9 +108,9 @@ impl CursorOp {
108108 let style = SeekFrom :: Current ( index - ( num_bytes * 3 / 4 ) as i64 ) ;
109109 eprintln ! ( "style: {:?}" , style) ;
110110
111- let buf_list_pos = buf_list. seek ( style) ;
112- let upstream_pos = upstream . seek ( style) ;
113- Self :: assert_io_error_eq ( buf_list_pos , upstream_pos )
111+ let buf_list_res = buf_list. seek ( style) ;
112+ let oracle_res = oracle . seek ( style) ;
113+ Self :: assert_io_result_eq ( buf_list_res , oracle_res )
114114 . context ( "operation result didn't match" ) ?;
115115 }
116116 Self :: Read ( index) => {
@@ -120,13 +120,13 @@ impl CursorOp {
120120 // Must initialize the whole vec here so &mut returns the whole buffer -- can't use
121121 // with_capacity!
122122 let mut buf_list_buf = vec ! [ 0u8 ; buf_size] ;
123- let mut upstream_buf = vec ! [ 0u8 ; buf_size] ;
123+ let mut oracle_buf = vec ! [ 0u8 ; buf_size] ;
124124
125- let buf_list_nread = buf_list. read ( & mut buf_list_buf) ;
126- let upstream_nread = upstream . read ( & mut upstream_buf ) ;
127- Self :: assert_io_error_eq ( buf_list_nread , upstream_nread )
125+ let buf_list_res = buf_list. read ( & mut buf_list_buf) ;
126+ let oracle_res = oracle . read ( & mut oracle_buf ) ;
127+ Self :: assert_io_result_eq ( buf_list_res , oracle_res )
128128 . context ( "operation result didn't match" ) ?;
129- ensure ! ( buf_list_buf == upstream_buf , "read buffer matches" ) ;
129+ ensure ! ( buf_list_buf == oracle_buf , "read buffer matches" ) ;
130130 }
131131 Self :: ReadVectored ( indexes) => {
132132 // Build a bunch of IoSliceMuts.
@@ -139,28 +139,26 @@ impl CursorOp {
139139 vec ! [ 0u8 ; buf_size]
140140 } )
141141 . collect ( ) ;
142- let mut upstream_vecs = buf_list_vecs. clone ( ) ;
142+ let mut oracle_vecs = buf_list_vecs. clone ( ) ;
143143
144144 let mut buf_list_slices: Vec < _ > = buf_list_vecs
145145 . iter_mut ( )
146146 . map ( |v| IoSliceMut :: new ( v) )
147147 . collect ( ) ;
148- let mut upstream_slices: Vec < _ > = upstream_vecs
149- . iter_mut ( )
150- . map ( |v| IoSliceMut :: new ( v) )
151- . collect ( ) ;
148+ let mut oracle_slices: Vec < _ > =
149+ oracle_vecs. iter_mut ( ) . map ( |v| IoSliceMut :: new ( v) ) . collect ( ) ;
152150
153151 let buf_list_res = buf_list. read_vectored ( & mut buf_list_slices) ;
154- let upstream_res = upstream . read_vectored ( & mut upstream_slices ) ;
155- Self :: assert_io_error_eq ( buf_list_res, upstream_res )
152+ let oracle_res = oracle . read_vectored ( & mut oracle_slices ) ;
153+ Self :: assert_io_result_eq ( buf_list_res, oracle_res )
156154 . context ( "operation result didn't match" ) ?;
157155
158156 // Also check that the slices read match exactly.
159157 ensure ! (
160- buf_list_vecs == upstream_vecs ,
161- "read vecs didn't match: buf_list: {:?} == upstream : {:?}" ,
158+ buf_list_vecs == oracle_vecs ,
159+ "read vecs didn't match: buf_list: {:?} == oracle : {:?}" ,
162160 buf_list_vecs,
163- upstream_vecs
161+ oracle_vecs
164162 ) ;
165163 }
166164 Self :: ReadExact ( index) => {
@@ -170,20 +168,20 @@ impl CursorOp {
170168 // Must initialize the whole vec here so &mut returns the whole buffer -- can't use
171169 // with_capacity!
172170 let mut buf_list_buf = vec ! [ 0u8 ; buf_size] ;
173- let mut upstream_buf = vec ! [ 0u8 ; buf_size] ;
171+ let mut oracle_buf = vec ! [ 0u8 ; buf_size] ;
174172
175173 let buf_list_res = buf_list. read_exact ( & mut buf_list_buf) ;
176- let upstream_res = upstream . read_exact ( & mut upstream_buf ) ;
177- Self :: assert_io_error_eq ( buf_list_res, upstream_res )
174+ let oracle_res = oracle . read_exact ( & mut oracle_buf ) ;
175+ Self :: assert_io_result_eq ( buf_list_res, oracle_res )
178176 . context ( "operation result didn't match" ) ?;
179- ensure ! ( buf_list_buf == upstream_buf , "read buffer matches" ) ;
177+ ensure ! ( buf_list_buf == oracle_buf , "read buffer matches" ) ;
180178 }
181179 Self :: Consume ( index) => {
182180 let amt = index. index ( 1 + num_bytes * 5 / 4 ) ;
183181 eprintln ! ( "amt: {}" , amt) ;
184182
185183 buf_list. consume ( amt) ;
186- upstream . consume ( amt) ;
184+ oracle . consume ( amt) ;
187185 }
188186 #[ cfg( feature = "tokio1" ) ]
189187 Self :: PollRead { capacity, filled } => {
@@ -192,7 +190,7 @@ impl CursorOp {
192190
193191 let capacity = capacity. index ( 1 + num_bytes * 5 / 4 ) ;
194192 let mut buf_list_vec = vec ! [ MaybeUninit :: uninit( ) ; capacity] ;
195- let mut upstream_vec = buf_list_vec. clone ( ) ;
193+ let mut oracle_vec = buf_list_vec. clone ( ) ;
196194
197195 let mut buf_list_buf = ReadBuf :: uninit ( & mut buf_list_vec) ;
198196
@@ -202,8 +200,8 @@ impl CursorOp {
202200 let fill_vec = vec ! [ 0u8 ; filled_index] ;
203201 buf_list_buf. put_slice ( & fill_vec) ;
204202
205- let mut upstream_buf = ReadBuf :: uninit ( & mut upstream_vec ) ;
206- upstream_buf . put_slice ( & fill_vec) ;
203+ let mut oracle_buf = ReadBuf :: uninit ( & mut oracle_vec ) ;
204+ oracle_buf . put_slice ( & fill_vec) ;
207205
208206 eprintln ! ( "capacity: {}, filled_index: {}" , capacity, filled_index) ;
209207
@@ -218,41 +216,41 @@ impl CursorOp {
218216 Poll :: Pending => unreachable ! ( "buf_list never returns pending" ) ,
219217 } ;
220218
221- let mut upstream_pinned = Pin :: new ( upstream ) ;
222- let upstream_res = match upstream_pinned
219+ let mut oracle_pinned = Pin :: new ( oracle ) ;
220+ let oracle_res = match oracle_pinned
223221 . as_mut ( )
224- . poll_read ( & mut context, & mut upstream_buf )
222+ . poll_read ( & mut context, & mut oracle_buf )
225223 {
226224 Poll :: Ready ( res) => res,
227- Poll :: Pending => unreachable ! ( "upstream cursor never returns pending" ) ,
225+ Poll :: Pending => unreachable ! ( "oracle cursor never returns pending" ) ,
228226 } ;
229227
230- Self :: assert_io_error_eq ( buf_list_res, upstream_res )
228+ Self :: assert_io_result_eq ( buf_list_res, oracle_res )
231229 . context ( "result didn't match" ) ?;
232230 ensure ! (
233- buf_list_buf. filled( ) == upstream_buf . filled( ) ,
231+ buf_list_buf. filled( ) == oracle_buf . filled( ) ,
234232 "filled section didn't match"
235233 ) ;
236234 ensure ! (
237- buf_list_buf. remaining( ) == upstream_buf . remaining( ) ,
235+ buf_list_buf. remaining( ) == oracle_buf . remaining( ) ,
238236 "remaining count didn't match"
239237 ) ;
240238
241- // Put buf_list and upstream back into their original places.
239+ // Put buf_list and oracle back into their original places.
242240 buf_list = buf_list_pinned. get_mut ( ) ;
243- upstream = upstream_pinned . get_mut ( ) ;
241+ oracle = oracle_pinned . get_mut ( ) ;
244242 }
245243 }
246244
247245 // Also check that the position is the same.
248246 let buf_list_position = buf_list. position ( ) ;
249247 ensure ! (
250- buf_list_position == upstream . position( ) ,
251- "position didn't match: buf_list position {} == upstream position {}" ,
248+ buf_list_position == oracle . position( ) ,
249+ "position didn't match: buf_list position {} == oracle position {}" ,
252250 buf_list_position,
253- upstream . position( ) ,
251+ oracle . position( ) ,
254252 ) ;
255- Self :: assert_io_error_eq ( buf_list. stream_position ( ) , upstream . stream_position ( ) )
253+ Self :: assert_io_result_eq ( buf_list. stream_position ( ) , oracle . stream_position ( ) )
256254 . context ( "stream position didn't match" ) ?;
257255
258256 // Check that fill_buf returns an empty slice iff it is actually empty.
@@ -279,40 +277,40 @@ impl CursorOp {
279277 Ok ( ( ) )
280278 }
281279
282- fn assert_io_error_eq < T : Eq + fmt:: Debug > (
280+ fn assert_io_result_eq < T : Eq + fmt:: Debug > (
283281 buf_list_res : io:: Result < T > ,
284- upstream_res : io:: Result < T > ,
282+ oracle_res : io:: Result < T > ,
285283 ) -> Result < ( ) > {
286- match ( buf_list_res, upstream_res ) {
287- ( Ok ( buf_value ) , Ok ( upstream_value ) ) => {
284+ match ( buf_list_res, oracle_res ) {
285+ ( Ok ( buf_list_value ) , Ok ( oracle_value ) ) => {
288286 ensure ! (
289- buf_value == upstream_value ,
290- "value didn't match: buf_list value {:?} == upstream value {:?}" ,
291- buf_value ,
292- upstream_value
287+ buf_list_value == oracle_value ,
288+ "value didn't match: buf_list value {:?} == oracle value {:?}" ,
289+ buf_list_value ,
290+ oracle_value
293291 ) ;
294292 }
295- ( Ok ( buf_value ) , Err ( upstream_err ) ) => {
293+ ( Ok ( buf_list_value ) , Err ( oracle_err ) ) => {
296294 bail ! (
297- "BufList value Ok({:?}) is not the same as upstream error Err({})" ,
298- buf_value ,
299- upstream_err ,
295+ "BufList value Ok({:?}) is not the same as oracle error Err({})" ,
296+ buf_list_value ,
297+ oracle_err ,
300298 ) ;
301299 }
302- ( Err ( buf_err ) , Ok ( upstream_value ) ) => {
300+ ( Err ( buf_list_err ) , Ok ( oracle_value ) ) => {
303301 bail ! (
304- "BufList error ({}) is not the same as upstream value ({:?})" ,
305- buf_err ,
306- upstream_value
302+ "BufList error ({}) is not the same as oracle value ({:?})" ,
303+ buf_list_err ,
304+ oracle_value
307305 )
308306 }
309- ( Err ( buf_err ) , Err ( upstream_err ) ) => {
307+ ( Err ( buf_list_err ) , Err ( oracle_err ) ) => {
310308 // The kinds should match.
311309 ensure ! (
312- buf_err . kind( ) == upstream_err . kind( ) ,
313- "error kind didn't match: buf_list {:?} == upstream {:?}" ,
314- buf_err . kind( ) ,
315- upstream_err . kind( )
310+ buf_list_err . kind( ) == oracle_err . kind( ) ,
311+ "error kind didn't match: buf_list {:?} == oracle {:?}" ,
312+ buf_list_err . kind( ) ,
313+ oracle_err . kind( )
316314 ) ;
317315 }
318316 }
0 commit comments