Examples of Vm


Examples of net.sf.jabref.bst.VM

    assertEquals("c", v2.get(2).getBibtexEntry().getCiteKey());
    assertEquals("d", v2.get(3).getBibtexEntry().getCiteKey());
  }

  public void testBuildIn() throws RecognitionException, IOException {
    VM vm = new VM("EXECUTE {global.max$}");

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

    assertEquals(new Integer(Integer.MAX_VALUE), vm.getStack().pop());
    assertTrue(vm.getStack().empty());
  }
View Full Code Here

Examples of net.sf.jabref.bst.VM

    assertTrue(vm.getStack().empty());
  }

  public void testVariables() throws RecognitionException, IOException {

    VM vm = new VM(" STRINGS { t }                          "
      + " FUNCTION {not}  { { #0 } { #1 }  if$ } "
      + " FUNCTION {n.dashify} { \"HELLO-WORLD\" 't := t empty$ not } "
      + " EXECUTE {n.dashify}                    ");

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

    assertEquals(VM.TRUE, vm.getStack().pop());
  }
View Full Code Here

Examples of net.sf.jabref.bst.VM

    assertEquals(VM.TRUE, vm.getStack().pop());
  }

  public void testWhile() throws RecognitionException, IOException {

    VM vm = new VM(
      "STRINGS { t }            "
        + "FUNCTION {not}  {   "
        + " { #0 } { #1 }  if$ } "
        + "FUNCTION {n.dashify}              "
        + "{ \"HELLO-WORLD\"                 "
        + "  't :=                           "
        + " \"\"                                                 "
        + "     { t empty$ not }                 "
        + "     { t #1 #1 substring$ \"-\" =                      "
        + "       { t #1 #2 substring$ \"--\" = not "
        + "            { \"--\" *                                       "
        + "              t #2 global.max$ substring$ 't :=                 "
        + "            }                                                    "
        + "            {   { t #1 #1 substring$ \"-\" = }                "
        + "                { \"-\" *                                         "
        + "                  t #2 global.max$ substring$ 't :=               "
        + "                }                                                  "
        + "              while$                                                                  "
        + "            }                                                                  "
        + "          if$                                                                  "
        + "        }                                                                  "
        + "        { t #1 #1 substring$ *                                       "
        + "          t #2 global.max$ substring$ 't :=                          "
        + "        }                                                                  "
        + "        if$                                                                  "
        + "      }                                                                  "
        + "    while$                                                                  "
        + "  }                                                                  "
        + " EXECUTE {n.dashify} ");

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

    assertEquals(1, vm.getStack().size());
    assertEquals("HELLO--WORLD", vm.getStack().pop());
  }
View Full Code Here

Examples of net.sf.jabref.bst.VM

    assertEquals("HELLO--WORLD", vm.getStack().pop());
  }

  public void testType() throws RecognitionException, IOException {

    VM vm = new VM(
      ""
        + "ENTRY  { title }  { }  { label }"
        + "FUNCTION {presort} { cite$ 'sort.key$ := } ITERATE { presort } SORT FUNCTION {test} { type$ } ITERATE { test }");

    Vector<BibtexEntry> v = new Vector<BibtexEntry>();
    v.add(bibtexString2BibtexEntry("@article{a, author=\"AAA\"}"));
    v.add(bibtexString2BibtexEntry("@book{b, author=\"BBB\"}"));
    v.add(bibtexString2BibtexEntry("@misc{c, author=\"CCC\"}"));
    v.add(bibtexString2BibtexEntry("@inproceedings{d, author=\"DDD\"}"));
    vm.run(v);

    assertEquals(4, vm.getStack().size());
    assertEquals("Inproceedings", vm.getStack().pop());
    assertEquals("Misc", vm.getStack().pop());
    assertEquals("Book", vm.getStack().pop());
    assertEquals("Article", vm.getStack().pop());
  }
View Full Code Here

Examples of net.sf.jabref.bst.VM

    assertEquals("Article", vm.getStack().pop());
  }

  public void testMissing() throws RecognitionException, IOException {

    VM vm = new VM( //
      "ENTRY    { title }  { }  { label } " + //
        "FUNCTION {presort} { cite$ 'sort.key$ := } " + //
        "ITERATE  {presort} " + //
        "READ SORT " + //
        "FUNCTION {test}{ title missing$ cite$ } " + //
        "ITERATE  { test }");

    Vector<BibtexEntry> v = new Vector<BibtexEntry>();
    v.add(t1BibtexEntry());
    v.add(bibtexString2BibtexEntry("@article{test, author=\"No title\"}"));
    vm.run(v);

    assertEquals(4, vm.getStack().size());

    assertEquals("test", vm.getStack().pop());
    assertEquals(new Integer(1), vm.getStack().pop());
    assertEquals("canh05", vm.getStack().pop());
    assertEquals(new Integer(0), vm.getStack().pop());
  }
View Full Code Here

