From fe328b2a7be7b292761af68e16efafc6fc3f5b21 Mon Sep 17 00:00:00 2001 From: Geoff Romer Date: Mon, 1 Mar 2021 10:34:50 -0800 Subject: [PATCH] Add test coverage for a trailing comma in the alternatives list, and empty parentheses in an alternative declaration. (#305) --- executable_semantics/testdata/choice1.6c | 7 +++++++ executable_semantics/testdata/choice1.golden | 12 ++++++++++++ 2 files changed, 19 insertions(+) diff --git a/executable_semantics/testdata/choice1.6c b/executable_semantics/testdata/choice1.6c index 29c68baeec97..859dd9312733 100644 --- a/executable_semantics/testdata/choice1.6c +++ b/executable_semantics/testdata/choice1.6c @@ -30,3 +30,10 @@ fn main() -> Int { } return n; } + +// Test some alternate syntaxes +choice MoreInts { + None(), + One(Int), + Two(Int,Int), +} diff --git a/executable_semantics/testdata/choice1.golden b/executable_semantics/testdata/choice1.golden index 1ccf47425002..a6ff8240cf08 100644 --- a/executable_semantics/testdata/choice1.golden +++ b/executable_semantics/testdata/choice1.golden @@ -26,6 +26,11 @@ n = 5; } return n; +} +choice MoreInts { +alt None (); +alt One Int; +alt Two (0 = Int, 1 = Int); } ********** type checking ********** --- step exp () ---> @@ -36,6 +41,13 @@ return n; --- step exp Int ---> --- handle value Int with (0 = Int, 1 = Int)<2>(Int,Int,) ---> --- step exp Int ---> +--- step exp () ---> +--- step exp Int ---> +--- step exp (0 = Int, 1 = Int) ---> +--- step exp Int ---> +--- handle value Int with (0 = Int, 1 = Int)<1>(Int,) ---> +--- step exp Int ---> +--- handle value Int with (0 = Int, 1 = Int)<2>(Int,Int,) ---> --- step exp Int ---> --- step exp auto ---> 13: type error in call