anchor.diff:  
   -ifdef(TEST).
   
  -object_test() ->
  -    B = <<"buckets_are_binaries">>,
  -    K = <<"keys are binaries">>,
  +-record(object_test_state, {type_bucket_key1 :: {binary(), binary(), binary()},
  +                            type_bucket_key2 :: {binary(), binary(), binary()},
  +                            value1 :: term(),
  +                            value2 :: term(),
  +                            object1 :: riak_object(),
  +                            object2 :: riak_object(),
  +                            bucket_type_object1 :: riak_object(),
  +                            bucket_type_object2 :: riak_object(),
  +                            actor :: pid()}
  +       ).
  +
  +object_test_() ->
  +    {spawn,
  +     [{setup,
  +       fun object_test_setup/0,
  +       fun object_test_cleanup/1,
  +       [{"basic object test", fun basic_object_test_case/0},
  +        {"update test", fun update_test_case/0},
  +        {"ancestor test", fun ancestor_test_case/0},
  +        {"reconcile test", fun reconcile_test_case/0},
  +        {"merge test 1", fun merge1_test_case/0},
  +        {"merge test 2", fun merge2_test_case/0},
  +        {"merge test 3", fun merge3_test_case/0},
  +        {"date reconcile test case", fun date_reconcile_test_case/0}
  +       ]}
  +     ]}.
  +
  +object_test_setup() ->
  +    TBK1 = {T, B, K} =  {<<"types_are_binaries">>,
  +                         <<"buckets_are_binaries">>,
  +                         <<"keys are binaries">>},
       V = <<"values are anything">>,
  -    O = riak_object:new(B,K,V),
  -    B = riak_object:bucket(O),
  -    K = riak_object:key(O),
  -    V = riak_object:get_value(O),
  -    1 = riak_object:value_count(O),
  -    1 = length(riak_object:get_values(O)),
  -    1 = length(riak_object:get_metadatas(O)),
  -    O.
  -
  -update_test() ->
  -    O = object_test(),
       V2 = <<"testvalue2">>,
  -    O1 = riak_object:update_value(O, V2),
  -    O2 = riak_object:apply_updates(O1),
  -    V2 = riak_object:get_value(O2),
  -    {O,O2}.
  -
  -ancestor_test() ->
  +    O1 = riak_object:new(B, K, V),
  +    TypeO1 = riak_object:new({T, B}, K, V),
       Actor = self(),
  -    {O,O2} = update_test(),
  -    O3 = riak_object:increment_vclock(O2, Actor),
  -    [O] = riak_object:ancestors([O,O3]),
  -    MD = riak_object:get_metadata(O3),
  -    ?assertMatch({Actor, {1, _}}, dict:fetch(?DOT, MD)),
  -    {O,O3}.
  +    O2 = riak_object:increment_vclock(
  +           riak_object:apply_updates(
  +             riak_object:update_value(O1, V2)),
  +           Actor),
  +    meck:new(riak_core_bucket_type, [passthrough]),
  +    meck:expect(riak_core_bucket_type, get, fun(_) -> [false] end),
  +    TypeO2 = riak_object:increment_vclock(
  +           riak_object:apply_updates(
  +             riak_object:update_value(TypeO1, V2)),
  +           Actor),
  +    #object_test_state{type_bucket_key1=TBK1,
  +                       value1=V,
  +                       value2=V2,
  +                       object1=O1,
  +                       object2=O2,
  +                       bucket_type_object1=TypeO1,
  +                       bucket_type_object2=TypeO2,
  +                       actor=Actor}.
  +
  +object_test_cleanup(_) ->
  +    meck:unload().
  +
  +basic_object_test_case() ->
  +    fun(#object_test_state{type_bucket_key1={T, B, K},
  +                           value1=V,
  +                           object1=O1,
  +                           bucket_type_object1=TypeO1}) ->
  +            ?assertEqual(B, riak_object:bucket(O1)),
  +            ?assertEqual(K, riak_object:key(O1)),
  +            ?assertEqual(V, riak_object:get_value(O1)),
  +            ?assertEqual(1, riak_object:value_count(O1)),
  +            ?assertEqual(1, length(riak_object:get_values(O1))),
  +            ?assertEqual(1, length(riak_object:get_metadatas(O1))),
  +            ?assertEqual(T, riak_object:type(TypeO1)),
  +            ?assertEqual(B, riak_object:bucket_only(TypeO1)),
  +            ?assertEqual({T,B}, riak_object:bucket(TypeO1)),
  +            ?assertEqual(K, riak_object:key(TypeO1)),
  +            ?assertEqual(V, riak_object:get_value(TypeO1)),
  +            ?assertEqual(1, riak_object:value_count(TypeO1)),
  +            ?assertEqual(1, length(riak_object:get_values(TypeO1))),
  +            ?assertEqual(1, length(riak_object:get_metadatas(TypeO1)))
  +    end.
  +
  +update_test_case() ->
  +    fun(#object_test_state{value2=V2,
  +                           object1=O1,
  +                           bucket_type_object1=TypeO1}) ->
  +            ?assertEqual(V2, riak_object:get_value(
  +                               riak_object:apply_updates(
  +                                 riak_object:update_value(O1, V2)))),
  +            ?assertEqual(V2, riak_object:get_value(
  +                               riak_object:apply_updates(
  +                                 riak_object:update_value(TypeO1, V2))))
  +    end.
  +
  +ancestor_test_case() ->
  +    fun(#object_test_state{object1=O1,
  +                           object2=O2,
  +                           bucket_type_object1=TypeO1,
  +                           bucket_type_object2=TypeO2,
  +                           actor=Actor}) ->
  +            ?assertEqual([O1], riak_object:ancestors([O1, O2])),
  +            ?assertMatch({Actor, {1, _}}, dict:fetch(?DOT, riak_object:get_metadata(O2))),
  +            ?assertEqual([TypeO1], riak_object:ancestors([TypeO1, TypeO2])),
  +            ?assertMatch({Actor, {1, _}}, dict:fetch(?DOT, riak_object:get_metadata(TypeO2)))
  +    end.
  +
  +reconcile_test_case() ->
  +    fun(#object_test_state{object1=O1,
  +                           object2=O2,
  +                           bucket_type_object1=TypeO1,
  +                           bucket_type_object2=TypeO2}) ->
  +            ?assertEqual(O2, riak_object:reconcile([O1, O2], true)),
  +            ?assertEqual(O2, riak_object:reconcile([O1, O2], false)),
  +            ?assertEqual(TypeO2, riak_object:reconcile([TypeO1, TypeO2], true)),
  +            ?assertEqual(TypeO2, riak_object:reconcile([TypeO1, TypeO2], false))
  +    end.
  +
  +merge1_test_case() ->
  +    fun(#object_test_state{object1=O1,
  +                           object2=O2,
  +                           bucket_type_object1=TypeO1,
  +                           bucket_type_object2=TypeO2}) ->
  +            ?assertEqual(O2, riak_object:syntactic_merge(O1, O2)),
  +            ?assertEqual(TypeO2, riak_object:syntactic_merge(TypeO1, TypeO2))
  +    end.
  +
  +merge2_test_case() ->
  +    fun(#object_test_state{type_bucket_key1={_, B, K},
  +                           value2=V2,
  +                           object1=O,
  +                           bucket_type_object1=TypeO}) ->
  +            O1 = riak_object:increment_vclock(O, node1),
  +            O2 = riak_object:increment_vclock(riak_object:new(B,K,V2), node2),
  +            O3 = riak_object:syntactic_merge(O1, O2),
  +            ?assertEqual([node1, node2], [N || {N,_} <- riak_object:vclock(O3)]),
  +            ?assertEqual(2, riak_object:value_count(O3)),
  +            TypeO1 = riak_object:increment_vclock(TypeO, node1),
  +            TypeO2 = riak_object:increment_vclock(riak_object:new(B,K,V2), node2),
  +            TypeO3 = riak_object:syntactic_merge(TypeO1, TypeO2),
  +            ?assertEqual([node1, node2], [N || {N,_} <- riak_object:vclock(TypeO3)]),
  +            ?assertEqual(2, riak_object:value_count(TypeO3))
  +    end.
  +
  +merge3_test_case() ->
  +    fun(#object_test_state{type_bucket_key1={_, B, K},
  +                           value2=V2,
  +                           object1=O,
  +                           bucket_type_object1=TypeO}) ->
  +            O1 = riak_object:increment_vclock(O, node1),
  +            O2 = riak_object:increment_vclock(riak_object:new(B, K, V2), node2),
  +            TypeO1 = riak_object:increment_vclock(TypeO, node1),
  +            TypeO2 = riak_object:increment_vclock(riak_object:new(B, K, V2), node2),
  +            ?assertEqual(riak_object:syntactic_merge(O1, O2),
  +                         riak_object:syntactic_merge(O2, O1)),
  +            ?assertEqual(riak_object:syntactic_merge(TypeO1, TypeO2),
  +                         riak_object:syntactic_merge(TypeO2, TypeO1))
  +    end.
  +
  +date_reconcile_test_case() ->
  +    fun(#object_test_state{object1=O,
  +                           object2=O3,
  +                           bucket_type_object1=TypeO,
  +                           bucket_type_object2=TypeO3}) ->
  +            D = calendar:datetime_to_gregorian_seconds(
  +                  httpd_util:convert_request_date(
  +                    httpd_util:rfc1123_date())),
  +            O2 = apply_updates(
  +                   riak_object:update_metadata(
  +                     increment_vclock(O, date),
  +                     dict:store(
  +                       <<"X-Riak-Last-Modified">>,
  +                       httpd_util:rfc1123_date(
  +                         calendar:gregorian_seconds_to_datetime(D)),
  +                       get_metadata(O)))),
  +            O4 = apply_updates(
  +                   riak_object:update_metadata(
  +                     O3,
  +                     dict:store(
  +                       <<"X-Riak-Last-Modified">>,
  +                       httpd_util:rfc1123_date(
  +                         calendar:gregorian_seconds_to_datetime(D+1)),
  +                       get_metadata(O3)))),
  +            O5 = riak_object:reconcile([O2, O4], false),
  +            TypeO2 = apply_updates(
  +                       riak_object:update_metadata(
  +                         increment_vclock(TypeO, date),
  +                         dict:store(
  +                           <<"X-Riak-Last-Modified">>,
  +                           httpd_util:rfc1123_date(
  +                             calendar:gregorian_seconds_to_datetime(D)),
  +                           get_metadata(TypeO)))),
  +            TypeO4 = apply_updates(
  +                       riak_object:update_metadata(
  +                         TypeO3,
  +                         dict:store(
  +                           <<"X-Riak-Last-Modified">>,
  +                           httpd_util:rfc1123_date(
  +                             calendar:gregorian_seconds_to_datetime(D+1)),
  +                           get_metadata(TypeO3)))),
  +            TypeO5 = riak_object:reconcile([TypeO2, TypeO4], false),
  +            ?assert(not riak_object:equal(O2, O5)),
  +            ?assert(not riak_object:equal(O4, O5)),
  +            ?assert(not riak_object:equal(TypeO2, TypeO5)),
  +            ?assert(not riak_object:equal(TypeO4, TypeO5))
  +    end.
   
   ancestor_weird_clocks_test() ->
       %% make objects with dots / clocks that are causally the same but
  
