-
Notifications
You must be signed in to change notification settings - Fork 26
Division and remainder operator #290
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
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
15aab78
Division operator
CaelmBleidd 5c7201b
Remainder operator
CaelmBleidd bd5a3c9
Format
Lipen 05b3d09
Use concrete return type `UExpr<KFp64Sort>`
Lipen 1358d63
Merge branch 'main' into caelmbleidd/division
CaelmBleidd 9b3a078
Remove unnecessary 'scope.calcOnState'
Lipen b6f2db8
Format
Lipen 81f7d7d
Add missing 'let' and headers
Lipen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
usvm-ts/src/test/kotlin/org/usvm/samples/operators/Division.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| package org.usvm.samples.operators | ||
|
|
||
| import org.jacodb.ets.model.EtsScene | ||
| import org.usvm.api.TsTestValue | ||
| import org.usvm.util.TsMethodTestRunner | ||
| import org.usvm.util.toDouble | ||
| import kotlin.test.Test | ||
|
|
||
| class Division : TsMethodTestRunner() { | ||
| private val className = this::class.simpleName!! | ||
|
|
||
| override val scene: EtsScene = loadSampleScene(className, folderPrefix = "operators") | ||
|
|
||
| @Test | ||
| fun testTwoNumbersDivision() { | ||
| val method = getMethod(className, "twoNumbersDivision") | ||
| discoverProperties<TsTestValue.TsNumber, TsTestValue.TsNumber, TsTestValue.TsNumber>( | ||
| method = method, | ||
| { a, b, r -> a.number / b.number == 4.0 && r.number == 4.0 }, | ||
| { a, b, r -> a.number / b.number == Double.POSITIVE_INFINITY && r.number == Double.POSITIVE_INFINITY }, | ||
| { a, b, r -> a.number / b.number == Double.NEGATIVE_INFINITY && r.number == Double.NEGATIVE_INFINITY }, | ||
| { a, b, r -> (a.number / b.number).isNaN() && r.number.isNaN() }, | ||
| { a, b, r -> a.number / b.number != 4.0 && r.number == a.number / b.number } | ||
| ) | ||
| } | ||
|
|
||
| @Test | ||
| fun testBooleanDivision() { | ||
| val method = getMethod(className, "booleanDivision") | ||
| discoverProperties<TsTestValue.TsBoolean, TsTestValue.TsBoolean, TsTestValue.TsNumber>( | ||
| method = method, | ||
| { a, b, r -> a.value.toDouble() / b.value.toDouble() == 0.0 && r.number == 0.0 }, | ||
| { a, b, r -> | ||
| a.value.toDouble() / b.value.toDouble() != 0.0 && (r.number == (a.value.toDouble() / b.value.toDouble()) || r.number.isNaN()) | ||
| } | ||
| ) | ||
| } | ||
|
|
||
| @Test | ||
| fun testMixedDivision() { | ||
| val method = getMethod(className, "mixedDivision") | ||
| discoverProperties<TsTestValue.TsNumber, TsTestValue.TsBoolean, TsTestValue.TsNumber>( | ||
| method = method, | ||
| { a, b, r -> a.number / b.value.toDouble() == 4.0 && r.number == 4.0 }, | ||
| { a, b, r -> a.number / b.value.toDouble() == Double.POSITIVE_INFINITY && r.number == Double.POSITIVE_INFINITY }, | ||
| { a, b, r -> a.number / b.value.toDouble() == Double.NEGATIVE_INFINITY && r.number == Double.NEGATIVE_INFINITY }, | ||
| { a, b, r -> (a.number / b.value.toDouble()).isNaN() && r.number.isNaN() }, | ||
| { a, b, r -> a.number / b.value.toDouble() != 4.0 && r.number == a.number / b.value.toDouble() } | ||
| ) | ||
| } | ||
|
|
||
| @Test | ||
| fun testUnknownDivision() { | ||
| val method = getMethod(className, "unknownDivision") | ||
| discoverProperties<TsTestValue, TsTestValue, TsTestValue.TsNumber>( | ||
| method = method, | ||
| { a, b, r -> (a is TsTestValue.TsUndefined || b is TsTestValue.TsUndefined) && r.number.isNaN() }, | ||
| { _, _, r -> r.number == 4.0 }, | ||
| { _, _, r -> r.number == Double.POSITIVE_INFINITY }, | ||
| { _, _, r -> r.number == Double.NEGATIVE_INFINITY }, | ||
| { _, _, r -> r.number.isNaN() }, | ||
| ) | ||
| } | ||
| } |
80 changes: 80 additions & 0 deletions
80
usvm-ts/src/test/kotlin/org/usvm/samples/operators/Remainder.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| package org.usvm.samples.operators | ||
|
|
||
| import org.junit.jupiter.api.Disabled | ||
| import org.junit.jupiter.api.Test | ||
| import org.usvm.api.TsTestValue | ||
| import org.usvm.util.TsMethodTestRunner | ||
| import org.usvm.util.toDouble | ||
|
|
||
| class Remainder : TsMethodTestRunner() { | ||
| private val className = this::class.simpleName!! | ||
|
|
||
| override val scene = loadSampleScene(className, folderPrefix = "operators") | ||
|
|
||
| @Test | ||
| @Disabled("Never ends") | ||
| fun testTwoNumbersRemainder() { | ||
| val method = getMethod(className, "twoNumbersRemainder") | ||
| discoverProperties<TsTestValue.TsNumber, TsTestValue.TsNumber, TsTestValue.TsNumber>( | ||
| method = method, | ||
| { a, b, r -> | ||
| val res = a.number % b.number | ||
| res != res && (a.number.isNaN() || b.number.isNaN()) | ||
| }, | ||
| { a, b, r -> | ||
| val res = a.number % b.number | ||
| res != res && (a.number == Double.POSITIVE_INFINITY || a.number == Double.NEGATIVE_INFINITY) | ||
| }, | ||
| { a, b, r -> a.number == 0.0 && b.number == 0.0 && r.number.isNaN() }, | ||
| { a, b, r -> | ||
| b.number == 0.0 && a.number != 0.0 && r.number.isNaN() | ||
| }, | ||
| { a, b, r -> | ||
| (b.number == Double.POSITIVE_INFINITY || b.number == Double.NEGATIVE_INFINITY) && r.number == a.number | ||
| }, | ||
| { a, b, r -> a.number == 0.0 && r.number == a.number }, | ||
| { a, b, r -> a.number % b.number == 4.0 && r.number == 4.0 }, | ||
| { a, b, r -> | ||
| val res = a.number % b.number | ||
| !res.isNaN() && res != 4.0 && r.number == res | ||
| }, | ||
| ) | ||
| } | ||
|
|
||
| @Test | ||
| fun testBooleanRemainder() { | ||
| val method = getMethod(className, "booleanRemainder") | ||
| discoverProperties<TsTestValue.TsBoolean, TsTestValue.TsBoolean, TsTestValue.TsNumber>( | ||
| method = method, | ||
| { a, b, r -> a.value.toDouble() % b.value.toDouble() == 0.0 && r.number == 0.0 }, | ||
| { a, b, r -> | ||
| a.value.toDouble() % b.value.toDouble() != 0.0 && (r.number == (a.value.toDouble() % b.value.toDouble()) || r.number.isNaN()) | ||
| } | ||
| ) | ||
| } | ||
|
|
||
| @Test | ||
| @Disabled("Wrong result") | ||
| fun testMixedRemainder() { | ||
| val method = getMethod(className, "mixedRemainder") | ||
| discoverProperties<TsTestValue.TsNumber, TsTestValue.TsBoolean, TsTestValue.TsNumber>( | ||
| method = method, | ||
| { a, b, r -> a.number % b.value.toDouble() == 4.0 && r.number == 4.0 }, | ||
| { a, b, r -> (a.number % b.value.toDouble()).isNaN() && r.number.isNaN() }, | ||
| { a, b, r -> a.number % b.value.toDouble() != 4.0 && r.number == a.number % b.value.toDouble() } | ||
| ) | ||
| } | ||
|
|
||
| @Test | ||
| @Disabled("Never ends") | ||
| fun testUnknownRemainder() { | ||
| val method = getMethod(className, "unknownRemainder") | ||
| discoverProperties<TsTestValue, TsTestValue, TsTestValue.TsNumber>( | ||
| method = method, | ||
| { a, b, r -> (a is TsTestValue.TsUndefined || b is TsTestValue.TsUndefined) && r.number.isNaN() }, | ||
| { _, _, r -> r.number == 4.0 }, | ||
| { _, _, r -> r.number.isNaN() }, | ||
| { _, _, r -> !r.number.isNaN() && r.number != 4.0 } | ||
| ) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.