Permalink
Browse files

Fix typo and add a test for new changes

  • Loading branch information...
zshipko committed Nov 7, 2018
1 parent 7bcef65 commit 6897eb1e278656346569901bc31bf72288320706
Showing with 9 additions and 5 deletions.
  1. +5 −4 src/irmin/contents.ml
  2. +4 −1 test/irmin/test.ml
@@ -112,9 +112,9 @@ module Json_value = struct
let rec equal a b =
match a, b with
| `Null, `Null -> true
| `Bool a, `Bool b -> a = b
| `Bool a, `Bool b -> Type.(equal bool) a b
| `String a, `String b -> String.equal a b
| `Float a, `Float b -> a = b
| `Float a, `Float b -> Type.(equal float) a b
| `A a, `A b ->
(try
List.for_all2 (fun a' b' ->
@@ -125,10 +125,11 @@ module Json_value = struct
List.for_all2 (fun (k, v) (k', v') ->
equal (List.assoc k b) v && equal (List.assoc k' a) v') a b
with Not_found | Invalid_argument _ -> false)
| _, _ -> false
| _, _ ->
false
let t = Type.like' ~cli:(pp, of_string) t
let t = Type.like' ~equal ~cli:(pp, of_string) t
let rec merge_object ~old x y =
let open Merge.Infix in
@@ -113,7 +113,10 @@ let test_equal () =
Alcotest.(check int) "eq" (T.compare x 1 2) (compare 1 2);
Alcotest.(check int) "eq" (T.compare x 3 1) (compare 3 1);
Alcotest.(check bool) "eq" (T.equal x 3 1) true;
Alcotest.(check bool) "eq" (T.equal x 0 0) false
Alcotest.(check bool) "eq" (T.equal x 0 0) false;
let a = `O ["b", `Float 2.; "c", `A [`String "test"]; "a", `Bool true] in
let b = `O ["a", `Bool true; "b", `Float 2.; "c", `A [`String "test"]] in
Alcotest.(check bool) "json eq" (T.equal Irmin.Contents.Json_value.t a b) true
let suite = [
"type", [

0 comments on commit 6897eb1

Please sign in to comment.