Skip to content

Commit bbfc1b9

Browse files
authored
Merge pull request #302 from pfitaxel/impl-gh50-ppx-prot
Extend ppx_metaquot with an extension point [%funty: _ -> _]
2 parents 73ee1e9 + c08394b commit bbfc1b9

File tree

10 files changed

+448
-231
lines changed

10 files changed

+448
-231
lines changed

demo-repository/exercises/demo/descr.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ <h2>The task</h2>
5656
</li>
5757
</ul>
5858
</li>
59+
<li>
60+
Write a function <code>sum3</code> of type <code>int -> int -> int -> int</code>.
5961
</ol>
6062

6163
<p>

demo-repository/exercises/demo/solution.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ let minus_tests = [((1, 1), 0)]
99

1010
let divide = ( / )
1111
let divide_tests = [((2, 2), 1)]
12+
13+
let sum3 a b c = a + b + c

demo-repository/exercises/demo/test.ml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,15 @@ let test_divide () =
4040
[%ty : int -> int -> int ] "divide"
4141
[ ("Multiplies instead of dividing", 1, fun x y -> x * y) ]
4242

43+
let test_sum3 () =
44+
test_function_against_solution
45+
~gen:2 (* only 2 random test cases *)
46+
[%funty: int -> int -> int -> int] (* function type *)
47+
"sum3" (* function name *)
48+
(* list of additional, explicit test cases *)
49+
[ 10 @: 20 @:!! 30 ;
50+
-1 @: -2 @:!! -3 ]
51+
4352
let () =
4453
set_result @@
4554
ast_sanity_check code_ast @@ fun () ->
@@ -54,4 +63,7 @@ let () =
5463
test_times ()) ;
5564
Section
5665
([ Text "Function:" ; Code "divide" ],
57-
test_divide ()) ]
66+
test_divide ()) ;
67+
Section
68+
([ Text "Function:" ; Code "sum3" ],
69+
test_sum3 ()) ]

src/grader/dune

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@
105105
%{ocaml-config:standard_library}/compiler-libs/parse.cmi)
106106
(:generated-cmis
107107
../ppx-metaquot/.ty.objs/ty.cmi
108+
../ppx-metaquot/.fun_ty.objs/fun_ty.cmi
108109
.testing.objs/introspection_intf.cmi
109110
.learnocaml_report.objs/learnocaml_report.cmi
110111
.testing.objs/test_lib.cmi

0 commit comments

Comments
 (0)