<commit_before>TYPE_CONV_PATH "List_mutate"

type x = {
  foo: int;
  mutable bar: (string * string) list
} with orm

open Test_utils
open OUnit

let name = "list_mutate.db" 

let test_mutate_basic () =
  let db = open_db x_init name in
  let l = [ "foo1","bar1"; "foo2","bar2" ] in
  let t1 = {foo=1; bar=l } in
  x_save db t1;
  let l = ("foo3","bar3") :: l in
  t1.bar <- l;
  x_save db t1;
  match x_get db with
  |[s;t] -> "eq" @?
    (List.exists (fun t -> t.bar = ["foo3","bar3"; "foo1","bar1"; "foo2","bar2" ]) [s;t] &&
    List.exists (fun t -> t.bar = ["foo1","bar1"; "foo2","bar2" ]) [s;t] )
  |[] -> failwith "no x"
  |x -> failwith (Printf.sprintf "too many x: %d" (List.length x))

let suite = [
  "list_mutate_basic" >:: test_mutate_basic;
]
<commit_msg>[test] fix the list_mutate test.<commit_after>TYPE_CONV_PATH "List_mutate"

type x = {
  foo: int;
  mutable bar: (string * string) list
} with orm

open Test_utils
open OUnit

let name = "list_mutate.db" 

let test_mutate_basic () =
  let db = open_db x_init name in
  let l = [ "foo1","bar1"; "foo2","bar2" ] in
  let t1 = {foo=1; bar=l } in
  x_save db t1;
  let l = ("foo3","bar3") :: l in
  t1.bar <- l;
  x_save db t1;
  match x_get db with
  | [x] -> "eq" @? (x.bar = ["foo3","bar3"; "foo1","bar1"; "foo2","bar2" ])
  | [] -> failwith "no x"
  | x -> failwith (Printf.sprintf "too many x: %d" (List.length x))

let suite = [
  "list_mutate_basic" >:: test_mutate_basic;
]

{'fraction_non_alphanumeric': 0.1899171270718232, 'fraction_numerical': 0.026243093922651933, 'mean_word_length': 3.3513513513513513, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2814413', 'n_tokens_mistral': 642, 'n_tokens_neox': 638, 'n_words': 169}