Skip to content

Commit

Permalink
actually run the tests in the syntax/run folder
Browse files Browse the repository at this point in the history
  • Loading branch information
TimWhiting committed Apr 10, 2024
1 parent 8381e9e commit b76d3aa
Show file tree
Hide file tree
Showing 52 changed files with 55 additions and 21 deletions.
6 changes: 3 additions & 3 deletions src/Type/InferMonad.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1460,9 +1460,9 @@ filterMatchNameContextEx range ctx candidates
matchArgs :: Bool -> [Type] -> [(Name,Type)] -> Maybe Type -> (Name,NameInfo) -> Inf [(Name,NameInfo,Rho)]
matchArgs matchSome fixed named mbResTp (name,info)
= do free <- freeInGamma
-- traceDefDoc $ \penv -> text " match fixed:" <+> list [Pretty.ppType penv fix | fix <- fixed]
-- <+> text ", named" <+> list [Pretty.ppParam penv nametp | nametp <- named]
-- <+> text "on" <+> Pretty.ppParam penv (name,infoType info)
-- traceDefDoc $ \penv -> text " match fixed:" <+> list [Pretty.ppType penv fix | fix <- fixed]
-- <+> text ", named" <+> list [Pretty.ppParam penv nametp | nametp <- named]
-- <+> text "on" <+> Pretty.ppParam penv (name,infoType info)
res <- runUnify (matchArguments matchSome range free (infoType info) fixed named mbResTp)
case res of
(Right rho,_) -> return [(name,info,rho)]
Expand Down
2 changes: 1 addition & 1 deletion src/Type/Unify.hs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ matchArguments matchSome range free tp fixed named mbExpResTp
Just (pars,_,resTp)
-> if (length fixed + length named > length pars)
then unifyError NoMatch
else do trace (" matchArguments: " ++ show (map pretty pars, map pretty fixed, map pretty named)) $ return ()
else do -- trace (" matchArguments: " ++ show (map pretty pars, map pretty fixed, map pretty named)) $ return ()
-- subsume fixed parameters
let parsNotNamedArg = filter (\(nm,tp) -> nm `notElem` map fst named) pars
let (fpars,rest) = splitAt (length fixed) parsNotNamedArg
Expand Down
1 change: 0 additions & 1 deletion test/syntax/config.json

This file was deleted.

Empty file removed test/syntax/named-anywhere.kk.out
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions test/syntax/no-run/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"flags": "-l"
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions test/syntax/no-run/wrong/braces1.kk.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
test/syntax/no-run/wrong/braces1@kk(4,15): parse error: invalid syntax
unexpected ")"
expecting ":", guard condition "|", "->" or "{"
File renamed without changes.
3 changes: 3 additions & 0 deletions test/syntax/no-run/wrong/braces2.kk.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
test/syntax/no-run/wrong/braces2@kk(4,15): parse error: invalid syntax
unexpected "->"
expecting "," or ")"
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
test/syntax/wrong/unused1@kk(2, 5): parse error: invalid syntax
test/syntax/no-run/wrong/unused1@kk(2, 5): parse error: invalid syntax
unexpected 2
expecting "@", "(", "[", "{", "fn", operator, ":=", ";", "return" or "}"
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
test/syntax/wrong/unused2@kk(2, 9): parse error: invalid syntax
test/syntax/no-run/wrong/unused2@kk(2, 9): parse error: invalid syntax
unexpected identifier "print"
expecting "@", "(", "[", "{", "fn", operator, ":=", ";", "return" or "}"
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
test/syntax/wrong/unused3@kk(3, 5): parse error: invalid syntax
test/syntax/no-run/wrong/unused3@kk(3, 5): parse error: invalid syntax
unexpected identifier "xs"
expecting "@", "(", "[", "{", "fn", operator, ":=", ";", "return" or "}"
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
test/syntax/wrong/utf1@kk(4,13): type error: types do not match
test/syntax/no-run/wrong/utf1@kk(4,13): type error: types do not match
context : 2 + "hello effectful world!"
term : "hello effectful world!"
inferred type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
// All formal parameters are named after all (except for higher order functions, which typically use only required arguments - can they use even use optional?).

fun f(required: int, trailingrequired: () -> int, optional: int = 1, ?an-implicit: int): console ()
println(required.show ++ " + " ++ trailingrequired().show ++ " + " ++ optional.show ++ " + " ++ ?an-implicit.show)
val result = required + optional + ?an-implicit + trailingrequired()
println(result)

Expand All @@ -16,16 +17,16 @@ fun f2(required: int, fx: (int, ?c:int) -> int): int

val basic/an-implicit = 3

fun test-named-anywhere()
fun main()
// Normal ordering, using default values for optional parameters
f(1, {1})
f(1, {0})
// Pass an optional parameter as a fixed argument
f(1, {2}, 3)
// Defer trailing lambda till after named arguments (this is the main use case for this feature)
f(1, optional=2) fn() 1
// Named argument first, including implicits
f(?an-implicit=3, optional=0, 1, {2})
f(?an-implicit=10, optional=0, 1, {2})
// Use name for required argument to intentionally change order
f(?an-implicit=3, optional=0, trailingrequired={2}, 1)
f(trailingrequired=fn() 1, 1)
f(optional=0, ?an-implicit=30, trailingrequired={2}, 1)
f(trailingrequired=fn() 1, -1)

12 changes: 12 additions & 0 deletions test/syntax/run/named-anywhere.kk.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
1 + 0 + 1 + 3
5
1 + 2 + 3 + 3
9
1 + 1 + 2 + 3
7
1 + 2 + 0 + 10
13
1 + 2 + 0 + 30
33
-1 + 1 + 1 + 3
4
File renamed without changes.
9 changes: 9 additions & 0 deletions test/syntax/run/pattern-match-in-param.kk.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
f(2, [1], Just([2, 3])) -> 6
f(1, [1], Just([1])) -> syntax/run/pattern-match-in-param(1,34): f: pattern match failure
g(1, 2) -> 1
h([2,3]) -> 2
h() -> 1
i(0) -> 1
j(0) -> 1
k([]) -> syntax/run/pattern-match-in-param(23,12): k: pattern match failure
l((1, 2, 3)) -> 1
Empty file.
2 changes: 1 addition & 1 deletion test/syntax/run/tail.kk
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ fun min-by-rec(l : list<a>, ordering : a -> float64, default : a, smallest : flo
min-by-rec(tail, ordering, default, smallest, result)

pub fun main()
min-by([1.0, 2.0], id, 0.0)
min-by([1.0, 2.0], id, 0.0).println
5 changes: 5 additions & 0 deletions test/syntax/run/tail.kk.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
test/syntax/run/tail@kk(17,37): type error: types do not match
context : min-by([1@0, 2@0], id, 0@0)@println
term :
inferred type: (d : float64, precision : ? int) -> _e string
expected type: (float64) -> string
5 changes: 5 additions & 0 deletions test/syntax/run/tail2.kk.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
test/syntax/run/tail@kk(17,37): type error: types do not match
context : min-by([1@0, 2@0], id, 0@0)@println
term :
inferred type: (d : float64, precision : ? int) -> _e string
expected type: (float64) -> string
3 changes: 0 additions & 3 deletions test/syntax/wrong/braces1.kk.out

This file was deleted.

3 changes: 0 additions & 3 deletions test/syntax/wrong/braces2.kk.out

This file was deleted.

0 comments on commit b76d3aa

Please sign in to comment.