Search in sources :

Example 1 with DslCommand

use of co.rsk.test.dsl.DslCommand in project rskj by rsksmart.

the class DslCommandTest method createCommandWithVerbAndNoArguments.

@Test
public void createCommandWithVerbAndNoArguments() {
    DslCommand cmd = new DslCommand("verb");
    Assert.assertTrue(cmd.isCommand("verb"));
    Assert.assertEquals(0, cmd.getArity());
    Assert.assertNull(cmd.getArgument(0));
}
Also used : DslCommand(co.rsk.test.dsl.DslCommand) Test(org.junit.Test)

Example 2 with DslCommand

use of co.rsk.test.dsl.DslCommand in project rskj by rsksmart.

the class DslParserTest method parseTwoSimpleCommands.

@Test
public void parseTwoSimpleCommands() {
    DslParser parser = new DslParser("do1 arg11 arg12\ndo2 arg21 arg22");
    DslCommand cmd = parser.nextCommand();
    Assert.assertNotNull(cmd);
    Assert.assertTrue(cmd.isCommand("do1"));
    Assert.assertEquals(2, cmd.getArity());
    Assert.assertEquals("arg11", cmd.getArgument(0));
    Assert.assertEquals("arg12", cmd.getArgument(1));
    cmd = parser.nextCommand();
    Assert.assertNotNull(cmd);
    Assert.assertTrue(cmd.isCommand("do2"));
    Assert.assertEquals(2, cmd.getArity());
    Assert.assertEquals("arg21", cmd.getArgument(0));
    Assert.assertEquals("arg22", cmd.getArgument(1));
    Assert.assertNull(parser.nextCommand());
}
Also used : DslCommand(co.rsk.test.dsl.DslCommand) DslParser(co.rsk.test.dsl.DslParser) Test(org.junit.Test)

Example 3 with DslCommand

use of co.rsk.test.dsl.DslCommand in project rskj by rsksmart.

the class DslParserTest method parseSimpleCommand.

@Test
public void parseSimpleCommand() {
    DslParser parser = new DslParser("do arg1 arg2");
    DslCommand cmd = parser.nextCommand();
    Assert.assertNotNull(cmd);
    Assert.assertTrue(cmd.isCommand("do"));
    Assert.assertEquals(2, cmd.getArity());
    Assert.assertEquals("arg1", cmd.getArgument(0));
    Assert.assertEquals("arg2", cmd.getArgument(1));
    Assert.assertNull(parser.nextCommand());
}
Also used : DslCommand(co.rsk.test.dsl.DslCommand) DslParser(co.rsk.test.dsl.DslParser) Test(org.junit.Test)

Example 4 with DslCommand

use of co.rsk.test.dsl.DslCommand in project rskj by rsksmart.

the class DslParserTest method parseSimpleCommandSkippingComment.

@Test
public void parseSimpleCommandSkippingComment() {
    DslParser parser = new DslParser("do arg1 arg2 # this is a comment");
    DslCommand cmd = parser.nextCommand();
    Assert.assertNotNull(cmd);
    Assert.assertTrue(cmd.isCommand("do"));
    Assert.assertEquals(2, cmd.getArity());
    Assert.assertEquals("arg1", cmd.getArgument(0));
    Assert.assertEquals("arg2", cmd.getArgument(1));
    Assert.assertNull(parser.nextCommand());
}
Also used : DslCommand(co.rsk.test.dsl.DslCommand) DslParser(co.rsk.test.dsl.DslParser) Test(org.junit.Test)

Example 5 with DslCommand

use of co.rsk.test.dsl.DslCommand in project rskj by rsksmart.

the class DslParserTest method parseSimpleCommandSkippingCommentLines.

@Test
public void parseSimpleCommandSkippingCommentLines() {
    DslParser parser = new DslParser("# first comment   \ndo arg1 arg2\n  # second comment   ");
    DslCommand cmd = parser.nextCommand();
    Assert.assertNotNull(cmd);
    Assert.assertTrue(cmd.isCommand("do"));
    Assert.assertEquals(2, cmd.getArity());
    Assert.assertEquals("arg1", cmd.getArgument(0));
    Assert.assertEquals("arg2", cmd.getArgument(1));
    Assert.assertNull(parser.nextCommand());
}
Also used : DslCommand(co.rsk.test.dsl.DslCommand) DslParser(co.rsk.test.dsl.DslParser) Test(org.junit.Test)

Aggregations

DslCommand (co.rsk.test.dsl.DslCommand)9 Test (org.junit.Test)9 DslParser (co.rsk.test.dsl.DslParser)7 ArrayList (java.util.ArrayList)1