A collection of experiments, more or less organized.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Some tests for kinds

xvw 0f306cf2 230d1b0c

+110 -1
+1 -1
lib/pidgin/kind.mli
··· 24 24 val list : t -> t 25 25 val constr : ?value:t -> string -> t 26 26 val record : (string * t) list -> t 27 - val from_repr : Repr.t -> t 28 27 29 28 (** {1 Utils} *) 30 29 30 + val from_repr : Repr.t -> t 31 31 val equal : t -> t -> bool 32 32 val to_string : t -> string
+109
test/pidgin/kind_test.ml
··· 11 11 repr |> dump_kind; 12 12 [%expect {| unit |}] 13 13 ;; 14 + 15 + let%expect_test "kind of bool" = 16 + let repr = Repr.bool true in 17 + repr |> dump_kind; 18 + [%expect {| bool |}] 19 + ;; 20 + 21 + let%expect_test "kind of int" = 22 + let repr = Repr.int 42 in 23 + repr |> dump_kind; 24 + [%expect {| int |}] 25 + ;; 26 + 27 + let%expect_test "kind of int64" = 28 + let repr = Repr.int64 42L in 29 + repr |> dump_kind; 30 + [%expect {| int64 |}] 31 + ;; 32 + 33 + let%expect_test "kind of float" = 34 + let repr = Repr.float 42.2 in 35 + repr |> dump_kind; 36 + [%expect {| float |}] 37 + ;; 38 + 39 + let%expect_test "kind of char" = 40 + let repr = Repr.char '0' in 41 + repr |> dump_kind; 42 + [%expect {| char |}] 43 + ;; 44 + 45 + let%expect_test "kind of string" = 46 + let repr = Repr.string "Hello World" in 47 + repr |> dump_kind; 48 + [%expect {| string |}] 49 + ;; 50 + 51 + let%expect_test "kind of pair" = 52 + let repr = Repr.(pair int int) 42 32 in 53 + repr |> dump_kind; 54 + [%expect {| int * int |}] 55 + ;; 56 + 57 + let%expect_test "kind of pair" = 58 + let repr = Repr.(pair int string) 42 "foo" in 59 + repr |> dump_kind; 60 + [%expect {| int * string |}] 61 + ;; 62 + 63 + let%expect_test "kind of pair" = 64 + let repr = Repr.(quad int string bool unit) 42 "foo" false () in 65 + repr |> dump_kind; 66 + [%expect {| int * string * bool * unit |}] 67 + ;; 68 + 69 + let%expect_test "kind of list" = 70 + let repr = Repr.(list int) [ 42; 32; 12343; 32 ] in 71 + repr |> dump_kind; 72 + [%expect {| list(int) |}] 73 + ;; 74 + 75 + let%expect_test "kind of list" = 76 + let repr = 77 + Repr.(Lit.list) 78 + Repr.[ int 42; float 32.; string "Hello"; string "hello"; int 23 ] 79 + in 80 + repr |> dump_kind; 81 + [%expect {| list(string | int | float) |}] 82 + ;; 83 + 84 + let%expect_test "kind of record" = 85 + let repr = 86 + let open Repr in 87 + record [ "foo", string "Hello"; "bar", int 22 ] 88 + in 89 + repr |> dump_kind; 90 + [%expect {| record{ [bar] int; [foo] string } |}] 91 + ;; 92 + 93 + let%expect_test "kind of record" = 94 + let repr = 95 + let open Repr in 96 + record [ "foo", string "Hello"; "bar", int 22; "baz", Lit.list [] ] 97 + in 98 + repr |> dump_kind; 99 + [%expect {| record{ [bar] int; [baz] list(any); [foo] string } |}] 100 + ;; 101 + 102 + let%expect_test "kind of record" = 103 + let repr = 104 + let open Repr in 105 + record 106 + [ "foo", string "Hello" 107 + ; "bar", int 22 108 + ; ( "baz" 109 + , Lit.list 110 + [ int 42 111 + ; float 32. 112 + ; string "Hello" 113 + ; string "hello" 114 + ; int 23 115 + ; unit () 116 + ] ) 117 + ] 118 + in 119 + repr |> dump_kind; 120 + [%expect 121 + {| record{ [bar] int; [baz] list(unit | string | int | float); [foo] string } |}] 122 + ;;