-
Notifications
You must be signed in to change notification settings - Fork 24
Objects support #259
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
Objects support #259
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package org.usvm.machine.types | ||
Check warningCode scanning / detekt Detects missing final newlines Warning
File must end with a newline (\n)
|
||
|
||
import com.jetbrains.rd.framework.util.RdCoroutineScope.Companion.override | ||
Check warningCode scanning / detekt Detects unused imports Warning
Unused import
|
||
import org.jacodb.ets.base.EtsRefType | ||
import org.jacodb.ets.base.EtsType | ||
import org.jacodb.ets.model.EtsFieldSignature | ||
|
||
/** | ||
* An artificial type that represents a set of properties. | ||
*/ | ||
class AuxiliaryType(val properties: Set<EtsFieldSignature>) : EtsRefType { | ||
override val typeName: String = "AuxiliaryType" | ||
|
||
override fun <R> accept(visitor: EtsType.Visitor<R>): R { | ||
error("Should not be called") | ||
} | ||
} | ||
Check warningCode scanning / detekt Checks whether files end with a line separator. Warning
The file /home/runner/work/usvm/usvm/usvm-ts/src/main/kotlin/org/usvm/machine/types/AuxiliaryType.kt is not ending with a new line.
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package org.usvm.samples | ||
|
||
import org.jacodb.ets.model.EtsScene | ||
import org.jacodb.ets.utils.loadEtsFileAutoConvert | ||
import org.usvm.api.TsValue | ||
import org.usvm.util.TsMethodTestRunner | ||
import org.usvm.util.getResourcePath | ||
import kotlin.test.Test | ||
|
||
class Objects : TsMethodTestRunner() { | ||
override val scene: EtsScene = run { | ||
val name = "Objects.ts" | ||
val path = getResourcePath("/samples/$name") | ||
val file = loadEtsFileAutoConvert(path) | ||
EtsScene(listOf(file)) | ||
} | ||
|
||
@Test | ||
fun testCreateClassInstance() { | ||
val method = getMethod("Example", "createClassInstance") | ||
discoverProperties<TsValue.TsNumber>( | ||
method = method, | ||
{ r -> r.number == 5.0 } | ||
) | ||
} | ||
|
||
@Test | ||
fun testCreateClassInstanceAndWriteField() { | ||
val method = getMethod("Example", "createClassInstanceAndWriteField") | ||
discoverProperties<TsValue.TsClass>( | ||
method = method, | ||
{ r -> (r.properties.toList().single().second as TsValue.TsNumber).number == 14.0 } | ||
) | ||
} | ||
|
||
@Test | ||
fun testCreateClassInstanceAndWriteValueOfAnotherType() { | ||
val method = getMethod("Example", "createClassInstanceAndWriteValueOfAnotherType") | ||
discoverProperties<TsValue.TsClass>( | ||
method = method, | ||
{ r -> r.properties.toList().single().second is TsValue.TsNull } | ||
) | ||
} | ||
|
||
@Test | ||
fun testCreateAnonymousClass() { | ||
val method = getMethod("Example", "createAnonymousClass") | ||
discoverProperties<TsValue.TsClass>( | ||
method = method, | ||
{ r -> (r.properties.toList().single().second as TsValue.TsNumber).number == 15.0 } | ||
) | ||
} | ||
} |
Check warning
Code scanning / detekt
Detects unused imports Warning