From e6ee915f1e385329a7ef159d0e46318d60203bae Mon Sep 17 00:00:00 2001 From: Lesenechal Remi Date: Tue, 22 Oct 2019 11:55:36 +0200 Subject: [PATCH] updating tests (we don't need the big_map to be in a pair anymore) --- src/test/contracts/big_map.ligo | 31 ++++++++++++++++--------------- src/test/contracts/big_map.mligo | 25 +++++++++++++++++-------- src/test/integration_tests.ml | 2 +- 3 files changed, 34 insertions(+), 24 deletions(-) diff --git a/src/test/contracts/big_map.ligo b/src/test/contracts/big_map.ligo index 8afc707b4..3d504aa75 100644 --- a/src/test/contracts/big_map.ligo +++ b/src/test/contracts/big_map.ligo @@ -1,4 +1,5 @@ type storage_ is big_map(int, int) * unit +type foo is big_map(int, int) function main(const p : unit; const s : storage_) : list(operation) * storage_ is var toto : option (int) := Some(0); @@ -8,28 +9,28 @@ function main(const p : unit; const s : storage_) : list(operation) * storage_ i } with ((nil: list(operation)), s) -function set_ (var n : int ; var m : storage_) : storage_ is block { - m.0[23] := n ; +function set_ (var n : int ; var m : foo) : foo is block { + m[23] := n ; } with m -function rm (var m : storage_) : storage_ is block { - remove 42 from map m.0; +function rm (var m : foo) : foo is block { + remove 42 from map m; } with m -function gf (const m : storage_) : int is begin skip end with get_force(23, m.0) +function gf (const m : foo) : int is begin skip end with get_force(23, m) -function get (const m : storage_) : option(int) is begin skip end with m.0[42] - -function mutimaps (const m : storage_; const n : storage_) : storage_ is block -{ - var foo : big_map(int,int) := m.0 ; - foo[42] := 0 ; - n.0[42] := get_force(42, foo) ; -} with n +function get (const m : foo) : option(int) is begin skip end with m[42] const empty_big_map : big_map(int,int) = big_map end -const map1 : big_map(int,int) = big_map +const big_map1 : big_map(int,int) = big_map 23 -> 0 ; 42 -> 0 ; -end \ No newline at end of file +end + +function mutimaps (const m : foo ; const n : foo) : foo is block +{ + var bar : foo := m ; + bar[42] := 0 ; + n[42] := get_force(42, bar) ; +} with n \ No newline at end of file diff --git a/src/test/contracts/big_map.mligo b/src/test/contracts/big_map.mligo index d032fad8c..52a366fe6 100644 --- a/src/test/contracts/big_map.mligo +++ b/src/test/contracts/big_map.mligo @@ -1,12 +1,21 @@ -type storage_ = ((int, int) big_map * unit) +type foo = (int, int) big_map -let set_ (n : int) (m : storage_) : storage_ = - (Map.update 23 (Some(n)) m.(0), ()) +let set_ (n : int) (m : foo) : foo = Big_map.update 23 (Some(n)) m -let rm (m : storage_) : storage_ = - (Map.remove 42 m.(0), ()) +let rm (m : foo) : foo = Big_map.remove 42 m -let gf (m : storage_) : int = Map.find 23 m.(0) +let gf (m : foo) : int = Big_map.find 23 m -let get (m: storage_): int option = - Map.find_opt 42 m.(0) \ No newline at end of file +let get (m: foo): int option = Big_map.find_opt 42 m + +let empty_map : foo = Big_map.empty + +let map1 : foo = Big_map.literal + [ (23 , 0) ; (42, 0) ] + +let map1 : foo = Big_map.literal + [ (23 , 0) ; (42, 0) ] + +let mutimaps (m : foo) (n : foo) : foo = + let bar : foo = Big_map.update 42 (Some(0)) m in + Big_map.update 42 (get(bar)) n \ No newline at end of file diff --git a/src/test/integration_tests.ml b/src/test/integration_tests.ml index 401f446ce..98af59a7f 100644 --- a/src/test/integration_tests.ml +++ b/src/test/integration_tests.ml @@ -522,7 +522,7 @@ let big_map_ type_f path : unit result = let ez lst = let open Ast_simplified.Combinators in let lst' = List.map (fun (x, y) -> e_int x, e_int y) lst in - e_pair (e_typed_big_map lst' t_int t_int) (e_unit ()) + (e_typed_big_map lst' t_int t_int) in let%bind () = let make_input = fun n -> ez [(23, n) ; (42, 4)] in