Skip to content

Commit b30bc97

Browse files
committed
gh-145239: Add tests for unary plus in match literal patterns
Mirror the existing negative-number tests (095-110) for positive numbers: integers, floats, imaginary, and complex patterns.
1 parent 004646e commit b30bc97

File tree

1 file changed

+80
-0
lines changed

1 file changed

+80
-0
lines changed

Lib/test/test_patma.py

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2762,6 +2762,86 @@ def test_patma_255(self):
27622762
self.assertEqual(y, 1)
27632763
self.assertIs(z, x)
27642764

2765+
def test_patma_256(self):
2766+
x = 0
2767+
match x:
2768+
case +0:
2769+
y = 0
2770+
self.assertEqual(x, 0)
2771+
self.assertEqual(y, 0)
2772+
2773+
def test_patma_257(self):
2774+
x = 0
2775+
match x:
2776+
case +0.0:
2777+
y = 0
2778+
self.assertEqual(x, 0)
2779+
self.assertEqual(y, 0)
2780+
2781+
def test_patma_258(self):
2782+
x = 0
2783+
match x:
2784+
case +0j:
2785+
y = 0
2786+
self.assertEqual(x, 0)
2787+
self.assertEqual(y, 0)
2788+
2789+
def test_patma_259(self):
2790+
x = 0
2791+
match x:
2792+
case +0.0j:
2793+
y = 0
2794+
self.assertEqual(x, 0)
2795+
self.assertEqual(y, 0)
2796+
2797+
def test_patma_260(self):
2798+
x = 1
2799+
match x:
2800+
case +1:
2801+
y = 0
2802+
self.assertEqual(x, 1)
2803+
self.assertEqual(y, 0)
2804+
2805+
def test_patma_261(self):
2806+
x = 1.5
2807+
match x:
2808+
case +1.5:
2809+
y = 0
2810+
self.assertEqual(x, 1.5)
2811+
self.assertEqual(y, 0)
2812+
2813+
def test_patma_262(self):
2814+
x = 1j
2815+
match x:
2816+
case +1j:
2817+
y = 0
2818+
self.assertEqual(x, 1j)
2819+
self.assertEqual(y, 0)
2820+
2821+
def test_patma_263(self):
2822+
x = 1.5j
2823+
match x:
2824+
case +1.5j:
2825+
y = 0
2826+
self.assertEqual(x, 1.5j)
2827+
self.assertEqual(y, 0)
2828+
2829+
def test_patma_264(self):
2830+
x = 0.25 + 1.75j
2831+
match x:
2832+
case +0.25 + 1.75j:
2833+
y = 0
2834+
self.assertEqual(x, 0.25 + 1.75j)
2835+
self.assertEqual(y, 0)
2836+
2837+
def test_patma_265(self):
2838+
x = 0.25 - 1.75j
2839+
match x:
2840+
case +0.25 - 1.75j:
2841+
y = 0
2842+
self.assertEqual(x, 0.25 - 1.75j)
2843+
self.assertEqual(y, 0)
2844+
27652845
def test_patma_runtime_checkable_protocol(self):
27662846
# Runtime-checkable protocol
27672847
from typing import Protocol, runtime_checkable

0 commit comments

Comments
 (0)