@Test
	public void testBufferedTokenStreamReuseAfterFill() {
		CharStream firstInput = new ANTLRInputStream("A");
		BufferedTokenStream tokenStream = new BufferedTokenStream(new VisitorBasicLexer(firstInput));
		tokenStream.fill();
		assertEquals(2, tokenStream.size());
		assertEquals(VisitorBasicLexer.A, tokenStream.get(0).getType());
		assertEquals(Token.EOF, tokenStream.get(1).getType());

		CharStream secondInput = new ANTLRInputStream("AA");
		tokenStream.setTokenSource(new VisitorBasicLexer(secondInput));
		tokenStream.fill();
		assertEquals(3, tokenStream.size());
		assertEquals(VisitorBasicLexer.A, tokenStream.get(0).getType());
		assertEquals(VisitorBasicLexer.A, tokenStream.get(1).getType());
		assertEquals(Token.EOF, tokenStream.get(2).getType());
	}
This is a targeted regression test for antlr/antlr4#1584 ({@link BufferedTokenStream} cannot be reused after EOF).
runtime-testsuite/test/org/antlr/v4/test/runtime/java/api/TestTokenStream.java