package base_trie

  1. Overview
  2. Docs

Source file trie_stable_test.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
open! Core
open Expect_test_helpers_core

module _ : module type of Trie_stable = struct
  module V1 = Trie_stable.V1

  let%expect_test _ =
    let module T1 = V1 (Trie.Keychainable.Of_string) (String.Stable.V1) in
    let module T0 = struct
      type t = int T1.t [@@deriving bin_io, compare, sexp]
    end
    in
    let examples =
      [ []
      ; [ "", 0 ]
      ; [ "a", 1 ]
      ; [ "b", 2 ]
      ; [ "a", 1; "b", 2 ]
      ; [ "a", 1; "ab", 12; "b", 2; "ba", 21 ]
      ; [ "", 0; "a", 1; "ab", 2; "abc", 3; "abcd", 4; "abcde", 5; "abcdef", 6 ]
      ; List.init 256 ~f:(fun i -> sprintf "%02x" i, i)
      ]
      |> List.map ~f:(Trie.of_alist_exn Trie.Keychainable.Of_string.keychainable)
    in
    Ref.set_temporarily sexp_style Sexp_style.To_string_hum ~f:(fun () ->
      print_and_check_stable_type [%here] (module T0) examples);
    [%expect
      {|
      (bin_shape_digest dffef12720ad2729e32e97f67db1d1f6)
      ((sexp ()) (bin_io "\000"))
      ((sexp (("" 0))) (bin_io "\001\000\000"))
      ((sexp ((a 1))) (bin_io "\001\001a\001"))
      ((sexp ((b 2))) (bin_io "\001\001b\002"))
      ((sexp ((a 1) (b 2))) (bin_io "\002\001a\001\001b\002"))
      ((sexp ((a 1) (ab 12) (b 2) (ba 21)))
       (bin_io "\004\001a\001\002ab\012\001b\002\002ba\021"))
      ((sexp (("" 0) (a 1) (ab 2) (abc 3) (abcd 4) (abcde 5) (abcdef 6)))
       (bin_io
        "\007\000\000\001a\001\002ab\002\003abc\003\004abcd\004\005abcde\005\006abcdef\006"))
      ((sexp
        ((00 0) (01 1) (02 2) (03 3) (04 4) (05 5) (06 6) (07 7) (08 8) (09 9)
         (0a 10) (0b 11) (0c 12) (0d 13) (0e 14) (0f 15) (10 16) (11 17) (12 18)
         (13 19) (14 20) (15 21) (16 22) (17 23) (18 24) (19 25) (1a 26) (1b 27)
         (1c 28) (1d 29) (1e 30) (1f 31) (20 32) (21 33) (22 34) (23 35) (24 36)
         (25 37) (26 38) (27 39) (28 40) (29 41) (2a 42) (2b 43) (2c 44) (2d 45)
         (2e 46) (2f 47) (30 48) (31 49) (32 50) (33 51) (34 52) (35 53) (36 54)
         (37 55) (38 56) (39 57) (3a 58) (3b 59) (3c 60) (3d 61) (3e 62) (3f 63)
         (40 64) (41 65) (42 66) (43 67) (44 68) (45 69) (46 70) (47 71) (48 72)
         (49 73) (4a 74) (4b 75) (4c 76) (4d 77) (4e 78) (4f 79) (50 80) (51 81)
         (52 82) (53 83) (54 84) (55 85) (56 86) (57 87) (58 88) (59 89) (5a 90)
         (5b 91) (5c 92) (5d 93) (5e 94) (5f 95) (60 96) (61 97) (62 98) (63 99)
         (64 100) (65 101) (66 102) (67 103) (68 104) (69 105) (6a 106) (6b 107)
         (6c 108) (6d 109) (6e 110) (6f 111) (70 112) (71 113) (72 114) (73 115)
         (74 116) (75 117) (76 118) (77 119) (78 120) (79 121) (7a 122) (7b 123)
         (7c 124) (7d 125) (7e 126) (7f 127) (80 128) (81 129) (82 130) (83 131)
         (84 132) (85 133) (86 134) (87 135) (88 136) (89 137) (8a 138) (8b 139)
         (8c 140) (8d 141) (8e 142) (8f 143) (90 144) (91 145) (92 146) (93 147)
         (94 148) (95 149) (96 150) (97 151) (98 152) (99 153) (9a 154) (9b 155)
         (9c 156) (9d 157) (9e 158) (9f 159) (a0 160) (a1 161) (a2 162) (a3 163)
         (a4 164) (a5 165) (a6 166) (a7 167) (a8 168) (a9 169) (aa 170) (ab 171)
         (ac 172) (ad 173) (ae 174) (af 175) (b0 176) (b1 177) (b2 178) (b3 179)
         (b4 180) (b5 181) (b6 182) (b7 183) (b8 184) (b9 185) (ba 186) (bb 187)
         (bc 188) (bd 189) (be 190) (bf 191) (c0 192) (c1 193) (c2 194) (c3 195)
         (c4 196) (c5 197) (c6 198) (c7 199) (c8 200) (c9 201) (ca 202) (cb 203)
         (cc 204) (cd 205) (ce 206) (cf 207) (d0 208) (d1 209) (d2 210) (d3 211)
         (d4 212) (d5 213) (d6 214) (d7 215) (d8 216) (d9 217) (da 218) (db 219)
         (dc 220) (dd 221) (de 222) (df 223) (e0 224) (e1 225) (e2 226) (e3 227)
         (e4 228) (e5 229) (e6 230) (e7 231) (e8 232) (e9 233) (ea 234) (eb 235)
         (ec 236) (ed 237) (ee 238) (ef 239) (f0 240) (f1 241) (f2 242) (f3 243)
         (f4 244) (f5 245) (f6 246) (f7 247) (f8 248) (f9 249) (fa 250) (fb 251)
         (fc 252) (fd 253) (fe 254) (ff 255)))
       (bin_io
         "\254\000\001\00200\000\00201\001\00202\002\00203\003\00204\004\00205\005\00206\006\00207\007\00208\b\00209\t\0020a\
        \n\0020b\011\0020c\012\0020d\r\0020e\014\0020f\015\00210\016\00211\017\00212\018\00213\019\00214\020\00215\021\00216\022\00217\023\00218\024\00219\025\0021a\026\0021b\027\0021c\028\0021d\029\0021e\030\0021f\031\00220 \00221!\00222\"\00223#\00224$\00225%\00226&\00227'\00228(\00229)\0022a*\0022b+\0022c,\0022d-\0022e.\0022f/\002300\002311\002322\002333\002344\002355\002366\002377\002388\002399\0023a:\0023b;\0023c<\0023d=\0023e>\0023f?\00240@\00241A\00242B\00243C\00244D\00245E\00246F\00247G\00248H\00249I\0024aJ\0024bK\0024cL\0024dM\0024eN\0024fO\00250P\00251Q\00252R\00253S\00254T\00255U\00256V\00257W\00258X\00259Y\0025aZ\0025b[\0025c\\\0025d]\0025e^\0025f_\00260`\00261a\00262b\00263c\00264d\00265e\00266f\00267g\00268h\00269i\0026aj\0026bk\0026cl\0026dm\0026en\0026fo\00270p\00271q\00272r\00273s\00274t\00275u\00276v\00277w\00278x\00279y\0027az\0027b{\0027c|\0027d}\0027e~\0027f\127\00280\254\128\000\00281\254\129\000\00282\254\130\000\00283\254\131\000\00284\254\132\000\00285\254\133\000\00286\254\134\000\00287\254\135\000\00288\254\136\000\00289\254\137\000\0028a\254\138\000\0028b\254\139\000\0028c\254\140\000\0028d\254\141\000\0028e\254\142\000\0028f\254\143\000\00290\254\144\000\00291\254\145\000\00292\254\146\000\00293\254\147\000\00294\254\148\000\00295\254\149\000\00296\254\150\000\00297\254\151\000\00298\254\152\000\00299\254\153\000\0029a\254\154\000\0029b\254\155\000\0029c\254\156\000\0029d\254\157\000\0029e\254\158\000\0029f\254\159\000\002a0\254\160\000\002a1\254\161\000\002a2\254\162\000\002a3\254\163\000\002a4\254\164\000\002a5\254\165\000\002a6\254\166\000\002a7\254\167\000\002a8\254\168\000\002a9\254\169\000\002aa\254\170\000\002ab\254\171\000\002ac\254\172\000\002ad\254\173\000\002ae\254\174\000\002af\254\175\000\002b0\254\176\000\002b1\254\177\000\002b2\254\178\000\002b3\254\179\000\002b4\254\180\000\002b5\254\181\000\002b6\254\182\000\002b7\254\183\000\002b8\254\184\000\002b9\254\185\000\002ba\254\186\000\002bb\254\187\000\002bc\254\188\000\002bd\254\189\000\002be\254\190\000\002bf\254\191\000\002c0\254\192\000\002c1\254\193\000\002c2\254\194\000\002c3\254\195\000\002c4\254\196\000\002c5\254\197\000\002c6\254\198\000\002c7\254\199\000\002c8\254\200\000\002c9\254\201\000\002ca\254\202\000\002cb\254\203\000\002cc\254\204\000\002cd\254\205\000\002ce\254\206\000\002cf\254\207\000\002d0\254\208\000\002d1\254\209\000\002d2\254\210\000\002d3\254\211\000\002d4\254\212\000\002d5\254\213\000\002d6\254\214\000\002d7\254\215\000\002d8\254\216\000\002d9\254\217\000\002da\254\218\000\002db\254\219\000\002dc\254\220\000\002dd\254\221\000\002de\254\222\000\002df\254\223\000\002e0\254\224\000\002e1\254\225\000\002e2\254\226\000\002e3\254\227\000\002e4\254\228\000\002e5\254\229\000\002e6\254\230\000\002e7\254\231\000\002e8\254\232\000\002e9\254\233\000\002ea\254\234\000\002eb\254\235\000\002ec\254\236\000\002ed\254\237\000\002ee\254\238\000\002ef\254\239\000\002f0\254\240\000\002f1\254\241\000\002f2\254\242\000\002f3\254\243\000\002f4\254\244\000\002f5\254\245\000\002f6\254\246\000\002f7\254\247\000\002f8\254\248\000\002f9\254\249\000\002fa\254\250\000\002fb\254\251\000\002fc\254\252\000\002fd\254\253\000\002fe\254\254\000\002ff\254\255\000"))
      |}]
  ;;
end
OCaml

Innovation. Community. Security.