Examples of net.sf.jabref.bst.VM

    assertEquals(new Integer(0), vm.getStack().pop());
  }

  public void testFormatName() throws RecognitionException, IOException {
    {
      VM vm = new VM(
        "FUNCTION {format}{ \"Charles Louis Xavier Joseph de la Vall{\\'e}e Poussin\" #1 \"{vv~}{ll}{, jj}{, f}?\" format.name$ }"
          + "EXECUTE {format}");

      Vector<BibtexEntry> v = new Vector<BibtexEntry>();
      vm.run(v);
      assertEquals("de~la Vall{\\'e}e~Poussin, C.~L. X.~J?", (String) vm.getStack().pop());
      assertEquals(0, vm.getStack().size());
    }
    {
      VM vm = new VM("ENTRY  { author }  { }  { label } "
        + "FUNCTION {presort} { cite$ 'sort.key$ := } " + "ITERATE { presort } " + "READ "
        + "SORT " + "FUNCTION {format}{ author #2 \"{vv~}{ll}{, jj}{, f}?\" format.name$ }"
        + "ITERATE {format}");

      Vector<BibtexEntry> v = new Vector<BibtexEntry>();
      v.add(t1BibtexEntry());
      v
        .add(bibtexString2BibtexEntry("@book{test, author=\"Jonathan Meyer and Charles Louis Xavier Joseph de la Vall{\\'e}e Poussin\"}"));
      vm.run(v);
      assertEquals("de~la Vall{\\'e}e~Poussin, C.~L. X.~J?", vm.getStack().pop());
      assertEquals("Annabi, H?", vm.getStack().pop());
      assertEquals(0, vm.getStack().size());
    }
  }
View Full Code Here

Examples of net.sf.jabref.bst.VM

    }
  }

  public void testCallType() throws RecognitionException, IOException {

    VM vm = new VM(
      "ENTRY  { title }  { }  { label } FUNCTION {presort} { cite$ 'sort.key$ := } ITERATE { presort } READ SORT "
        + "FUNCTION {inproceedings}{ \"InProceedings called on \" title * } "
        + "FUNCTION {book}{ \"Book called on \" title * } " + " ITERATE { call.type$ }");

    Vector<BibtexEntry> v = new Vector<BibtexEntry>();
    v.add(t1BibtexEntry());
    v.add(bibtexString2BibtexEntry("@book{test, title=\"Test\"}"));
    vm.run(v);

    assertEquals(2, vm.getStack().size());

    assertEquals("Book called on Test", vm.getStack().pop());
    assertEquals(
      "InProceedings called on Effective work practices for floss development: A model and propositions",
      vm.getStack().pop());
    assertEquals(0, vm.getStack().size());
  }
View Full Code Here

Examples of net.sf.jabref.bst.VM

    assertEquals(0, vm.getStack().size());
  }

  public void testIterate() throws RecognitionException, IOException {

    VM vm = new VM("" + "ENTRY  { " + "  address " + "  author " + "  title " + "  type "
      + "}  {}  { label } " + "FUNCTION {test}{ cite$ } " + "READ " + "ITERATE { test }");

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

    v.add(bibtexString2BibtexEntry("@article{test, title=\"BLA\"}"));

    vm.run(v);

    assertEquals(2, vm.getStack().size());

    String s1 = (String) vm.getStack().pop();
    String s2 = (String) vm.getStack().pop();

    if (s1.equals("canh05")) {
      assertEquals("test", s2);
    } else {
      assertEquals("canh05", s2);
View Full Code Here

Examples of net.sf.jabref.bst.VM

    }
  }

  public void testWidth() throws RecognitionException, IOException {

    VM vm = new VM("ENTRY  { " + "  address " + "  author " + "  title " + "  type "
      + "}  {}  { label } " + //
      "STRINGS { longest.label } " + //
      "INTEGERS { number.label longest.label.width } " + //
      "FUNCTION {initialize.longest.label} " + //
      "{ \"\" 'longest.label := " + //
      "  #1 'number.label := " + //
      "  #0 'longest.label.width := " + //
      "} " + //
      " " + //
      "    FUNCTION {longest.label.pass} " + //
      "    { number.label int.to.str$ 'label := " + //
      "      number.label #1 + 'number.label := " + //
      "      label width$ longest.label.width > " + //
      "        { label 'longest.label := " + //
      "          label width$ 'longest.label.width := " + //
      "        } " + //
      "        'skip$ " + //
      "      if$ " + //
      "    } " + //
      " " + //
      "    EXECUTE {initialize.longest.label} " + //
      " " + //
      "    ITERATE {longest.label.pass} " + //
      "FUNCTION {begin.bib} " + //
      "{ preamble$ empty$" + //
      "    'skip$" + //
      "    { preamble$ write$ newline$ }" + //
      "  if$" + //
      "  \"\\begin{thebibliography}{\"  longest.label  * \"}\" *" + //
      "}" + //
      "EXECUTE {begin.bib}" + //
      "");//

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

    vm.run(v);

    assertTrue(vm.getIntegers().containsKey("longest.label.width"));
    assertEquals("\\begin{thebibliography}{1}", vm.getStack().pop());
  }
View Full Code Here

Examples of net.sf.jabref.bst.VM

    assertEquals("\\begin{thebibliography}{1}", vm.getStack().pop());
  }

  public void testVMSwap() throws RecognitionException, IOException {

    VM vm = new VM("FUNCTION {a}{ #3 \"Hallo\" swap$ } EXECUTE { a }");

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

    assertEquals(2, vm.getStack().size());
    assertEquals(new Integer(3), vm.getStack().pop());
    assertEquals("Hallo", vm.getStack().pop());
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.