@@ -3,7 +3,8 @@ use lean_compiler::{
33 compile_to_low_level_bytecode, simplify_program,
44} ;
55use lean_compiler:: { compile_program, parse_program} ;
6- use lean_runner:: { ExecutionHistory , execute_bytecode, execute_bytecode_helper} ;
6+ use lean_runner:: { execute_bytecode, execute_bytecode_helper} ;
7+ use lean_vm:: { ExecutionHistory , ExecutionResult } ;
78use lean_vm:: core:: Label ;
89use lean_vm:: * ;
910use p3_field:: PrimeCharacteristicRing ;
@@ -99,7 +100,7 @@ fn do_test_range_check(v: usize, t: usize, verbose: bool) {
99100 let max_runner_memory_size: usize = 1 << 24 ;
100101
101102 let program = range_check_program ( v, t) ;
102- let ( bytecode, function_locations) = compile_program ( & program) ; // Range checks are automatically compiled now
103+ let ( bytecode, function_locations) = compile_program ( & program, & [ ] , & [ ] ) ;
103104
104105 if verbose {
105106 println ! ( "Range Check Test: v: {}, t: {} ==============" , v, t) ;
@@ -115,7 +116,6 @@ fn do_test_range_check(v: usize, t: usize, verbose: bool) {
115116 & [ ] ,
116117 & [ ] ,
117118 max_runner_memory_size / 2 ,
118- false ,
119119 & mut std_out,
120120 & mut instruction_history,
121121 false ,
@@ -144,6 +144,12 @@ fn do_test_range_check(v: usize, t: usize, verbose: bool) {
144144 }
145145}
146146
147+ #[ test]
148+ fn test_range_check_execution ( ) {
149+ do_test_range_check ( 0 , 1 , false ) ;
150+ }
151+
152+
147153/// Test that the range check keyword is parsed and compiled (steps a to c only).
148154#[ test]
149155fn test_range_check_parsing_and_compilation ( ) {
@@ -268,7 +274,6 @@ fn do_test_invalid_range_check(v: usize, t: usize) {
268274 println ! ( "Execution complete but the range check failed to OOM" ) ;
269275 assert ! ( false , "range check failed to catch OOM" ) ;
270276 }
271- println ! ( "result: {}" , result. as_ref( ) . unwrap_err( ) ) ;
272277 assert ! ( matches!( & result, Err ( RunnerError :: OutOfMemory ) ) ) ;
273278}
274279
@@ -445,20 +450,21 @@ fn test_deref() {
445450 } ;
446451 println ! ( "bytecode:\n {}" , bytecode. to_string( ) ) ;
447452 let execution_result = execute_bytecode (
448- & mut bytecode,
453+ & bytecode,
449454 & [ ] , // public input
450455 & [ ] , // private input
451456 "" , // no source code for debug
452457 & std:: collections:: BTreeMap :: new ( ) , // no function locations
458+ 1 << 23 , // no_vec_runtime_memory
453459 false , // no profiler
454460 ) ;
455461
456- assert ! ( execution_result. is_ok( ) ) ;
462+ // execution_result is now ExecutionResult struct, not a Result
463+ assert ! ( execution_result. pcs. len( ) > 0 ) ; // Basic check that execution completed
457464}
458465
459- fn range_check ( v : usize , t : usize ) -> Result < lean_runner :: ExecutionResult , RunnerError > {
466+ fn range_check ( v : usize , t : usize ) -> Result < ExecutionResult , RunnerError > {
460467 let starting_frame_memory = 5 ;
461- println ! ( "v: {}; t: {}" , v, t) ;
462468 let val = F :: from_usize ( v) ;
463469
464470 // In the final version, these values will have to be set after a first execution pass
@@ -571,13 +577,16 @@ fn range_check(v: usize, t: usize) -> Result<lean_runner::ExecutionResult, Runne
571577 } ;
572578
573579 // Execute the bytecode
574- let execution_result = execute_bytecode (
575- & mut bytecode,
576- & [ ] , // public input
577- & [ ] , // private input
578- "" , // no source code for debug
579- & std:: collections:: BTreeMap :: new ( ) , // no function locations
580- false , // no profiler
581- ) ;
582- execution_result
580+ let execution_result = execute_bytecode_helper (
581+ & bytecode,
582+ & [ ] ,
583+ & [ ] ,
584+ 1 << 23 ,
585+ & mut String :: new ( ) ,
586+ & mut ExecutionHistory :: new ( ) ,
587+ false ,
588+ & BTreeMap :: new ( ) ,
589+ ) ?;
590+
591+ Ok ( execution_result)
583592}
0 commit comments