| 13 | |
| 14 | |
| 15 | class TestTokenStream: |
| 16 | test_tokens = [ |
| 17 | Token(1, TOKEN_BLOCK_BEGIN, ""), |
| 18 | Token(2, TOKEN_BLOCK_END, ""), |
| 19 | ] |
| 20 | |
| 21 | def test_simple(self, env): |
| 22 | ts = TokenStream(self.test_tokens, "foo", "bar") |
| 23 | assert ts.current.type is TOKEN_BLOCK_BEGIN |
| 24 | assert bool(ts) |
| 25 | assert not bool(ts.eos) |
| 26 | next(ts) |
| 27 | assert ts.current.type is TOKEN_BLOCK_END |
| 28 | assert bool(ts) |
| 29 | assert not bool(ts.eos) |
| 30 | next(ts) |
| 31 | assert ts.current.type is TOKEN_EOF |
| 32 | assert not bool(ts) |
| 33 | assert bool(ts.eos) |
| 34 | |
| 35 | def test_iter(self, env): |
| 36 | token_types = [t.type for t in TokenStream(self.test_tokens, "foo", "bar")] |
| 37 | assert token_types == [ |
| 38 | "block_begin", |
| 39 | "block_end", |
| 40 | ] |
| 41 | |
| 42 | |
| 43 | class TestLexer: |