Merge branch 'feature/variable-in-dry-run' into 'dev'

Allow using top level variables defined in source code in dry-run PARAMETER and STORAGE

See merge request ligolang/ligo!436
This commit is contained in:
Rémi Lesenechal 2020-02-19 20:41:37 +00:00
commit e8129c5be3
3 changed files with 10 additions and 2 deletions

View File

@ -327,7 +327,7 @@ let dry_run =
let%bind simplified = Compile.Of_source.compile_contract_input storage input v_syntax in let%bind simplified = Compile.Of_source.compile_contract_input storage input v_syntax in
let%bind typed,_ = Compile.Of_simplified.compile_expression ~env ~state simplified in let%bind typed,_ = Compile.Of_simplified.compile_expression ~env ~state simplified in
let%bind mini_c = Compile.Of_typed.compile_expression typed in let%bind mini_c = Compile.Of_typed.compile_expression typed in
let%bind compiled_params = Compile.Of_mini_c.compile_expression mini_c in let%bind compiled_params = Compile.Of_mini_c.aggregate_and_compile_expression mini_c_prg mini_c in
let%bind args_michelson = Run.evaluate_expression compiled_params.expr compiled_params.expr_ty in let%bind args_michelson = Run.evaluate_expression compiled_params.expr compiled_params.expr_ty in
let%bind options = Run.make_dry_run_options {predecessor_timestamp ; amount ; sender ; source } in let%bind options = Run.make_dry_run_options {predecessor_timestamp ; amount ; sender ; source } in

View File

@ -1126,3 +1126,8 @@ let%expect_test _ =
{ parameter int ; { parameter int ;
storage (pair (map %one key_hash nat) (big_map %two key_hash bool)) ; storage (pair (map %one key_hash nat) (big_map %two key_hash bool)) ;
code { DUP ; CDR ; NIL operation ; PAIR ; DIP { DROP } } } |}] code { DUP ; CDR ; NIL operation ; PAIR ; DIP { DROP } } } |}]
let%expect_test _ =
run_ligo_good [ "dry-run" ; contract "super-counter.mligo" ; "main" ; "test_param" ; "test_storage" ] ;
[%expect {|
( list[] , 3 ) |}]

View File

@ -2,6 +2,9 @@ type action =
| Increment of int | Increment of int
| Decrement of int | Decrement of int
let test_param = Increment(1)
let test_storage = 2
let main (ps : action * int) : (operation list * int) = let main (ps : action * int) : (operation list * int) =
let storage = let storage =
match ps.0 with match ps.0 with