Add empty set patches, add test for empty set patches
This commit is contained in:
parent
c82076281f
commit
0de17f4b57
@ -828,7 +828,7 @@ and simpl_single_instruction : Raw.single_instr -> (_ -> expression result) resu
|
||||
| MapPatch patch ->
|
||||
fail @@ unsupported_map_patches patch
|
||||
| SetPatch patch -> (
|
||||
let setp = patch.value in
|
||||
let (setp, loc) = r_split patch in
|
||||
let (name , access_path) = simpl_path setp.path in
|
||||
let%bind inj = bind_list
|
||||
@@ List.map (fun (x:Raw.expr) ->
|
||||
@ -840,7 +840,7 @@ and simpl_single_instruction : Raw.single_instr -> (_ -> expression result) resu
|
||||
e_assign name access_path (e_constant "SET_ADD" [v ; e_variable name]) in
|
||||
let assigns = List.map aux inj in
|
||||
match assigns with
|
||||
| [] -> fail @@ unsupported_empty_record_patch setp.set_inj
|
||||
| [] -> ok @@ e_skip ~loc ()
|
||||
| hd :: tl -> (
|
||||
let aux acc cur = e_sequence acc cur in
|
||||
ok @@ List.fold_left aux hd tl
|
||||
|
@ -20,6 +20,9 @@ function remove_syntax (var s : set(string)) : set(string) is
|
||||
function patch_op (var s: set(string)) : set(string) is
|
||||
begin patch s with set ["foobar"]; end with s
|
||||
|
||||
function patch_op_empty (var s: set(string)) : set(string) is
|
||||
begin patch s with set []; end with s
|
||||
|
||||
function mem_op (const s : set(string)) : bool is
|
||||
begin skip end with set_mem("foobar" , s)
|
||||
|
||||
|
@ -249,6 +249,10 @@ let set_arithmetic () : unit result =
|
||||
expect_eq program "patch_op"
|
||||
(e_set [e_string "foo" ; e_string "bar"])
|
||||
(e_set [e_string "foo" ; e_string "bar"; e_string "foobar"]) in
|
||||
let%bind () =
|
||||
expect_eq program "patch_op_empty"
|
||||
(e_set [e_string "foo" ; e_string "bar"])
|
||||
(e_set [e_string "foo" ; e_string "bar"]) in
|
||||
let%bind () =
|
||||
expect_eq program "mem_op"
|
||||
(e_set [e_string "foo" ; e_string "bar" ; e_string "foobar"])
|
||||
|
Loading…
Reference in New Issue
Block a user