-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename option to toggle switch functions. (#919)
This commit renames the option `pattern_matching_sugar` to `switch_functions` as the former is somewhat generic and the latter is the name of the feature actually being enabled/disabled by toggling the option. In addition, this commit also cleans up the test suite for functions. The non-experimental function features should not be kept in the same test file as the experimental features -- in particular, the non-experimental features should not **always** be tested under the assumption that an experimental flag is enabled.
- Loading branch information
Showing
5 changed files
with
41 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
switch_functions=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
config: tests/switch_functions.config | ||
--- | ||
|
||
Switch fun (syntax check) | ||
fun foo(_) switch { case x -> x } foo | ||
stdout : fun : (a) ~> a | ||
|
||
Ackermann switch fun (1) | ||
fun ack(_,_) switch { case (0, n) -> n + 1 case (m, 0) -> ack(m - 1, 1) case (m, n) -> ack(m - 1, ack(m, n - 1)) } ack | ||
stdout : fun : (Int, Int) ~> Int | ||
|
||
Ackermann switch fun (2) | ||
fun ack(_,_) switch { case (0, n) -> n + 1 case (m, 0) -> ack(m - 1, 1) case (m, n) -> ack(m - 1, ack(m, n - 1)) } fun test() { print(intToString(ack(0,1))); print(intToString(ack(1,0))); print(intToString(ack(1,1))) } test() | ||
stdout : 223() : () | ||
|
||
Curried switch fun | ||
fun foo(_)(_) switch { case (x, y) -> x + y } foo | ||
stderr : @.*Curried switch functions are not yet supported.* | ||
exit : 1 | ||
|
||
Switch fun: runtime non-exhaustive error | ||
fun foo(_) switch { case 1 -> 1 } foo(0) | ||
stderr : @.*non-exhaustive pattern matching.* | ||
exit : 1 | ||
|
||
Switch fun: matching over nullary function | ||
fun f() switch { case n -> 1 } | ||
stderr : @.*Can't match over nullary function.* | ||
exit : 1 | ||
|
||
Anonymous switch fun | ||
fun(s) switch { case x -> x } | ||
stdout : fun : (a) ~> a |