Skip to content

Kotlin: Add a ministdlib test #10633

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions java/ql/test/kotlin/library-tests/ministdlib/MiniStdLib.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package kotlin

/*
This is a mini standard library replacement, to make it easy to write
very small tests that create very small databases.

If you define a class, then you will need to also define any members that
compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/descriptors/IrBuiltInsOverDescriptors.kt
expects (e.g. with findFunctions(...).first) to exist.
*/

public open class Any {
fun toString(): String { return this.toString() }
open operator fun equals(other: Any?): Boolean { return this.equals(other) }
}

public class String {
operator fun plus(other: Any?): String { return this.plus(other) }
}

public class Boolean {
operator fun not(): Boolean { return this.not() }
}

public class Int {
operator fun plus(other: Int): Int { return this.plus(other) }
operator fun times(other: Int): Int { return this.times(other) }
infix fun xor(other: Int): Int { return this.xor(other) }
}

public object Unit {
}

1 change: 1 addition & 0 deletions java/ql/test/kotlin/library-tests/ministdlib/MyClass.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
class MyClass {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
| MiniStdLib.kt:12:1:15:1 | Any |
| MiniStdLib.kt:17:1:19:1 | String |
| MiniStdLib.kt:21:1:23:1 | Boolean |
| MiniStdLib.kt:25:1:29:1 | Int |
| MiniStdLib.kt:31:1:32:1 | Unit |
| MyClass.kt:1:1:1:16 | MyClass |
| file://:0:0:0:0 | FakeKotlinClass |
4 changes: 4 additions & 0 deletions java/ql/test/kotlin/library-tests/ministdlib/classes.ql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import java

from Class c
select c
1 change: 1 addition & 0 deletions java/ql/test/kotlin/library-tests/ministdlib/options
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
codeql-extractor-kotlin-options: -no-jdk -no-reflect -no-stdlib -Xallow-kotlin-package