]> git.madduck.net Git - etc/vim.git/blob - tests/data/py_310/pattern_matching_complex.py

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Drop support for parsing Python 2 (#3933)
[etc/vim.git] / tests / data / py_310 / pattern_matching_complex.py
1 # Cases sampled from Lib/test/test_patma.py
2
3 # case black_test_patma_098
4 match x:
5     case -0j:
6         y = 0
7 # case black_test_patma_142
8 match x:
9     case bytes(z):
10         y = 0
11 # case black_test_patma_073
12 match x:
13     case 0 if 0:
14         y = 0
15     case 0 if 1:
16         y = 1
17 # case black_test_patma_006
18 match 3:
19     case 0 | 1 | 2 | 3:
20         x = True
21 # case black_test_patma_049
22 match x:
23     case [0, 1] | [1, 0]:
24         y = 0
25 # case black_check_sequence_then_mapping
26 match x:
27     case [*_]:
28         return "seq"
29     case {}:
30         return "map"
31 # case black_test_patma_035
32 match x:
33     case {0: [1, 2, {}]}:
34         y = 0
35     case {0: [1, 2, {}] | True} | {1: [[]]} | {0: [1, 2, {}]} | [] | "X" | {}:
36         y = 1
37     case []:
38         y = 2
39 # case black_test_patma_107
40 match x:
41     case 0.25 + 1.75j:
42         y = 0
43 # case black_test_patma_097
44 match x:
45     case -0j:
46         y = 0
47 # case black_test_patma_007
48 match 4:
49     case 0 | 1 | 2 | 3:
50         x = True
51 # case black_test_patma_154
52 match x:
53     case 0 if x:
54         y = 0
55 # case black_test_patma_134
56 match x:
57     case {1: 0}:
58         y = 0
59     case {0: 0}:
60         y = 1
61     case {**z}:
62         y = 2
63 # case black_test_patma_185
64 match Seq():
65     case [*_]:
66         y = 0
67 # case black_test_patma_063
68 match x:
69     case 1:
70         y = 0
71     case 1:
72         y = 1
73 # case black_test_patma_248
74 match x:
75     case {"foo": bar}:
76         y = bar
77 # case black_test_patma_019
78 match (0, 1, 2):
79     case [0, 1, *x, 2]:
80         y = 0
81 # case black_test_patma_052
82 match x:
83     case [0]:
84         y = 0
85     case [1, 0] if (x := x[:0]):
86         y = 1
87     case [1, 0]:
88         y = 2
89 # case black_test_patma_191
90 match w:
91     case [x, y, *_]:
92         z = 0
93 # case black_test_patma_110
94 match x:
95     case -0.25 - 1.75j:
96         y = 0
97 # case black_test_patma_151
98 match (x,):
99     case [y]:
100         z = 0
101 # case black_test_patma_114
102 match x:
103     case A.B.C.D:
104         y = 0
105 # case black_test_patma_232
106 match x:
107     case None:
108         y = 0
109 # case black_test_patma_058
110 match x:
111     case 0:
112         y = 0
113 # case black_test_patma_233
114 match x:
115     case False:
116         y = 0
117 # case black_test_patma_078
118 match x:
119     case []:
120         y = 0
121     case [""]:
122         y = 1
123     case "":
124         y = 2
125 # case black_test_patma_156
126 match x:
127     case z:
128         y = 0
129 # case black_test_patma_189
130 match w:
131     case [x, y, *rest]:
132         z = 0
133 # case black_test_patma_042
134 match x:
135     case (0 as z) | (1 as z) | (2 as z) if z == x % 2:
136         y = 0
137 # case black_test_patma_034
138 match x:
139     case {0: [1, 2, {}]}:
140         y = 0
141     case {0: [1, 2, {}] | False} | {1: [[]]} | {0: [1, 2, {}]} | [] | "X" | {}:
142         y = 1
143     case []:
144         y = 2