Skip to content

Commit

Permalink
add junit test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
李家奥 authored and 李家奥 committed Apr 20, 2022
1 parent 5958b92 commit 2667b42
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pmd-plsql/etc/grammar/PldocAST.jjt
Original file line number Diff line number Diff line change
Expand Up @@ -2126,9 +2126,9 @@ void QueryTableExpression() #void :
|
LOOKAHEAD(5) "(" [ LOOKAHEAD(2) SchemaName() "." ] TableName() [TableAlias()] ")"
|
LOOKAHEAD(3) [ <LATERAL> ] "(" Subquery() [ SubqueryRestrictionClause() ] ")"
LOOKAHEAD(5) [ <LATERAL> ] "(" Subquery() [ SubqueryRestrictionClause() ] ")"
|
LOOKAHEAD(3) "(" JoinClause() ")"
"(" JoinClause() ")"
)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/

package net.sourceforge.pmd.lang.plsql.ast;

import org.junit.Assert;
import org.junit.Test;

import net.sourceforge.pmd.lang.plsql.AbstractPLSQLParserTst;

public class ParenthesisGroupTest extends AbstractPLSQLParserTst {

@Test
public void parseParenthesisGroup0() {
ASTInput input = plsql.parseResource("ParenthesisGroup0.pls");
Assert.assertNotNull(input);
}

@Test
public void parseParenthesisGroup1() {
ASTInput input = plsql.parseResource("ParenthesisGroup1.pls");
Assert.assertNotNull(input);
}

@Test
public void parseParenthesisGroup2() {
ASTInput input = plsql.parseResource("ParenthesisGroup2.pls");
Assert.assertNotNull(input);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
CREATE OR REPLACE PROCEDURE EXAMPLE_PROCEDURE IS
--
CURSOR c_example IS
SELECT a.owner, u.object_name, p.aggregate
FROM (USER_OBJECTS u) INNER JOIN (ALL_OBJECTS a) ON
u.object_name = a.object_name AND u.object_type = a.object_type AND u.object_id = a.object_id)
INNER JOIN (ALL_PROCEDURES p) ON
p.owner = a.owner AND p.object_name = a.object_name AND p.object_type = a.object_type
WHERE a.owner = USER;
--
BEGIN
--
FOR l_object IN c_example LOOP
--
DBMS_OUTPUT.Put_Line(l_object.owner);
DBMS_OUTPUT.Put_Line(l_object.object_name);
DBMS_OUTPUT.Put_Line(l_object.aggregate);
--
END LOOP;
--
END EXAMPLE_PROCEDURE;
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
CREATE OR REPLACE PROCEDURE EXAMPLE_PROCEDURE IS
--
CURSOR c_example IS
SELECT a.owner, u.object_name, p.aggregate
FROM (((USER_OBJECTS u) INNER JOIN (ALL_OBJECTS a) ON
u.object_name = a.object_name AND u.object_type = a.object_type AND u.object_id = a.object_id)
INNER JOIN (ALL_PROCEDURES p) ON
p.owner = a.owner AND p.object_name = a.object_name AND p.object_type = a.object_type)
WHERE a.owner = USER;
--
BEGIN
--
FOR l_object IN c_example LOOP
--
DBMS_OUTPUT.Put_Line(l_object.owner);
DBMS_OUTPUT.Put_Line(l_object.object_name);
DBMS_OUTPUT.Put_Line(l_object.aggregate);
--
END LOOP;
--
END EXAMPLE_PROCEDURE;
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
CREATE OR REPLACE PROCEDURE TEST_PROCEDURE IS
--
CURSOR c_test IS
SELECT si.sid, sn.name, sa.age, ss.score, sp.parent
FROM ((((STUDENT_INFO si) INNER JOIN (STUDENT_AGE sa) on si.sid = sa.sid)
INNER JOIN
(STUDENT_SCORE ss) on si.sid = sp.sid)
INNER JOIN
(STUDENT_PARENT sp) on si.sid = sp.sid)
WHERE si.sid = '114514';
--
BEGIN
--
--
END EXAMPLE_PROCEDURE;

0 comments on commit 2667b42

Please sign in to comment.