Skip to content

Commit 32255d3

Browse files
author
Michal Medvecky
committed
pattern match tests ours, cpython
1 parent 2801fb8 commit 32255d3

File tree

3 files changed

+310
-62
lines changed

3 files changed

+310
-62
lines changed

graalpython/com.oracle.graal.python.test/src/tests/test_patmat.py

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -233,54 +233,6 @@ def test_multiple_or_pattern_creates_locals():
233233
assert y == 6
234234

235235

236-
class TestOriginalPatMa(unittest.TestCase):
237-
@unittest.skipIf(sys.version_info.minor < 10, "Requires Python 3.10+")
238-
def test_patma_246(self):
239-
def f(x):
240-
match x:
241-
case (
242-
(h, g, i, a, b, d, e, c, f, 10) |
243-
(a, b, c, d, e, f, g, h, i, 9) |
244-
(g, b, a, c, d, -5, e, h, i, f) |
245-
(-1, d, f, b, g, e, i, a, h, c)
246-
):
247-
w = 0
248-
out = locals()
249-
del out["x"]
250-
return out
251-
alts = [
252-
dict(a=0, b=1, c=2, d=3, e=4, f=5, g=6, h=7, i=8, w=0),
253-
dict(h=1, g=2, i=3, a=4, b=5, d=6, e=7, c=8, f=9, w=0),
254-
dict(g=0, b=-1, a=-2, c=-3, d=-4, e=-6, h=-7, i=-8, f=-9, w=0),
255-
dict(d=-2, f=-3, b=-4, g=-5, e=-6, i=-7, a=-8, h=-9, c=-10, w=0),
256-
dict(),
257-
]
258-
self.assertEqual(f(range(10)), alts[0])
259-
self.assertEqual(f(range(1, 11)), alts[1])
260-
self.assertEqual(f(range(0, -10, -1)), alts[2])
261-
self.assertEqual(f(range(-1, -11, -1)), alts[3])
262-
self.assertEqual(f(range(10, 20)), alts[4])
263-
264-
@unittest.skipIf(sys.version_info.minor < 10, "Requires Python 3.10+")
265-
def test_patma_242(self):
266-
x = range(3)
267-
match x:
268-
case [y, *_, z]:
269-
w = 0
270-
self.assertEqual(w, 0)
271-
self.assertEqual(x, range(3))
272-
self.assertEqual(y, 0)
273-
self.assertEqual(z, 2)
274-
275-
@unittest.skipIf(sys.version_info.minor < 10, "Requires Python 3.10+")
276-
def test_patma_017(self):
277-
match (0, 1, 2):
278-
case [*x, 0, 1, 2,]:
279-
y = 0
280-
self.assertEqual(x, [])
281-
self.assertEqual(y, 0)
282-
283-
284236
class TestErrors(unittest.TestCase):
285237
def assert_syntax_error(self, code: str):
286238
with self.assertRaises(SyntaxError):

0 commit comments

Comments
 (0)