-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Nested transformers * Remove deprecated methods * Update examples * Upgrade version to 0.5.0
- Loading branch information
Showing
8 changed files
with
80 additions
and
52 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
|
@@ -9,7 +9,7 @@ plugins { | |
} | ||
|
||
group = "org.ksmt" | ||
version = "0.4.6" | ||
version = "0.5.0" | ||
|
||
repositories { | ||
mavenCentral() | ||
|
This file contains 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 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 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 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 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
54 changes: 54 additions & 0 deletions
54
ksmt-core/src/test/kotlin/org/ksmt/NestedTransformationTest.kt
This file contains 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,54 @@ | ||
package org.ksmt | ||
|
||
import org.ksmt.expr.KExpr | ||
import org.ksmt.expr.printer.ExpressionPrinter | ||
import org.ksmt.expr.transformer.KNonRecursiveTransformer | ||
import org.ksmt.expr.transformer.KTransformerBase | ||
import org.ksmt.sort.KSort | ||
import org.ksmt.utils.getValue | ||
import kotlin.test.Test | ||
import kotlin.test.assertEquals | ||
|
||
class NestedTransformationTest { | ||
|
||
@Test | ||
fun nestedTransformationTest(): Unit = with(KContext()) { | ||
val a by intSort | ||
val b by intSort | ||
|
||
val transformer = TestAuxTransformer(this) | ||
|
||
val e0 = TestAuxExpr(this, TestAuxExpr(this, a) + TestAuxExpr(this, b)) | ||
val e1 = TestAuxExpr(this, e0 * TestAuxExpr(this, a)) | ||
val expr = TestAuxExpr(this, e1 / TestAuxExpr(this, b)) | ||
val actual = transformer.apply(expr) | ||
|
||
val expected = transformer.apply(((a + b) * a) / b) | ||
|
||
assertEquals(expected, actual) | ||
} | ||
|
||
class TestAuxTransformer(ctx: KContext) : KNonRecursiveTransformer(ctx) { | ||
fun <T : KSort> transformAux(expr: TestAuxExpr<T>): KExpr<T> { | ||
// nested transformation | ||
return apply(expr.nested) | ||
} | ||
} | ||
|
||
class TestAuxExpr<T : KSort>(ctx: KContext, val nested: KExpr<T>) : KExpr<T>(ctx) { | ||
override val sort: T | ||
get() = nested.sort | ||
|
||
override fun accept(transformer: KTransformerBase): KExpr<T> { | ||
transformer as TestAuxTransformer | ||
return transformer.transformAux(this) | ||
} | ||
|
||
override fun print(printer: ExpressionPrinter) { | ||
printer.append(nested) | ||
} | ||
|
||
override fun internEquals(other: Any): Boolean = error("Interning is not used") | ||
override fun internHashCode(): Int = error("Interning is not used") | ||
} | ||
} |