// 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); }
// Tests that local variables are correctly recognized and that // cast expressions are skipped appropriately public void testLocalTimeVar() throws SVParseException { String content = "function void foobar();\n" + " time t = 10ns;\n" + " t = 20ns;\n" + "endfunction\n"; SVCorePlugin.getDefault().enableDebug(false); SVDBTask func = parse_tf(content, "testLocalTimeVar"); assertEquals(2, SVDBUtil.getChildrenSize(func)); assertTrue(SVDBUtil.getFirstChildItem(func).getType() == SVDBItemType.VarDeclStmt); SVDBVarDeclStmt stmt = (SVDBVarDeclStmt) SVDBUtil.getFirstChildItem(func); SVDBVarDeclItem vi = (SVDBVarDeclItem) stmt.getChildren().iterator().next(); assertEquals("t", vi.getName()); }