module store_tests.
  accumulate test_helpers, domains, store.

  local testcase int -> o.

  %% adapters from test_helpers.
  check_exists 1 J :- testcase J.
  check 1 J :- testcase J.

  %          expression     expected answer
  testcase 1 :-
       initial_store S0,
       OBJ = (object "Point" (f_fun_extend "x" nullref empty_f_fun)),
       alloc OBJ S0 0 S1,
       access S1 0 OBJ.
  testcase 2 :-
       initial_store S0,
       OBJ1 = (object "Point" (f_fun_extend "x" nullref empty_f_fun)),
       OBJ2 = (object "Point" (f_fun_extend "x" (ref 33)
                                (f_fun_extend "y" (ref 42) empty_f_fun))),
       alloc OBJ1 S0 0 S1,
       alloc OBJ2 S1 1 S2,
       access S2 0 OBJ1,
       access S2 1 OBJ2.
  testcase 3 :-
       initial_store S0,
       OBJ1 = (object "Point" (f_fun_extend "x" nullref empty_f_fun)),
       OBJ2 = (object "Point" (f_fun_extend "x" (ref 33)
                                (f_fun_extend "y" (ref 42) empty_f_fun))),
       OBJ3 = (object "Whale" (f_fun_extend "weight" nullref empty_f_fun)),
       alloc OBJ1 S0 0 S1,
       alloc OBJ2 S1 1 S2,
       update S2 0 OBJ3 S3,
       access S3 0 OBJ3,
       access S3 1 OBJ2.

end
