@@ -223,3 +223,32 @@ repl_test!(test_full_word_hex_formatting, |repl| {
223223 "Hex (full word): 0x0a6b316b47a0cd26c1b582ae3dcffbd175283c221c3cb3d1c614e3e47f62a700" ,
224224 ) ;
225225} ) ;
226+
227+ // Test that uint is printed properly with any size.
228+ repl_test ! ( test_uint_formatting, |repl| {
229+ for size in ( 8 ..=256 ) . step_by( 8 ) {
230+ repl. sendln( & format!( "type(uint{size}).max" ) ) ;
231+ repl. expect( & format!( "Hex: 0x{}" , "f" . repeat( size / 4 ) ) ) ;
232+
233+ repl. sendln( & format!( "uint{size}(2)" ) ) ;
234+ repl. expect( "Hex: 0x2" ) ;
235+ }
236+ } ) ;
237+
238+ // Test that int is printed properly with any size.
239+ repl_test ! ( test_int_formatting, |repl| {
240+ for size in ( 8 ..=256 ) . step_by( 8 ) {
241+ let size_minus_1: usize = size / 4 - 1 ;
242+ repl. sendln( & format!( "type(int{size}).max" ) ) ;
243+ repl. expect( & format!( "Hex: 0x7{}" , "f" . repeat( size_minus_1) ) ) ;
244+
245+ repl. sendln( & format!( "int{size}(2)" ) ) ;
246+ repl. expect( "Hex: 0x2" ) ;
247+
248+ repl. sendln( & format!( "type(int{size}).min" ) ) ;
249+ repl. expect( & format!( "Hex: 0x8{}" , "0" . repeat( size_minus_1) ) ) ;
250+
251+ repl. sendln( & format!( "int{size}(-2)" ) ) ;
252+ repl. expect( & format!( "Hex: 0x{}e" , "f" . repeat( size_minus_1) ) ) ;
253+ }
254+ } ) ;
0 commit comments