Skip to content

Commit

Permalink
test: Add test to repro issue #440
Browse files Browse the repository at this point in the history
  • Loading branch information
erikmd committed Oct 13, 2021
1 parent 19477a5 commit 07033c9
Show file tree
Hide file tree
Showing 10 changed files with 103 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/test_negative_int/int_exo/correct.ml
@@ -0,0 +1 @@
let aff = fun a b x -> a * x + b
78 changes: 78 additions & 0 deletions tests/test_negative_int/int_exo/correct.ml.json
@@ -0,0 +1,78 @@
[
{
"section": [
{
"text": "Function:"
},
{
"text": "aff",
"display": "code"
}
],
"contents": [
{
"message": [
{
"text": "Found"
},
{
"text": "aff",
"display": "code"
},
{
"text": "with compatible type."
}
],
"result": "informative"
},
{
"message": [
{
"text": "Computing"
},
{
"text": "aff 2 (-1) 5",
"display": "code"
}
],
"result": "informative"
},
{
"message": [
{
"text": "Correct value"
},
{
"text": "9",
"display": "code"
}
],
"result": 1
},
{
"message": [
{
"text": "Computing"
},
{
"text": "aff (-2) 1 5",
"display": "code"
}
],
"result": "informative"
},
{
"message": [
{
"text": "Correct value"
},
{
"text": "(-9)",
"display": "code"
}
],
"result": 1
}
]
}
]
5 changes: 5 additions & 0 deletions tests/test_negative_int/repo/exercises/index.json
@@ -0,0 +1,5 @@
{ "learnocaml_version": "1",
"groups":
{ "demo":
{ "title": "Test negative_int",
"exercises": [ "int_exo" ] } } }
3 changes: 3 additions & 0 deletions tests/test_negative_int/repo/exercises/int_exo/descr.md
@@ -0,0 +1,3 @@
# Test negative_int

This exercise is just a regression test with pretty-printing negative `int`s.
2 changes: 2 additions & 0 deletions tests/test_negative_int/repo/exercises/int_exo/meta.json
@@ -0,0 +1,2 @@
{"learnocaml_version":"1","kind":"exercise","stars":0,
"title":"Test negative_int"}
Empty file.
Empty file.
1 change: 1 addition & 0 deletions tests/test_negative_int/repo/exercises/int_exo/solution.ml
@@ -0,0 +1 @@
let aff a b x = a * x + b
Empty file.
13 changes: 13 additions & 0 deletions tests/test_negative_int/repo/exercises/int_exo/test.ml
@@ -0,0 +1,13 @@
open Test_lib
open Report

let () =
set_result @@
ast_sanity_check code_ast @@ fun () ->
[ Section
([ Text "Function:" ; Code "aff" ],
let prot = [%funty: int -> int -> int -> int] in
test_function_against_solution ~gen:(0) prot "aff"
[2 @: (-1) @:!! 5;
(-2) @: 1 @:!! 5])
]

0 comments on commit 07033c9

Please sign in to comment.