o
    ¦ÜÓhY	  ã                   @   s>   d dl mZ d dlmZmZ eedk dƒG dd„ deƒƒZdS )é    )Úversion_info)ÚTestCaseÚskipIf)é   é
   zPython >= 3.10 onlyc                   @   sL   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dd„ Z
dS )Ú	TestMatchc                 C   s"   |   d¡ |   d¡ |   d¡ d S )NzŸ
            def f():
                x = 1
                match x:
                    case 1 as y:
                        print(f'matched as {y}')
        z§
            def f():
                x = [1, 2, 3]
                match x:
                    case [1, y, 3]:
                        print(f'matched {y}')
        z©
            def f():
                x = {'foo': 1}
                match x:
                    case {'foo': y}:
                        print(f'matched {y}')
        ©Úflakes©Úself© r   úN/var/www/html/ai/venv/lib/python3.10/site-packages/pyflakes/test/test_match.pyÚtest_match_bindings   s   

zTestMatch.test_match_bindingsc                 C   s   |   d¡ |   d¡ d S )Nz‡
            from a import B

            match 1:
                case B(x=1) as y:
                    print(f'matched {y}')
        z’
            from a import B

            match 1:
                case B(a, x=z) as y:
                    print(f'matched {y} {a} {z}')
        r   r
   r   r   r   Ú test_match_pattern_matched_class   s   
z*TestMatch.test_match_pattern_matched_classc                 C   ó   |   d¡ d S )Nz~
            def f():
                match 1:
                    case _:
                        print('catchall!')
        r   r
   r   r   r   Útest_match_placeholder/   ó   z TestMatch.test_match_placeholderc                 C   r   )Nz[
            match 1:
                case True:
                    print('true')
        r   r
   r   r   r   Útest_match_singleton7   r   zTestMatch.test_match_singletonc                 C   r   )Nzb
            match 1:
                case 1 | 2:
                    print('one or two')
        r   r
   r   r   r   Útest_match_or_pattern>   r   zTestMatch.test_match_or_patternc                 C   r   )Nz‚
            x = [1, 2, 3]
            match x:
                case [1, *y]:
                    print(f'captured: {y}')
        r   r
   r   r   r   Útest_match_starE   r   zTestMatch.test_match_starc                 C   r   )Nz¢
            x = {'foo': 'bar', 'baz': 'womp'}
            match x:
                case {'foo': k1, **rest}:
                    print(f'{k1=} {rest=}')
        r   r
   r   r   r   Útest_match_double_starM   r   z TestMatch.test_match_double_starc                 C   r   )NzÙ
            def f(x):
                match x:
                    case 1:
                        def y(): pass
                    case _:
                        def y(): print(1)
                return y
        r   r
   r   r   r   Ú"test_defined_in_different_branchesU   r   z,TestMatch.test_defined_in_different_branchesN)Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r   r   r   r   r   r   r   r   r      s    r   N)Úsysr   Úpyflakes.test.harnessr   r   r   r   r   r   r   Ú<module>   s    