From 52ced721794fabbf37981fe049f530305f4edf86 Mon Sep 17 00:00:00 2001 From: "Terence D. Honles" Date: Mon, 6 May 2024 18:39:05 +0200 Subject: [PATCH] add functional enum test --- test-data/unit/check-python310.test | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test-data/unit/check-python310.test b/test-data/unit/check-python310.test index adbdb9c081f8c..303807ec1fb0c 100644 --- a/test-data/unit/check-python310.test +++ b/test-data/unit/check-python310.test @@ -1520,6 +1520,24 @@ match m: [builtins fixtures/tuple.pyi] +[case testMatchLiteralPatternEnumFunctional] +from enum import Enum +from typing import NoReturn +def assert_never(x: NoReturn) -> None: ... + +Medal = Enum('Medal', 'gold silver bronze') +m: Medal + +match m: + case Medal.gold: + reveal_type(m) # N: Revealed type is "Literal[__main__.Medal.gold]" + case Medal.silver: + reveal_type(m) # N: Revealed type is "Literal[__main__.Medal.silver]" + case Medal.bronze: + reveal_type(m) # N: Revealed type is "Literal[__main__.Medal.bronze]" + case _ as unreachable: + assert_never(unreachable) + [case testMatchLiteralPatternEnumCustomEquals-skip] from enum import Enum class Medal(Enum):