Skip to content

Commit

Permalink
update tests and compatibility document
Browse files Browse the repository at this point in the history
  • Loading branch information
thwfhk committed Sep 19, 2023
1 parent 5d5fa5e commit 6d9c0fa
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 21 deletions.
12 changes: 5 additions & 7 deletions control-flow-linearity-in-Links.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,8 @@ fun : (a::Any) {L:() =@ ()|_::Lin}-> a::Any
## Compatibility
* Compatible with all previous handler tests (except part of
polymorphic operations and effect sugar).
* Not entirely compatible with FreezeML, SessionFail, etc.
* Passes all tests with the flag disabled, except
* `!FAILURE: Operation polymorphism (2)`
* `!FAILURE: Operation polymorphism (3)`
* `!FAILURE: Typecheck example file examples/handlers/monadic_reflection.links`
* Passes all previous tests with the flag disabled.
* Passes all previous effect handler tests with the flag enabled, including
* `/tests/handlers_with_cfl_on.tests`, and
* `/tests/typecheck_examples_with_cfl_on.tests`.
* Not entirely compatible with FreezeML, SessionFail, etc. (?)
31 changes: 17 additions & 14 deletions tests/control_flow_linearity.tests
Original file line number Diff line number Diff line change
@@ -1,85 +1,88 @@
---
config: tests/control_flow_linearity.config
---

Use linear variables in deep handlers (1)
tests/handlers/lin_deep1.links
filemode : true
exit : 1
stderr : @.*Type error: Variable .* of linear type .* is used in a deep handler.*
args : --enable-handlers --track-control-flow-linearity


Use linear variables in deep handlers (2)
tests/handlers/lin_deep2.links
filemode : true
exit : 1
stderr : @.*Type error: Variable .* of linear type .* is used in a deep handler.*
args : --enable-handlers --track-control-flow-linearity


Use linear variables in deep handlers (3)
tests/handlers/lin_deep3.links
filemode : true
exit : 1
stderr : @.*Type error: Variable .* has linear type .* is used .* times.*
args : --enable-handlers --track-control-flow-linearity


Use linear variables in deep handlers (4)
tests/handlers/lin_deep4.links
filemode : true
exit : 1
stderr : @.*Type error: Variable .* of linear type .* is used in a deep handler.*
args : --enable-handlers --track-control-flow-linearity


Linear operation and continuation
handle (lindo Foo(20) + 1) {case <Foo(i) =@ k> -> xlin; k(i)}
stdout : 21 : Int
args : --enable-handlers --track-control-flow-linearity


Non-linear operation and continuation
handle (do Foo(20) + 1) {case <Foo(i) => k> -> k(i) + k(i)}
stdout : 42 : Int
args : --enable-handlers --track-control-flow-linearity


Use linear variable in linear continuation
{linfun f(x) {40+x} handle ({xlin; f(lindo Foo)}) {case <Foo =@ k> -> xlin; k(2)}}
stdout : 42 : Int
args : --enable-handlers --track-control-flow-linearity


Use linear variable in non-linear continuation
{linfun f(x) {x} handle (f(do Foo)) {case <Foo => k> -> k(1)}}
exit : 1
stderr : @.*Type error: Variable .* of linear type .* is used in a non-linear continuation.*
args : --enable-handlers --track-control-flow-linearity


Operation annotation
fun(m) { xlin; handle(m()) { case <Foo(x) =@ k> : ((Int) =@ Int) -> xlin; k (x) } }
stdout : fun : (() {Foo:(Int) =@ Int|a::Lin}~> b::Any) {Foo{_::Lin}|a::Lin}~> b::Any
args : --enable-handlers --track-control-flow-linearity


New implementation of examples/handlers/choose.links
tests/handlers/new_choose.links
filemode : true
stdout : [10, 10, 18, 12, 20] : [Int]
args : --enable-handlers --track-control-flow-linearity


Combine unlimited choice and state
tests/handlers/choose_and_state.links
filemode : true
stdout : [3, 4, 9, 10, 3, 3, 3, 3] : [Int]
args : --enable-handlers --track-control-flow-linearity


Combine linear choice and unlimited state
tests/handlers/choose_and_state2.links
filemode : true
stdout : 3 : Int
args : --enable-handlers --track-control-flow-linearity


Check the first part of Issue 544
tests/handlers/issue544a.links
filemode : true
exit : 1
stderr : @.*Type error: Effect row type .* can not be made linear .*
args : --enable-handlers --track-control-flow-linearity


Check the second part of Issue 544
tests/handlers/issue544b.links
filemode : true
exit : 1
stderr : @.*Type error: Effect row type .* can not be made linear .*
args : --enable-handlers --track-control-flow-linearity
2 changes: 2 additions & 0 deletions tests/typecheck_examples_with_cfl_on.tests
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
config: tests/examples_default_with_cfl_on.config
---

# Only include the files in examples/handlers

Typecheck example file examples/handlers/alert.links
examples/handlers/alert.links
filemode : true
Expand Down

0 comments on commit 6d9c0fa

Please sign in to comment.