Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

run testcase #925

Open
frehberg opened this issue Jan 13, 2022 · 0 comments
Open

run testcase #925

frehberg opened this issue Jan 13, 2022 · 0 comments

Comments

@frehberg
Copy link
Contributor

frehberg commented Jan 13, 2022

Please tell me , how to execute unit-tests based on std.test

I modified the testcase from tests/pass/alternative.glu, changing final line to "run tests" (see below). But when I try to execute the file alternative.glu , the following error message shows up in console

$ gluon alternative.glu 
error: Expected the following types to be equal
Expected: std.effect.Eff [| ... | a |] a
Found: forall r . std.test.TestCase r ()
2 errors were found during unification:
Row labels do not match.
    Expected: Pure
    Found: Test
Row labels do not match.
    Expected: Impure
    Found: Group
   ┌─ alternative:28:5
   │
28 │ run tests
   │     ^^^^^

Please can you explain, how to execute the group "tests" ?


let { run, Test, TestCase, assert_eq, test, group, ? } = import! std.test
let { (<|) } = import! std.function
let prelude @ { Alternative } = import! std.prelude
let { Applicative, (*>) } = import! std.applicative
let int = import! std.int
let list @ { ? }= import! std.list
let option = import! std.option
let { (<|>), or, empty } = import! std.alternative

let test_alt ?alt show eq : [Alternative f] -> Show (f Int) -> Eq (f Int) -> _ =
    let { wrap } = alt.applicative

    let assert = assert_eq ?show ?eq

    [
        test "empty equal" <| \_ -> (assert empty empty),
        test "or selects non-empty" <| \_ -> (assert (empty <|> wrap 1) (wrap 1)),
        test "empty <|> empty == empty" <| \_ -> (assert (empty <|> empty) empty),
        test "or selects non-empty 2" <| \_ -> (assert (empty <|> empty <|> wrap 10) (wrap 10))
    ]

let tests: TestCase r () =
    group "alternative" [
        group "option" (test_alt option.show option.eq),
        group "list" (test_alt list.show list.eq)
    ]
    
run tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant