Exemplo n.º 1
0
  // Tests that local variables are correctly recognized and that
  // cast expressions are skipped appropriately
  public void testLocalTypedef() throws SVParseException {
    String content =
        "function void foobar();\n"
            + "    typedef foo #(BAR) foo_t;\n"
            + "    foo_t              a;\n"
            + "    a = 5;\n"
            + "endfunction\n";

    //		ParserSVDBFileFactory parser = new ParserSVDBFileFactory(null);

    SVDBTask func = parse_tf(content, "testLocalTypedef");

    SVDBVarDeclItem a = null;
    for (ISVDBItemBase it : func.getChildren()) {
      if (it.getType() == SVDBItemType.VarDeclStmt) {
        for (ISVDBChildItem vi : ((SVDBVarDeclStmt) it).getChildren()) {
          if (SVDBItem.getName(vi).equals("a")) {
            a = (SVDBVarDeclItem) vi;
          }
        }
      }
    }

    assertEquals(3, SVDBUtil.getChildrenSize(func));
    assertEquals("foo_t", SVDBItem.getName(SVDBUtil.getFirstChildItem(func)));
    assertNotNull(a);
  }
Exemplo n.º 2
0
  // Tests that local variables are correctly recognized and that
  // cast expressions are skipped appropriately
  public void testLocalVarsWithCast() throws SVParseException {
    String content =
        "function void foobar();\n"
            + "    int a = integer'(5);\n"
            + "    int b = longint'(6);\n"
            + "    a = 5;\n"
            + "endfunction\n";

    SVCorePlugin.getDefault().enableDebug(false);

    SVDBTask func = parse_tf(content, "testLocalVarsWithCast");

    assertEquals(3, SVDBUtil.getChildrenSize(func));
    SVDBVarDeclItem a = null, b = null;
    for (ISVDBItemBase it_t : func.getChildren()) {
      if (it_t.getType() == SVDBItemType.VarDeclStmt) {
        SVDBVarDeclStmt v = (SVDBVarDeclStmt) it_t;
        for (ISVDBChildItem vi : v.getChildren()) {
          if (SVDBItem.getName(vi).equals("a")) {
            a = (SVDBVarDeclItem) vi;
          } else if (SVDBItem.getName(vi).equals("b")) {
            b = (SVDBVarDeclItem) vi;
          }
        }
      }
    }
    assertNotNull(a);
    assertNotNull(b);
  }