@@ -86,14 +86,14 @@ class UtplsqlParserTest extends AbstractJdbcTest {
8686 Assert . assertEquals(' ' ' "P"' ' ' . toString, units. get(1 ). name)
8787 Assert . assertTrue(units. get(0 ). position < units. get(1 ). position)
8888 Assert . assertEquals(" " , parser. getPathAt(0 ))
89- Assert . assertEquals(" " , parser. getPathAt(3 ,6 ))
90- Assert . assertEquals(" pkg" , parser. getPathAt(4 ,1 ))
91- Assert . assertEquals(" pkg.p" , parser. getPathAt(10 ,33 ))
92- Assert . assertEquals(" pkg.p" , parser. getPathAt(13 ,1 ))
93- Assert . assertEquals(" SCOTT.PKG.P" , parser. getPathAt(19 ,1 ))
94- Assert . assertEquals(" SCOTT.PKG.P" , parser. getPathAt(22 ,9 ))
95- Assert . assertEquals(" SCOTT.PKG.P" , parser. getPathAt(22 ,10 ))
96- Assert . assertEquals(" SCOTT.PKG.P" , parser. getPathAt(29 ,1 ))
89+ Assert . assertEquals(" " , parser. getPathAt(parser . toPosition( 3 ,6 ) ))
90+ Assert . assertEquals(" pkg" , parser. getPathAt(parser . toPosition( 4 ,1 ) ))
91+ Assert . assertEquals(" pkg.p" , parser. getPathAt(parser . toPosition( 10 ,33 ) ))
92+ Assert . assertEquals(" pkg.p" , parser. getPathAt(parser . toPosition( 13 ,1 ) ))
93+ Assert . assertEquals(" SCOTT.PKG.P" , parser. getPathAt(parser . toPosition( 19 ,1 ) ))
94+ Assert . assertEquals(" SCOTT.PKG.P" , parser. getPathAt(parser . toPosition( 22 ,9 ) ))
95+ Assert . assertEquals(" SCOTT.PKG.P" , parser. getPathAt(parser . toPosition( 22 ,10 ) ))
96+ Assert . assertEquals(" SCOTT.PKG.P" , parser. getPathAt(parser . toPosition( 29 ,1 ) ))
9797 }
9898
9999 @Test
@@ -124,8 +124,8 @@ class UtplsqlParserTest extends AbstractJdbcTest {
124124 parser = new UtplsqlParser (sqlScript, dataSource. connection, null )
125125 Assert . assertEquals(2 , parser. getObjects. size)
126126 Assert . assertEquals(2 , parser. getUnits. size)
127- Assert . assertEquals(" pkg.p" , parser. getPathAt(13 ,1 ))
128- Assert . assertEquals(" SCOTT.PKG.P" , parser. getPathAt(19 ,1 ))
127+ Assert . assertEquals(" pkg.p" , parser. getPathAt(parser . toPosition( 13 ,1 ) ))
128+ Assert . assertEquals(" SCOTT.PKG.P" , parser. getPathAt(parser . toPosition( 19 ,1 ) ))
129129 setupAndTeardown
130130 }
131131
@@ -178,12 +178,12 @@ class UtplsqlParserTest extends AbstractJdbcTest {
178178 end;
179179 ' ' '
180180 val parser = new UtplsqlParser (plsql)
181- Assert . assertEquals(" test_expect_not_to_be_null.cleanup_expectations" , parser. getPathAt(7 ,1 ))
182- Assert . assertEquals(" test_expect_not_to_be_null.create_types" , parser. getPathAt(13 ,1 ))
181+ Assert . assertEquals(" test_expect_not_to_be_null.cleanup_expectations" , parser. getPathAt(parser . toPosition( 7 ,1 ) ))
182+ Assert . assertEquals(" test_expect_not_to_be_null.create_types" , parser. getPathAt(parser . toPosition( 13 ,1 ) ))
183183 // was: '||gc_varray_name||'.drop_types
184- Assert . assertEquals(" test_expect_not_to_be_null.drop_types" , parser. getPathAt(23 ,1 ))
184+ Assert . assertEquals(" test_expect_not_to_be_null.drop_types" , parser. getPathAt(parser . toPosition( 23 ,1 ) ))
185185 // was: '||gc_varray_name||'.blob_not_null
186- Assert . assertEquals(" test_expect_not_to_be_null.blob_not_null" , parser. getPathAt(33 ,1 ))
186+ Assert . assertEquals(" test_expect_not_to_be_null.blob_not_null" , parser. getPathAt(parser . toPosition( 33 ,1 ) ))
187187 }
188188
189189 @Test
@@ -215,7 +215,89 @@ class UtplsqlParserTest extends AbstractJdbcTest {
215215 ' ' '
216216 val parser = new UtplsqlParser (plsql)
217217 // was: test_expect_not_to_be_null.create_types
218- Assert . assertEquals(" test_expect_not_to_be_null.blob_not_null" , parser. getPathAt(13 ,26 ))
218+ Assert . assertEquals(" test_expect_not_to_be_null.blob_not_null" , parser. getPathAt(parser . toPosition( 13 ,26 ) ))
219219 }
220220
221+ @Test
222+ def testProcedure () {
223+ val plsql = ' ' '
224+ create or replace procedure z
225+ is
226+ null;
227+ end;
228+ /
229+ ' ' '
230+ val parser = new UtplsqlParser (plsql)
231+ Assert . assertEquals(" z" , parser. getObjectAt(0 ). name)
232+ Assert . assertEquals(" PROCEDURE" , parser. getObjectAt(0 ). type)
233+ }
234+
235+ @Test
236+ def testFunction () {
237+ val plsql = ' ' '
238+ create or replace procedure z
239+ is
240+ null;
241+ end;
242+ /
243+
244+ create or replace function f return number is
245+ begin
246+ null;
247+ end;
248+ /
249+ ' ' '
250+ val parser = new UtplsqlParser (plsql)
251+ Assert . assertEquals(" f" , parser. getObjectAt(parser. toPosition(8 ,1 )). name)
252+ Assert . assertEquals(" FUNCTION" , parser. getObjectAt(parser. toPosition(8 ,1 )). type)
253+ }
254+
255+ @Test
256+ def testType () {
257+ val plsql = ' ' '
258+ create or replace type t force is
259+ object (
260+ a number,
261+ b number,
262+ c varchar2(10),
263+ member procedure p(self in t)
264+ )
265+ end;
266+ /
267+ ' ' '
268+ val parser = new UtplsqlParser (plsql)
269+ Assert . assertEquals(" t" , parser. getObjectAt(0 ). name)
270+ Assert . assertEquals(" TYPE" , parser. getObjectAt(0 ). type)
271+ }
272+
273+ @Test
274+ def testTypeBody () {
275+ val plsql = ' ' '
276+ create or replace type body t force is
277+ member procedure p(self in t) is
278+ begin
279+ null;
280+ end;
281+ end;
282+ /
283+ ' ' '
284+ val parser = new UtplsqlParser (plsql)
285+ Assert . assertEquals(" t" , parser. getObjectAt(0 ). name)
286+ Assert . assertEquals(" TYPE" , parser. getObjectAt(0 ). type)
287+ }
288+
289+ @Test
290+ def testUnknown () {
291+ val plsql = ' ' '
292+ create or replace unknown u is
293+ begin
294+ null;
295+ end;
296+ /
297+ ' ' '
298+ val parser = new UtplsqlParser (plsql)
299+ Assert . assertEquals(null , parser. getObjectAt(0 ))
300+ }
301+
302+
221303}
0 commit comments