Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The parseFile method of the InterpreterDataReader class is missing code: "line = br.readLine();" #3375

Closed
Tinker1024 opened this issue Nov 30, 2021 · 2 comments · Fixed by #3419

Comments

@Tinker1024
Copy link
Contributor

target information : Java
The parseFile method of the InterpreterDataReader class before check the code "if (line.equals("channel names:"))", missing code "line = br.readLine();"
The source code like this:
image
The code we're expecting like this:
image

@ericvergnaud
Copy link
Contributor

ericvergnaud commented Nov 30, 2021 via email

@Tinker1024
Copy link
Contributor Author

Tinker1024 commented Nov 30, 2021

InterpTestFile.txt
Use the InterpTestFile.txt file above,My test method is as follows:

public class TestInterpreterDataReader {
	@Test
	public void test() throws NoSuchFieldException, IllegalAccessException {
		final ClassLoader loader = Thread.currentThread().getContextClassLoader();
               // pay attention to the path where the InterpTestFile.txt is stored.
		final URL stuff = loader.getResource("org/antlr/v4/test/runtime/InterpTestFile.txt");
		InterpreterDataReader.InterpreterData interpreterData = InterpreterDataReader.parseFile(stuff.getPath());
		Field ruleNames = interpreterData.getClass().getDeclaredField("ruleNames");
		Field channels = interpreterData.getClass().getDeclaredField("channels");
		Field modes = interpreterData.getClass().getDeclaredField("modes");
		ruleNames.setAccessible(true);
		channels.setAccessible(true);
		modes.setAccessible(true);
		List<String> ruleNamesList = (List<String>) ruleNames.get(interpreterData);
		List<String> channelsList = (List<String>) channels.get(interpreterData);
		List<String> modesList = (List<String>) modes.get(interpreterData);
		Assert.assertEquals(5,ruleNamesList.size());
		Assert.assertEquals(5,channelsList.size());
		Assert.assertEquals(1,modesList.size());
	}
}

Before the code “line = br.readLine(); ” was added
image

After the code “line = br.readLine(); ” was added,The test case is passed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants