Skip to content

Commit 2e7d7b3

Browse files
authored
Merge pull request #580 from JeroenUH/master
Correctly generate multiple CLI arguments for Haskell
2 parents 3b65304 + a732ee7 commit 2e7d7b3

File tree

4 files changed

+48
-1
lines changed

4 files changed

+48
-1
lines changed

tested/languages/haskell/generators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ def convert_execution_unit(pu: PreparedExecutionUnit) -> str:
241241
if tc.testcase.is_main_testcase():
242242
assert isinstance(tc.input, MainInput)
243243
wrapped = [json.dumps(a) for a in tc.input.arguments]
244-
result += indent + f"let mainArgs = [{' '.join(wrapped)}]\n"
244+
result += indent + f"let mainArgs = [{' ,'.join(wrapped)}]\n"
245245
result += (
246246
indent
247247
+ f"result <- try (withArgs mainArgs {pu.submission_name}.main) :: IO (Either SomeException ())\n"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
- tab: "command_line_arguments"
2+
testcases:
3+
- arguments: [haskell, rust, java, haskell, c, rust]
4+
stdout: "c haskell java rust"
5+
- arguments: ["banana", "apple", "apple", "orange", "apple", "apple", "banana", "orange"]
6+
stdout: "apple banana orange"
7+
- arguments: []
8+
stdout: "\n"
9+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import Data.List (nub, sort)
2+
import System.Environment (getArgs)
3+
4+
main :: IO ()
5+
main = do
6+
args <- getArgs
7+
let uniqueSorted = nub (sort args)
8+
putStrLn (unwords uniqueSorted)

tests/test_cli_args.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import json
2+
from pathlib import Path
3+
4+
import pytest
5+
import yaml
6+
7+
from tested.datatypes import (
8+
AdvancedNothingTypes,
9+
AdvancedSequenceTypes,
10+
BasicNumericTypes,
11+
)
12+
from tested.serialisation import NothingType, NumberType, SequenceType
13+
from tested.utils import sorted_no_duplicates, sorting_value_extract
14+
from tests.manual_utils import assert_valid_output, configuration, execute_config
15+
16+
17+
@pytest.mark.parametrize("language", ["haskell"])
18+
def test_cli_params(language: str, tmp_path: Path, pytestconfig: pytest.Config):
19+
conf = configuration(
20+
pytestconfig,
21+
"dedup",
22+
language,
23+
tmp_path,
24+
"plan.yaml",
25+
"solution",
26+
)
27+
result = execute_config(conf)
28+
print(result)
29+
updates = assert_valid_output(result, pytestconfig)
30+
assert updates.find_status_enum() == ["correct", "correct", "correct"]

0 commit comments

Comments
 (0)