Skip to content

Commit 2ad12d0

Browse files
committed
Add examples/base
1 parent b51bb85 commit 2ad12d0

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

examples/base/preloaded.ml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
open Base
2+
3+
let print_int_list = Fn.compose Sexp.to_string (sexp_of_list sexp_of_int)

examples/base/solution.ml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
open Base
2+
3+
let cubes = List.map ~f:Int.(fun x -> x ** 3)

examples/base/tests.ml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
open Base
2+
open OUnit
3+
open Preloaded
4+
5+
let suite = [
6+
(* "sum tests" >:::
7+
[
8+
"Testing 1" >:: (fun _ -> assert_equal 1 (Solution.sum 1) ~printer:print_int);
9+
"Testing 9" >:: (fun _ -> assert_equal 45 (Solution.sum 9) ~printer:print_int);
10+
]; *)
11+
"cubes tests (passing)" >:::
12+
[
13+
"Testing [1; 2; 3]" >:: (fun _ -> assert_equal [1; 8; 27] (Solution.cubes (List.range 1 4)) ~printer:print_int_list);
14+
"Testing [5]" >:: (fun _ -> assert_equal [125] (Solution.cubes [5]) ~printer:print_int_list);
15+
];
16+
"cubes tests (failing)" >:::
17+
[
18+
"Testing [1; 2; 3]" >:: (fun _ -> assert_equal [1; 8; 27] (Solution.cubes (List.range 1 5)) ~printer:print_int_list);
19+
];
20+
]

0 commit comments

Comments
 (0)