use of co.rsk.test.dsl.DslParser in project rskj by rsksmart.
the class DslFilesTest method runUncles04Resource.
@Test
public void runUncles04Resource() throws FileNotFoundException, DslProcessorException {
DslParser parser = DslParser.fromResource("dsl/uncles04.txt");
World world = new World();
WorldDslProcessor processor = new WorldDslProcessor(world);
processor.processCommands(parser);
Assert.assertNotNull(world.getBlockByName("b01"));
Assert.assertNotNull(world.getBlockByName("u01"));
Assert.assertNotNull(world.getBlockByName("u02"));
Assert.assertNotNull(world.getBlockByName("b02"));
Assert.assertNotNull(world.getBlockByName("c02"));
Assert.assertEquals(2, world.getBlockChain().getStatus().getBestBlock().getNumber());
}
use of co.rsk.test.dsl.DslParser 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());
}
use of co.rsk.test.dsl.DslParser 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());
}
use of co.rsk.test.dsl.DslParser 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());
}
use of co.rsk.test.dsl.DslParser in project rskj by rsksmart.
the class DslParserTest method getNoCommandFromEmptyString.
@Test
public void getNoCommandFromEmptyString() {
DslParser parser = new DslParser("");
Assert.assertNull(parser.nextCommand());
}
Aggregations