def test_symbols(): p = Parser() x1 = p.add_symbol('sym') x2 = p.add_token('tok') x3 = p.add_anon_symbol(':sym') x4 = p.add_anon_symbol(':sym1') # test basic numbering assumption # symbols and tokens are attributed sequentially # using the same counter assert x2 == x1 + 1 # anon symbols have negative value assert x3 != x2 + 1 assert x4 == x3 - 1 assert x3 < 0 y1 = p.add_symbol('sym') assert y1 == x1 y2 = p.add_token('tok') assert y2 == x2 y3 = p.add_symbol(':sym') assert y3 == x3 y4 = p.add_symbol(':sym1') assert y4 == x4