Exemple #1
0
  @Test
  public void testVMFunction1() throws RecognitionException, IOException {

    VM vm = new VM("FUNCTION {init.state.consts}{ #0 'before.all := } ");

    Vector<BibtexEntry> v = new Vector<>();
    vm.run(v);

    Assert.assertEquals(38, vm.getFunctions().size());

    Assert.assertTrue(vm.getFunctions().get("init.state.consts") instanceof StackFunction);

    StackFunction fun = (StackFunction) vm.getFunctions().get("init.state.consts");
    Assert.assertEquals(3, fun.getTree().getChildCount());
  }
Exemple #2
0
  @Test
  public void testVMSimple() throws RecognitionException, IOException {

    VM vm =
        new VM(
            ""
                + "ENTRY  { "
                + "  address "
                + "  author "
                + "  title "
                + "  type "
                + "}  {}  { label }"
                + "INTEGERS { output.state before.all"
                + " mid.sentence after.sentence after.block }"
                + "FUNCTION {init.state.consts}{ #0 'before.all := "
                + " #1 'mid.sentence :=  #2 'after.sentence :=  #3 'after.block := } "
                + "STRINGS { s t } "
                + "READ");

    Vector<BibtexEntry> v = new Vector<>();
    v.add(t1BibtexEntry());

    vm.run(v);

    Assert.assertEquals(2, vm.getStrings().size());
    Assert.assertEquals(7, vm.getIntegers().size());
    Assert.assertEquals(1, vm.getEntries().size());
    Assert.assertEquals(5, vm.getEntries().get(0).getFields().size());
    Assert.assertEquals(38, vm.getFunctions().size());
  }