Search in sources :

Example 6 with DslCommand

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

the class DslCommandTest method createCommandWithVerbAndTwoArguments.

@Test
public void createCommandWithVerbAndTwoArguments() {
    List<String> args = new ArrayList<>();
    args.add("arg1");
    args.add("arg2");
    DslCommand cmd = new DslCommand("verb", args);
    Assert.assertTrue(cmd.isCommand("verb"));
    Assert.assertEquals(2, cmd.getArity());
    Assert.assertEquals("arg1", cmd.getArgument(0));
    Assert.assertEquals("arg2", cmd.getArgument(1));
    Assert.assertNull(cmd.getArgument(2));
}
Also used : DslCommand(co.rsk.test.dsl.DslCommand) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 7 with DslCommand

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

the class DslParserTest method parseSimpleCommandWithAdditionalSpacesAndTabs.

@Test
public void parseSimpleCommandWithAdditionalSpacesAndTabs() {
    DslParser parser = new DslParser("        do\t\t    arg1  \t    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 8 with DslCommand

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

the class DslParserTest method parseSimpleCommandSkippingEmptyLines.

@Test
public void parseSimpleCommandSkippingEmptyLines() {
    DslParser parser = new DslParser("   \ndo arg1 arg2\n   ");
    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 9 with DslCommand

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

the class DslParserTest method parseSimpleCommandWithNoArguments.

@Test
public void parseSimpleCommandWithNoArguments() {
    DslParser parser = new DslParser("do");
    DslCommand cmd = parser.nextCommand();
    Assert.assertNotNull(cmd);
    Assert.assertTrue(cmd.isCommand("do"));
    Assert.assertEquals(0, cmd.getArity());
    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