positive.code:     Ancestors = ancestors([A, AWat]),
      ?assertEqual(0, length(Ancestors)).
  
  reconcile_test() ->
      {O,O3} = ancestor_test(),
      O3 = riak_object:reconcile([O,O3],true),
      O3 = riak_object:reconcile([O,O3],false),
      {O,O3}.
  
  merge1_test() ->
      {O,O3} = reconcile_test(),
      O3 = riak_object:syntactic_merge(O,O3),
      {O,O3}.
  
  merge2_test() ->
      B = <<"buckets_are_binaries">>,
      K = <<"keys are binaries">>,
      V = <<"testvalue2">>,
      O1 = riak_object:increment_vclock(object_test(), node1),
      O2 = riak_object:increment_vclock(riak_object:new(B,K,V), node2),
      O3 = riak_object:syntactic_merge(O1, O2),
      [node1, node2] = [N || {N,_} <- riak_object:vclock(O3)],
      2 = riak_object:value_count(O3).
  
  merge3_test() ->
      O0 = riak_object:new(<<"test">>, <<"test">>, hi),
      O1 = riak_object:increment_vclock(O0, x),
      ?assertEqual(O1, riak_object:syntactic_merge(O1, O1)).
  
  merge4_test() ->
      O0 = riak_object:new(<<"test">>, <<"test">>, hi),
      O1 = riak_object:increment_vclock(
             riak_object:update_value(O0, bye), x),
  
negative.code:     catch throw:{error, key_too_large} ->
              ok
      end.
  
  get_update_value_test() ->
      O = riak_object:new(<<"test">>, <<"test">>, old_val),
  