Add empty map patch test

This commit is contained in:
John David Pressman 2019-10-11 13:23:29 -07:00
parent 49ffe00466
commit 62377135c4
3 changed files with 12 additions and 0 deletions

View File

@ -29,6 +29,10 @@ function patch_ (var m: foobar) : foobar is block {
patch m with map [0 -> 5; 1 -> 6; 2 -> 7] patch m with map [0 -> 5; 1 -> 6; 2 -> 7]
} with m } with m
function patch_empty (var m : foobar) : foobar is block {
patch m with map []
} with m
function size_ (const m : foobar) : nat is function size_ (const m : foobar) : nat is
block {skip} with (size(m)) block {skip} with (size(m))

View File

@ -14,6 +14,9 @@ let rm (m : foobar) : foobar = Map.remove 42 m
(* Dummy test so that we can add the same test for PascaLIGO *) (* Dummy test so that we can add the same test for PascaLIGO *)
let patch_ (m : foobar) : foobar = Map.literal [ (0, 5) ; (1, 6) ; (2, 7) ] let patch_ (m : foobar) : foobar = Map.literal [ (0, 5) ; (1, 6) ; (2, 7) ]
(* Second dummy test, see above *)
let patch_empty (m : foobar) : foobar = Map.literal [ (0, 0) ; (1, 1) ; (2, 2) ]
let size_ (m : foobar) : nat = Map.size m let size_ (m : foobar) : nat = Map.size m
let gf (m : foobar) : int = Map.find 23 m let gf (m : foobar) : int = Map.find 23 m

View File

@ -416,6 +416,11 @@ let map_ type_f path : unit result =
let expected = ez [(0, 5) ; (1, 6) ; (2, 7)] in let expected = ez [(0, 5) ; (1, 6) ; (2, 7)] in
expect_eq program "patch_" input expected expect_eq program "patch_" input expected
in in
let%bind () =
let input = ez [(0,0) ; (1,1) ; (2,2)] in
let expected = ez [(0,0) ; (1,1) ; (2,2)] in
expect_eq program "patch_empty" input expected
in
let%bind () = let%bind () =
let make_input = fun n -> ez List.(map (fun x -> (x, x)) @@ range n) in let make_input = fun n -> ez List.(map (fun x -> (x, x)) @@ range n) in
let make_expected = e_nat in let make_expected = e_nat in