<s> import re <EOL> from vispy . visuals . shaders . parsing import re_identifier , find_program_variables <EOL> from vispy . testing import run_tests_if_main <EOL> def test_identifier ( ) : <EOL> assert ( re . match ( '<STR_LIT:(>' + re_identifier + '<STR_LIT:)>' , '<STR_LIT>' ) . groups ( ) [ <NUM_LIT:0> ] == <EOL> '<STR_LIT>' ) <EOL> assert ( re . match ( '<STR_LIT:(>' + re_identifier + '<STR_LIT:)>' , '<STR_LIT>' ) . groups ( ) [ <NUM_LIT:0> ] == <EOL> '<STR_LIT>' ) <EOL> assert ( re . match ( re_identifier , '<STR_LIT>' ) is None ) <EOL> assert ( re . match ( '<STR_LIT:(>' + re_identifier + '<STR_LIT:)>' , '<STR_LIT>' ) . groups ( ) [ <NUM_LIT:0> ] == '<STR_LIT:x>' ) <EOL> assert ( re . match ( '<STR_LIT:(>' + re_identifier + '<STR_LIT:)>' , '<STR_LIT>' ) . groups ( ) [ <NUM_LIT:0> ] == '<STR_LIT:x>' ) <EOL> def test_find_variables ( ) : <EOL> code = """<STR_LIT>""" <EOL> expect = dict ( <EOL> x = ( None , '<STR_LIT:float>' ) , <EOL> y = ( None , '<STR_LIT:float>' ) , <EOL> z = ( None , '<STR_LIT:float>' ) , <EOL> w = ( None , '<STR_LIT:int>' ) , <EOL> v = ( None , '<STR_LIT:int>' ) , <EOL> u = ( None , '<STR_LIT:int>' ) , <EOL> t = ( None , '<STR_LIT>' ) , <EOL> s = ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> q = ( '<STR_LIT>' , '<STR_LIT:float>' ) , <EOL> r = ( '<STR_LIT>' , '<STR_LIT:float>' ) , <EOL> p = ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ) <EOL> vars = find_program_variables ( code ) <EOL> for k in expect : <EOL> assert expect [ k ] == vars . pop ( k ) <EOL> assert len ( vars ) == <NUM_LIT:0> <EOL> run_tests_if_main ( ) </s>
