Blame test/test_ExtHashtbl.ml
|
rpm-build |
0f2925 |
(*
|
|
rpm-build |
0f2925 |
* ExtLib Testing Suite
|
|
rpm-build |
0f2925 |
* Copyright (C) 2013 ygrek
|
|
rpm-build |
0f2925 |
*
|
|
rpm-build |
0f2925 |
* This library is free software; you can redistribute it and/or
|
|
rpm-build |
0f2925 |
* modify it under the terms of the GNU Lesser General Public
|
|
rpm-build |
0f2925 |
* License as published by the Free Software Foundation; either
|
|
rpm-build |
0f2925 |
* version 2.1 of the License, or (at your option) any later version,
|
|
rpm-build |
0f2925 |
* with the special exception on linking described in file LICENSE.
|
|
rpm-build |
0f2925 |
*
|
|
rpm-build |
0f2925 |
* This library is distributed in the hope that it will be useful,
|
|
rpm-build |
0f2925 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
rpm-build |
0f2925 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
rpm-build |
0f2925 |
* Lesser General Public License for more details.
|
|
rpm-build |
0f2925 |
*
|
|
rpm-build |
0f2925 |
* You should have received a copy of the GNU Lesser General Public
|
|
rpm-build |
0f2925 |
* License along with this library; if not, write to the Free Software
|
|
rpm-build |
0f2925 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
rpm-build |
0f2925 |
*)
|
|
rpm-build |
0f2925 |
|
|
rpm-build |
0f2925 |
open ExtHashtbl
|
|
rpm-build |
0f2925 |
|
|
rpm-build |
0f2925 |
(* Issue 26: Hashtbl.map is broken in OCaml >= 4.00 *)
|
|
rpm-build |
0f2925 |
let test_map () =
|
|
rpm-build |
0f2925 |
let h = Hashtbl.create 1 in
|
|
rpm-build |
0f2925 |
Hashtbl.add h "test" 1;
|
|
rpm-build |
0f2925 |
let h1 = Hashtbl.map (fun x -> x + 1) h in
|
|
rpm-build |
0f2925 |
let find h k = try Some (Hashtbl.find h k) with Not_found -> None in
|
|
rpm-build |
0f2925 |
assert (find h "test" = Some 1);
|
|
rpm-build |
0f2925 |
assert (find h1 "test" = Some 2)
|
|
rpm-build |
0f2925 |
|
|
rpm-build |
0f2925 |
let () =
|
|
rpm-build |
0f2925 |
Util.register1 "ExtHashtbl" "map" test_map
|