Skip to content

Commit

Permalink
Allow Heterogenous arguments in Haskell to allow Ambiguous variable j…
Browse files Browse the repository at this point in the history
…udging
  • Loading branch information
tibvdm committed Oct 1, 2024
1 parent 2b61918 commit 7df8f0d
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 3 deletions.
1 change: 1 addition & 0 deletions tested/languages/haskell/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ def supported_constructs(self) -> set[Construct]:
Construct.ASSIGNMENTS,
Construct.EVALUATION,
Construct.GLOBAL_VARIABLES,
Construct.HETEROGENEOUS_ARGUMENTS
}

def compilation(self, files: list[str]) -> CallbackResult:
Expand Down
6 changes: 3 additions & 3 deletions tested/manual.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from tested.main import run
from tested.testsuite import SupportedLanguage

exercise_dir = "/home/niko/Ontwikkeling/universal-judge/tests/exercises/echo-function"
exercise_dir = "/Users/tibvdm/PycharmProjects/universal-judge/tests/exercises/haskell"


def read_config() -> DodonaConfig:
Expand All @@ -24,10 +24,10 @@ def read_config() -> DodonaConfig:
programming_language=SupportedLanguage("haskell"),
natural_language="nl",
resources=Path(exercise_dir, "evaluation"),
source=Path(exercise_dir, "solution/correct.hs"),
source=Path(exercise_dir, "solution/voorlaatste.hs"),
judge=Path("."),
workdir=Path("workdir"),
test_suite="two-specific.tson",
test_suite="voorlaatste.yaml",
options=Options(
linter=False,
),
Expand Down
43 changes: 43 additions & 0 deletions tests/exercises/haskell/evaluation/voorlaatste.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
tabs:
- tab: 'voorlaatste (Int)'
testcases:
- expression: voorlaatste([1, 2])
return: 1
- expression: voorlaatste([1, 2, 3])
return: 2
- expression: voorlaatste([1, 2, 3, 4])
return: 3
- expression: voorlaatste([1, 2, 3, 4, 5])
return: 4
- expression: voorlaatste([1, 0, 1, 0, 1])
return: 0
- expression: voorlaatste([9, 81, 1, 2, 4, 1, 42, 1])
return: 42
- tab: 'voorlaatste (Double)'
testcases:
- expression: voorlaatste([1.0, 2.0])
return: 1.0
- expression: voorlaatste([1.0, 2.0, 3.0])
return: 2.0
- expression: voorlaatste([1.0, 2.0, 3.0, 4.0])
return: 3.0
- expression: voorlaatste([1.0, 2.0, 3.0, 4.0, 5.0])
return: 4.0
- expression: voorlaatste([1.0, 0.0, 1.0, 0.0, 1.0])
return: 0.0
- expression: voorlaatste([9.0, 81.0, 1.0, 2.0, 4.0, 1.0, 42.0, 1.0])
return: 42.0
- tab: 'voorlaatste (Char)'
testcases:
- expression: voorlaatste(['a', 'b'])
return: 'a'
- expression: voorlaatste(['a', 'b', 'c'])
return: 'b'
- expression: voorlaatste(['a', 'b', 'c', 'd'])
return: 'c'
- expression: voorlaatste(['a', 'b', 'c', 'd', 'e'])
return: 'd'
- expression: voorlaatste(['a', 'b', 'a', 'b', 'a'])
return: 'b'
- expression: voorlaatste(['c', 'd', 'a', 'b', 'g'])
return: 'b'
2 changes: 2 additions & 0 deletions tests/exercises/haskell/solution/voorlaatste.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
voorlaatste :: [a] -> a
voorlaatste = last . init

0 comments on commit 7df8f0d

Please sign in to comment.