File: test_ExtHashtbl.ml

package info (click to toggle)
extlib 1.7.7-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 632 kB
  • sloc: ml: 6,980; makefile: 128; sh: 42; ansic: 31
file content (33 lines) | stat: -rw-r--r-- 1,255 bytes parent folder | download | duplicates (2)
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
(*
 * ExtLib Testing Suite
 * Copyright (C) 2013 ygrek
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version,
 * with the special exception on linking described in file LICENSE.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *)

open ExtHashtbl

(* Issue 26: Hashtbl.map is broken in OCaml >= 4.00 *)
let test_map () =
  let h = Hashtbl.create 1 in
  Hashtbl.add h "test" 1;
  let h1 = Hashtbl.map (fun x -> x + 1) h in
  let find h k = try Some (Hashtbl.find h k) with Not_found -> None in
  assert (find h "test" = Some 1);
  assert (find h1 "test" = Some 2)

let () = 
  Util.register1 "ExtHashtbl" "map" test_map