}
@Test
public void testStatefullParsing4() throws NoTokensAvailableException, CommandSyntaxException {
IntegerArgument intArg = new IntegerArgument("intArg", Argument.MULTIPLE);
FileArgument fileArg = new FileArgument("fileArg", Argument.MULTIPLE);
ArgumentBundle bundle = new ArgumentBundle(intArg, fileArg);
// <root> ::= <<fileArg>> | ( <<intArg>> <root> )
MuSyntax syntax =
new MuAlternation("root", new MuArgument("fileArg"), new MuSequence(new MuArgument(
"intArg"), new MuBackReference("root")));
syntax.resolveBackReferences();
MuParser parser = new MuParser();
CommandLine cl;
cl = new CommandLine(new String[] {"x"});
parser.parse(syntax, null, cl.tokenIterator(), bundle);
Assert.assertEquals(1, fileArg.getValues().length);
Assert.assertEquals(0, intArg.getValues().length);
cl = new CommandLine(new String[] {"1", "x"});
parser.parse(syntax, null, cl.tokenIterator(), bundle);
Assert.assertEquals(1, fileArg.getValues().length);
Assert.assertEquals(1, intArg.getValues().length);
cl = new CommandLine(new String[] {"1", "2", "x"});
parser.parse(syntax, null, cl.tokenIterator(), bundle);
Assert.assertEquals(1, fileArg.getValues().length);
Assert.assertEquals(2, intArg.getValues().length);
try {
cl = new CommandLine(new String[] {"1", "2", ""});
parser.parse(syntax, null, cl.tokenIterator(), bundle);