From 591844f68033e9463944b6da96159e2361b10aca Mon Sep 17 00:00:00 2001 From: Ian Lynagh Date: Mon, 10 Oct 2022 19:04:11 +0100 Subject: [PATCH] Kotlin: Add a numlines test --- .../library-tests/numlines/callable.expected | 6 +++++ .../kotlin/library-tests/numlines/callable.ql | 4 +++ .../library-tests/numlines/classes.expected | 1 + .../kotlin/library-tests/numlines/classes.ql | 4 +++ .../library-tests/numlines/files.expected | 1 + .../kotlin/library-tests/numlines/files.ql | 4 +++ .../kotlin/library-tests/numlines/test.kt | 27 +++++++++++++++++++ 7 files changed, 47 insertions(+) create mode 100644 java/ql/test/kotlin/library-tests/numlines/callable.expected create mode 100644 java/ql/test/kotlin/library-tests/numlines/callable.ql create mode 100644 java/ql/test/kotlin/library-tests/numlines/classes.expected create mode 100644 java/ql/test/kotlin/library-tests/numlines/classes.ql create mode 100644 java/ql/test/kotlin/library-tests/numlines/files.expected create mode 100644 java/ql/test/kotlin/library-tests/numlines/files.ql create mode 100644 java/ql/test/kotlin/library-tests/numlines/test.kt diff --git a/java/ql/test/kotlin/library-tests/numlines/callable.expected b/java/ql/test/kotlin/library-tests/numlines/callable.expected new file mode 100644 index 00000000000..52f3a4f2cbe --- /dev/null +++ b/java/ql/test/kotlin/library-tests/numlines/callable.expected @@ -0,0 +1,6 @@ +| test.kt:2:1:4:1 | foo | 3 | 3 | 0 | +| test.kt:8:1:8:9 | getX | 1 | 1 | 0 | +| test.kt:18:1:18:17 | getY | 5 | 1 | 4 | +| test.kt:20:1:26:1 | Foo | 7 | 6 | 1 | +| test.kt:21:5:24:5 | bar | 4 | 3 | 1 | +| test.kt:25:5:25:21 | getSomeField | 1 | 1 | 0 | diff --git a/java/ql/test/kotlin/library-tests/numlines/callable.ql b/java/ql/test/kotlin/library-tests/numlines/callable.ql new file mode 100644 index 00000000000..c9775a24c5d --- /dev/null +++ b/java/ql/test/kotlin/library-tests/numlines/callable.ql @@ -0,0 +1,4 @@ +import java + +from Callable c +select c, c.getTotalNumberOfLines(), c.getNumberOfLinesOfCode(), c.getNumberOfCommentLines() diff --git a/java/ql/test/kotlin/library-tests/numlines/classes.expected b/java/ql/test/kotlin/library-tests/numlines/classes.expected new file mode 100644 index 00000000000..35000a02464 --- /dev/null +++ b/java/ql/test/kotlin/library-tests/numlines/classes.expected @@ -0,0 +1 @@ +| test.kt:20:1:26:1 | Foo | 7 | 6 | 1 | diff --git a/java/ql/test/kotlin/library-tests/numlines/classes.ql b/java/ql/test/kotlin/library-tests/numlines/classes.ql new file mode 100644 index 00000000000..4c987784146 --- /dev/null +++ b/java/ql/test/kotlin/library-tests/numlines/classes.ql @@ -0,0 +1,4 @@ +import java + +from Class c +select c, c.getTotalNumberOfLines(), c.getNumberOfLinesOfCode(), c.getNumberOfCommentLines() diff --git a/java/ql/test/kotlin/library-tests/numlines/files.expected b/java/ql/test/kotlin/library-tests/numlines/files.expected new file mode 100644 index 00000000000..1cc9c337bac --- /dev/null +++ b/java/ql/test/kotlin/library-tests/numlines/files.expected @@ -0,0 +1 @@ +| test.kt:0:0:0:0 | test | 28 | 11 | 9 | diff --git a/java/ql/test/kotlin/library-tests/numlines/files.ql b/java/ql/test/kotlin/library-tests/numlines/files.ql new file mode 100644 index 00000000000..ca56da73369 --- /dev/null +++ b/java/ql/test/kotlin/library-tests/numlines/files.ql @@ -0,0 +1,4 @@ +import java + +from File f +select f, f.getTotalNumberOfLines(), f.getNumberOfLinesOfCode(), f.getNumberOfCommentLines() diff --git a/java/ql/test/kotlin/library-tests/numlines/test.kt b/java/ql/test/kotlin/library-tests/numlines/test.kt new file mode 100644 index 00000000000..1ede04c7952 --- /dev/null +++ b/java/ql/test/kotlin/library-tests/numlines/test.kt @@ -0,0 +1,27 @@ + +fun foo ( x : Int ) { + val y = ( x + 1 ) +} + +// test + +val x = 4 + +/* +test +*/ + +/** +test +*/ + +val y = 5 // test + +class Foo { + fun bar() { + // comment + return + } + val someField = 3 +} +