Remove Spek add Kotest

This commit is contained in:
Edwin Jakobs
2023-11-18 22:36:35 +01:00
parent 2d3ae83729
commit 5012f8fb14
34 changed files with 255 additions and 309 deletions

View File

@@ -7,10 +7,10 @@ openrndr = { require = "[0.4.2, 0.5.0)" }
kotlinxCoroutines = "1.7.3"
kotlinLogging = "3.0.0"
kotlinxSerialization = "1.6.1"
kotest = "5.8.0"
dokka = "1.7.10"
nebulaRelease = "18.0.4"
gradleNexusPublish = "2.0.0-rc-1"
spek = "2.0.19"
boofcv = "1.0.0"
kluent = "1.73"
junitJupiter = "5.9.2"
@@ -43,6 +43,11 @@ kotlin-gradle-plugin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-p
kotlin-serialization-gradle-plugin = { group = "org.jetbrains.kotlin", name = "kotlin-serialization", version.ref = "kotlin" }
dokka-gradle-plugin = { group = "org.jetbrains.dokka", name = "dokka-gradle-plugin", version.ref = "dokka" }
kotest-assertions = { group = "io.kotest", name = "kotest-assertions-core", version.ref = "kotest" }
kotest-runner = { group = "io.kotest", name = "kotest-runner-junit5", version.ref = "kotest" }
kotest-framework-engine = { group = "io.kotest", name = "kotest-framework-engine", version.ref = "kotest" }
openrndr-application = { group = "org.openrndr", name = "openrndr-application", version.ref = "openrndr" }
openrndr-extensions = { group = "org.openrndr", name = "openrndr-extensions", version.ref = "openrndr" }
openrndr-math = { group = "org.openrndr", name = "openrndr-math", version.ref = "openrndr" }
@@ -73,8 +78,6 @@ antlr-runtime = { group = "org.antlr", name = "antlr4-runtime", version.ref = "a
jupiter-api = { group = "org.junit.jupiter", name = "junit-jupiter-api", version.ref = "junitJupiter" }
jupiter-engine = { group = "org.junit.jupiter", name = "junit-jupiter-engine", version.ref = "junitJupiter" }
spek-dsl = { group = "org.spekframework.spek2", name = "spek-dsl-jvm", version.ref = "spek" }
spek-junit5 = { group = "org.spekframework.spek2", name = "spek-runner-junit5", version.ref = "spek" }
kluent = { group = "org.amshove.kluent", name = "kluent", version.ref = "kluent" }
slf4j-simple = { group = "org.slf4j", name = "slf4j-simple", version.ref = "slf4j" }
@@ -82,6 +85,8 @@ slf4j-simple = { group = "org.slf4j", name = "slf4j-simple", version.ref = "slf4
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
nebula-release = { id = "nebula.release", version.ref = "nebulaRelease" }
gradle-nexus-publish = { id = "io.github.gradle-nexus.publish-plugin", version.ref = "gradleNexusPublish" }
kotest-multiplatform = { id = "io.kotest.multiplatform", version.ref = "kotest"}
[bundles]
jupiter = ["jupiter-api", "jupiter-engine"]

View File

@@ -6,7 +6,6 @@ kotlin {
jvm {
testRuns["test"].executionTask {
useJUnitPlatform {
includeEngines("spek2")
}
}
}

View File

@@ -5,19 +5,11 @@ plugins {
// version was used. If openrndr were an included build, we probably wouldn't need to do this.
// https://github.com/gradle/gradle/issues/20084
id(libs.plugins.kotlin.serialization.get().pluginId)
alias(libs.plugins.kotest.multiplatform)
}
kotlin {
jvm {
testRuns["test"].executionTask {
useJUnitPlatform {
includeEngines("spek2")
}
}
}
sourceSets {
@Suppress("UNUSED_VARIABLE")
val commonMain by getting {
dependencies {
implementation(project(":orx-parameters"))
@@ -30,24 +22,14 @@ kotlin {
}
}
@Suppress("UNUSED_VARIABLE")
val commonTest by getting {
dependencies {
implementation(libs.kotlin.serialization.json)
implementation(libs.kotest.assertions)
implementation(libs.kotest.framework.engine)
}
}
@Suppress("UNUSED_VARIABLE")
val jvmTest by getting {
dependencies {
implementation(libs.kluent)
implementation(libs.spek.dsl)
runtimeOnly(libs.spek.junit5)
runtimeOnly(libs.kotlin.reflect)
}
}
@Suppress("UNUSED_VARIABLE")
val jvmDemo by getting {
dependencies {
implementation(project(":orx-camera"))

View File

@@ -1,21 +1,25 @@
import org.amshove.kluent.`should be equal to`
package spaces
import io.kotest.core.spec.style.DescribeSpec
import org.openrndr.color.ColorRGBa
import org.openrndr.color.Linearity
import org.openrndr.extra.color.palettes.rangeTo
import org.spekframework.spek2.Spek
import org.spekframework.spek2.style.specification.describe
object TestMix : Spek({
import kotlin.test.assertEquals
import kotlin.test.assertSame
class TestMix : DescribeSpec({
describe("two srgb colors") {
val a = ColorRGBa.BLUE
val b = ColorRGBa.RED
a.linearity `should be equal to` Linearity.SRGB
assertEquals(Linearity.SRGB, a.linearity)
it("should mix properly") {
a.mix(b, 0.0) `should be equal to` a
a.mix(b, 1.0) `should be equal to` b
assertSame(a, a.mix(b, 0.0))
assertSame(b, a.mix(b, 1.0))
}
}
@@ -24,8 +28,8 @@ object TestMix : Spek({
val b = ColorRGBa.RED.toLinear()
it("should mix properly") {
a.mix(b, 0.0) `should be equal to` a
a.mix(b, 1.0) `should be equal to` b
assertSame(a, a.mix(b, 0.0))
assertSame(b, a.mix(b, 1.0))
}
}
@@ -34,9 +38,9 @@ object TestMix : Spek({
val b = ColorRGBa.RED
val blend = a..b blend 2
blend.size `should be equal to` 2
blend[0] `should be equal to` a
blend[1] `should be equal to` b
assertEquals(2, blend.size)
assertEquals(a, blend[0])
assertEquals(b, blend[1])
}
})

View File

@@ -2,7 +2,6 @@ package spaces
import org.openrndr.color.ColorRGBa
import org.openrndr.extra.color.spaces.toOKHSLa
import org.openrndr.extra.color.spaces.toOKHSVa
import kotlin.test.Test
import kotlin.test.assertTrue

View File

@@ -1,17 +1,17 @@
plugins {
org.openrndr.extra.convention.`kotlin-multiplatform`
alias(libs.plugins.kotest.multiplatform)
}
kotlin {
jvm {
testRuns["test"].executionTask {
useJUnitPlatform {
includeEngines("spek2")
}
}
}
sourceSets {
@Suppress("UNUSED_VARIABLE")
val commonMain by getting {
dependencies {
implementation(project(":orx-parameters"))
@@ -23,13 +23,17 @@ kotlin {
}
}
val commonTest by getting {
dependencies {
implementation(libs.kotest.assertions)
implementation(libs.kotest.framework.engine)
}
}
@Suppress("UNUSED_VARIABLE")
val jvmTest by getting {
dependencies {
implementation(libs.kluent)
implementation(libs.spek.dsl)
runtimeOnly(libs.spek.junit5)
implementation(libs.kotest.assertions)
implementation(libs.kotest.framework.engine)
runtimeOnly(libs.kotlin.reflect)
}
}

View File

@@ -0,0 +1,26 @@
import io.kotest.core.spec.style.DescribeSpec
import io.kotest.matchers.equals.shouldBeEqual
import org.openrndr.extra.gradientdescent.dot
class TestDot : DescribeSpec({
describe("some vectors") {
val a = doubleArrayOf(10.0)
val b = doubleArrayOf(4.0)
dot(a, b).shouldBeEqual(40.0)
}
describe("a matrix and a vector") {
val a = arrayOf(doubleArrayOf(10.0))
val b = doubleArrayOf(1.0)
val d = dot(a, b)
d[0].shouldBeEqual(10.0)
}
describe("another matrix and a vector") {
val a = arrayOf(doubleArrayOf(1.0))
val b = doubleArrayOf(19.99999999995339)
val d = dot(a, b)
d[0].shouldBeEqual(19.99999999995339)
}
})

View File

@@ -1,18 +1,16 @@
import org.amshove.kluent.`should be equal to`
import org.amshove.kluent.`should equal`
import io.kotest.core.spec.style.DescribeSpec
import io.kotest.matchers.equals.shouldBeEqual
import org.openrndr.extra.gradientdescent.gradient
import org.spekframework.spek2.Spek
import org.spekframework.spek2.style.specification.describe
object TestGradient : Spek({
class TestGradient : DescribeSpec({
describe("a simple 1d function") {
fun parabola(x: DoubleArray): Double {
return x[0] * x[0]
}
it("its gradient at x=0 is 0.0") {
val g0 = gradient(doubleArrayOf(0.0), ::parabola)
g0.size `should equal` 1
g0[0] `should be equal to` 0.0
g0.size.shouldBeEqual(1)
g0[0].shouldBeEqual(0.0)
}
it("its gradient at x=1 is ~2.0") {
val g1 = gradient(doubleArrayOf(1.0), ::parabola)
@@ -29,8 +27,8 @@ object TestGradient : Spek({
it("its gradient at x=0 is 0.0") {
val g0 = gradient(doubleArrayOf(0.0, 0.0), ::parabola)
g0.size `should equal` 2
g0[0] `should be equal to` 0.0
g0.size.shouldBeEqual(2)
g0[0].shouldBeEqual(0.0)
}
it("its gradient at x=1 is ~2.0") {

View File

@@ -1,8 +1,7 @@
import io.kotest.core.spec.style.DescribeSpec
import org.openrndr.extra.gradientdescent.minimize
import org.spekframework.spek2.Spek
import org.spekframework.spek2.style.specification.describe
object TestMinimize : Spek({
class TestMinimize : DescribeSpec({
describe("a simple 1d function") {
fun parabola(x: DoubleArray): Double {
return (x[0] + 1) * (x[0] + 1)

View File

@@ -1,28 +0,0 @@
package org.openrndr.extra.gradientdescent
import org.amshove.kluent.`should be equal to`
import org.spekframework.spek2.Spek
import org.spekframework.spek2.style.specification.describe
object TestDot : Spek({
describe("some vectors") {
val a = doubleArrayOf(10.0)
val b = doubleArrayOf(4.0)
dot(a,b) `should be equal to` 40.0
}
describe("a matrix and a vector") {
val a = arrayOf(doubleArrayOf(10.0))
val b = doubleArrayOf(1.0)
val d = dot(a,b)
d[0] `should be equal to` 10.0
}
describe("a matrix and a vector") {
val a = arrayOf(doubleArrayOf(1.0))
val b = doubleArrayOf(19.99999999995339)
val d = dot(a,b)
d[0] `should be equal to` 19.99999999995339
}
})

View File

@@ -1,10 +1,10 @@
import org.amshove.kluent.shouldBeNear
import io.kotest.core.spec.style.DescribeSpec
import io.kotest.matchers.doubles.plusOrMinus
import io.kotest.matchers.shouldBe
import org.openrndr.extra.gradientdescent.minimizeModel
import org.openrndr.math.Vector2
import org.spekframework.spek2.Spek
import org.spekframework.spek2.style.specification.describe
object TestMinimizeModel : Spek({
class TestMinimizeModel : DescribeSpec({
describe("a model") {
val m = object {
var x = 0.0
@@ -14,8 +14,8 @@ object TestMinimizeModel : Spek({
minimizeModel(m) { m->
(m.x - 4.0) * (m.x - 4.0) + (m.y - 3.0) * (m.y - 3.0)
}
m.x.shouldBeNear(4.0, 0.01)
m.y.shouldBeNear(3.0, 0.01)
m.x.shouldBe(4.0.plusOrMinus(0.01))
m.y.shouldBe(3.0.plusOrMinus(0.01))
}
}
@@ -27,8 +27,8 @@ object TestMinimizeModel : Spek({
minimizeModel(m) { m->
(m.position.x - 4.0) * (m.position.x - 4.0) + (m.position.y - 3.0) * (m.position.y - 3.0)
}
m.position.x.shouldBeNear(4.0, 0.01)
m.position.y.shouldBeNear(3.0, 0.01)
m.position.x.shouldBe(4.0.plusOrMinus(0.01))
m.position.y.shouldBe(3.0.plusOrMinus(0.01))
}
}
})

View File

@@ -10,7 +10,6 @@ tasks.withType<KotlinCompile> {
tasks.test {
useJUnitPlatform {
includeEngines("spek2")
}
}
@@ -25,7 +24,7 @@ dependencies {
implementation(libs.kotlin.scriptingJSR223)
implementation(libs.kotlin.coroutines)
testImplementation(libs.kluent)
testImplementation(libs.spek.dsl)
testRuntimeOnly(libs.spek.junit5)
testImplementation(libs.kotest.runner)
testImplementation(libs.kotest.assertions)
testRuntimeOnly(libs.kotlin.reflect)
}

View File

@@ -1,10 +1,8 @@
import org.amshove.kluent.`should be equal to`
import io.kotest.core.spec.style.DescribeSpec
import io.kotest.matchers.equals.shouldBeEqual
import org.openrndr.extra.olive.ScriptObjectLoader
import org.openrndr.extra.olive.loadFromScript
import org.spekframework.spek2.Spek
import org.spekframework.spek2.style.specification.describe
object TestLoadScript : Spek({
class TestLoadScript : DescribeSpec({
describe("some script") {
val loader = ScriptObjectLoader()
@@ -12,7 +10,7 @@ object TestLoadScript : Spek({
val number = loader.load<Int>("5")
it("should evaluate properly") {
number `should be equal to` 5
number shouldBeEqual 5
}
}
})

View File

@@ -1,15 +1,14 @@
import org.amshove.kluent.`should be equal to`
import io.kotest.core.spec.style.DescribeSpec
import io.kotest.matchers.equals.shouldBeEqual
import org.openrndr.extra.olive.loadFromScriptContentsKSH
import org.spekframework.spek2.Spek
import org.spekframework.spek2.style.specification.describe
object TestLoadScriptKSH : Spek({
class TestLoadScriptKSH : DescribeSpec({
describe("some script") {
val number = loadFromScriptContentsKSH<Int>("5")
it("should evaluate properly") {
number `should be equal to` 5
number shouldBeEqual 5
}
}
})

View File

@@ -10,7 +10,6 @@ tasks.withType<KotlinCompile> {
tasks.test {
useJUnitPlatform {
includeEngines("spek2")
}
}
@@ -20,8 +19,6 @@ dependencies {
implementation(libs.openrndr.math)
implementation(libs.kotlin.coroutines)
implementation(libs.kotlin.reflect)
testImplementation(libs.spek.dsl)
testRuntimeOnly(libs.spek.junit5)
testRuntimeOnly(libs.kotlin.reflect)
demoImplementation(libs.openrndr.dialogs)
demoImplementation(libs.gson)

View File

@@ -1,5 +1,6 @@
plugins {
org.openrndr.extra.convention.`kotlin-multiplatform`
alias(libs.plugins.kotest.multiplatform)
}
val embedShaders = tasks.register<EmbedShadersTask>("embedShaders") {
@@ -11,17 +12,8 @@ val embedShaders = tasks.register<EmbedShadersTask>("embedShaders") {
}.get()
kotlin {
jvm {
testRuns["test"].executionTask {
useJUnitPlatform {
includeEngines("spek2")
}
}
}
kotlin.sourceSets.getByName("commonMain").kotlin.srcDir(embedShaders.outputDir)
sourceSets {
@Suppress("UNUSED_VARIABLE")
val commonMain by getting {
dependencies {
implementation(libs.openrndr.math)
@@ -33,16 +25,13 @@ kotlin {
}
}
@Suppress("UNUSED_VARIABLE")
val jvmTest by getting {
val commonTest by getting {
dependencies {
implementation(libs.spek.dsl)
runtimeOnly(libs.spek.junit5)
runtimeOnly(libs.kotlin.reflect)
implementation(libs.kotest.assertions)
implementation(libs.kotest.framework.engine)
}
}
@Suppress("UNUSED_VARIABLE")
val jvmDemo by getting {
dependencies {
implementation(project(":orx-hash-grid"))

View File

@@ -1,9 +1,8 @@
import io.kotest.core.spec.style.DescribeSpec
import org.openrndr.extra.noise.*
import org.spekframework.spek2.Spek
import org.spekframework.spek2.style.specification.describe
import kotlin.test.assertEquals
object TestGradient : Spek({
class TestGradient : DescribeSpec({
describe("Noise") {
it("has a gradient") {
gradient1D(::perlinLinear, 100, 0.1)

View File

@@ -1,9 +1,8 @@
import io.kotest.core.spec.style.DescribeSpec
import org.openrndr.extra.noise.fastFloor
import org.spekframework.spek2.Spek
import org.spekframework.spek2.style.specification.describe
import kotlin.test.assertEquals
object TestMathUtils : Spek({
class TestMathUtils : DescribeSpec({
describe("Fast floor") {
it("it is corrrect for 0.0") {
assertEquals(0, 0.0.fastFloor())

View File

@@ -1,11 +1,11 @@
import io.kotest.core.spec.style.DescribeSpec
import org.openrndr.extra.noise.Random
import org.openrndr.extra.noise.perlinQuintic
import org.openrndr.math.Vector4
import org.spekframework.spek2.Spek
import org.spekframework.spek2.style.specification.describe
import kotlin.test.assertEquals
object TestVectorShortcutFunctions : Spek({
class TestVectorShortcutFunctions : DescribeSpec({
val v = Vector4(1.13, 2.74, 3.59, 4.83)

View File

@@ -1,5 +1,6 @@
plugins {
org.openrndr.extra.convention.`kotlin-multiplatform`
alias(libs.plugins.kotest.multiplatform)
}
kotlin {
@@ -10,6 +11,7 @@ kotlin {
implementation(libs.openrndr.application)
implementation(libs.openrndr.math)
implementation(libs.kotlin.reflect)
}
}
@@ -17,11 +19,10 @@ kotlin {
@Suppress("UNUSED_VARIABLE")
val jvmTest by getting {
dependencies {
implementation(libs.kluent)
implementation(libs.spek.dsl)
runtimeOnly(libs.spek.junit5)
implementation(libs.kotest.assertions)
implementation(libs.kotest.framework.engine)
implementation(libs.kotlin.serialization.json)
runtimeOnly(libs.kotlin.reflect)
}
}
}

View File

@@ -1,12 +1,16 @@
import org.amshove.kluent.*
import org.junit.jupiter.api.Assertions.assertEquals
import io.kotest.assertions.throwables.shouldThrowUnit
import io.kotest.core.spec.style.DescribeSpec
import io.kotest.matchers.collections.shouldBeIn
import io.kotest.matchers.doubles.plusOrMinus
import io.kotest.matchers.equals.shouldBeEqual
import io.kotest.matchers.nulls.shouldBeNull
import io.kotest.matchers.shouldBe
import org.openrndr.color.ColorRGBa
import org.openrndr.extra.parameters.*
import org.openrndr.math.Vector2
import org.openrndr.math.Vector3
import org.openrndr.math.Vector4
import org.spekframework.spek2.Spek
import org.spekframework.spek2.style.specification.describe
import kotlin.test.assertEquals
val a = object {
@DoubleParameter("a double scalar", 0.0, 1.0, order = 0)
@@ -52,81 +56,83 @@ val a = object {
}
object TestAnnotations : Spek({
class TestAnnotations : DescribeSpec({
describe("an annotated object") {
it("has listable parameters") {
val list = a.listParameters()
list.size `should be equal to` 13
list.size shouldBeEqual 13
list[0].property?.name `should be equal to` "d"
list[0].parameterType `should be equal to` ParameterType.Double
list[0].label `should be equal to` "a double scalar"
list[0].property?.name shouldBe "d"
list[0].parameterType shouldBeEqual ParameterType.Double
list[0].label shouldBeEqual "a double scalar"
list[0].doubleRange?.let {
it.start shouldBeInRange 0.0..0.0001
it.endInclusive shouldBeInRange 0.999..1.001
it.start.shouldBe(0.0.plusOrMinus(0.001))
it.endInclusive.shouldBe(1.0.plusOrMinus(0.001))
}
list[0].precision `should be equal to` 3
list[0].precision?.shouldBeEqual(3)
list[1].property?.name `should be equal to` "i"
list[1].parameterType `should be equal to` ParameterType.Int
list[1].label `should be equal to` "an integer scalar"
list[1].property?.name?.shouldBeEqual("i")
list[1].parameterType shouldBeEqual ParameterType.Int
list[1].label shouldBeEqual "an integer scalar"
list[1].intRange?.let {
it.first `should be equal to` 1
it.last `should be equal to` 100
it.first shouldBeEqual 1
it.last shouldBeEqual 100
}
list[2].property?.name `should be equal to` "b"
list[2].parameterType `should be equal to` ParameterType.Boolean
list[2].label `should be equal to` "a boolean parameter"
list[2].precision `should be equal to` null
list[2].property?.name?.shouldBeEqual("b")
list[2].parameterType shouldBeEqual ParameterType.Boolean
list[2].label shouldBeEqual "a boolean parameter"
list[2].precision?.shouldBeNull()
list[3].parameterType `should be equal to` ParameterType.Action
list[3].property `should be equal to` null
list[3].label `should be equal to` "an action parameter"
list[3].parameterType shouldBeEqual ParameterType.Action
list[3].property?.shouldBeNull()
list[3].label shouldBeEqual "an action parameter"
/* test if we can call the annotated function, this is performed by raising an expected exception in the
function in the annotated function.
*/
invoking {
shouldThrowUnit<IllegalStateException> {
try {
list[3].function?.call(a)
} catch (e: java.lang.reflect.InvocationTargetException) {
/* this unpacks the exception that is wrapped in the ITExc */
throw (e.targetException)
}
} `should throw` IllegalStateException::class withMessage "this is to test if this function can be called"
}
list[4].parameterType `should be equal to` ParameterType.Text
list[4].property?.name `should be equal to` "t"
list[4].label `should be equal to` "a text parameter"
list[5].parameterType `should be equal to` ParameterType.Color
list[5].property?.name `should be equal to` "c"
list[5].label `should be equal to` "a color parameter"
list[4].parameterType shouldBeEqual ParameterType.Text
list[4].property?.name?.shouldBeEqual("t")
list[4].label shouldBeEqual "a text parameter"
list[6].parameterType `should be equal to` ParameterType.XY
list[6].property?.name `should be equal to` "xy"
list[6].label `should be equal to` "an XY parameter"
list[5].parameterType shouldBeEqual ParameterType.Color
list[5].property?.name?.shouldBeEqual("c")
list[5].label shouldBeEqual "a color parameter"
list[7].parameterType `should be equal to` ParameterType.DoubleList
list[7].property?.name `should be equal to` "dl"
list[7].label `should be equal to` "a double list parameter"
list[6].parameterType shouldBeEqual ParameterType.XY
list[6].property?.name?.shouldBeEqual("xy")
list[6].label shouldBeEqual "an XY parameter"
list[8].parameterType `should be equal to` ParameterType.Vector2
list[8].property?.name `should be equal to` "v2"
list[8].label `should be equal to` "a vector 2 parameter"
list[7].parameterType shouldBeEqual ParameterType.DoubleList
list[7].property?.name?.shouldBeEqual("dl")
list[7].label shouldBeEqual "a double list parameter"
list[9].parameterType `should be equal to` ParameterType.Vector3
list[9].property?.name `should be equal to` "v3"
list[9].label `should be equal to` "a vector 3 parameter"
list[8].parameterType shouldBeEqual ParameterType.Vector2
list[8].property?.name?.shouldBeEqual("v2")
list[8].label shouldBeEqual "a vector 2 parameter"
list[10].parameterType `should be equal to` ParameterType.Vector4
list[10].property?.name `should be equal to` "v4"
list[10].label `should be equal to` "a vector 4 parameter"
list[9].parameterType shouldBeEqual ParameterType.Vector3
list[9].property?.name?.shouldBeEqual("v3")
list[9].label shouldBeEqual "a vector 3 parameter"
list[11].parameterType `should be equal to` ParameterType.Option
list[11].property?.name `should be equal to` "o"
list[11].label `should be equal to` "an option parameter"
list[10].parameterType shouldBeEqual ParameterType.Vector4
list[10].property?.name?.shouldBeEqual("v4")
list[10].label shouldBeEqual "a vector 4 parameter"
list[11].parameterType shouldBeEqual ParameterType.Option
list[11].property?.name?.shouldBeEqual("o")
list[11].label shouldBeEqual "an option parameter"
assertEquals(list[12].parameterType, ParameterType.Path)
assertEquals(list[12].property?.name, "p")

View File

@@ -6,7 +6,6 @@ kotlin {
jvm {
testRuns["test"].executionTask {
useJUnitPlatform {
includeEngines("spek2")
}
}
}

View File

@@ -1,5 +1,6 @@
plugins {
org.openrndr.extra.convention.`kotlin-multiplatform`
alias(libs.plugins.kotest.multiplatform)
}
val embedShaders = tasks.register<EmbedShadersTask>("embedShaders") {
@@ -9,16 +10,8 @@ val embedShaders = tasks.register<EmbedShadersTask>("embedShaders") {
}.get()
kotlin {
jvm {
testRuns["test"].executionTask {
useJUnitPlatform {
includeEngines("spek2")
}
}
}
kotlin.sourceSets.getByName("commonMain").kotlin.srcDir(embedShaders.outputDir)
sourceSets {
@Suppress("UNUSED_VARIABLE")
val commonMain by getting {
dependencies {
implementation(libs.openrndr.application)
@@ -31,10 +24,9 @@ kotlin {
val jvmTest by getting {
dependencies {
runtimeOnly(libs.slf4j.simple)
implementation(libs.kluent)
implementation(libs.spek.dsl)
runtimeOnly(libs.spek.junit5)
runtimeOnly(libs.kotlin.reflect)
implementation(libs.kotest.assertions)
implementation(libs.kotest.framework.engine)
}
}
}

View File

@@ -1,12 +1,13 @@
import org.amshove.kluent.`should be equal to`
import org.amshove.kluent.internal.assertFails
import io.kotest.assertions.shouldFail
import io.kotest.assertions.throwables.shouldThrow
import io.kotest.assertions.throwables.shouldThrowAny
import io.kotest.assertions.throwables.shouldThrowUnit
import io.kotest.core.spec.style.DescribeSpec
import io.kotest.matchers.equals.shouldBeEqual
import org.openrndr.extra.shaderphrases.ShaderPhraseRegistry.getGLSLFunctionName
import org.spekframework.spek2.Spek
import org.spekframework.spek2.style.specification.describe
object TestFunctionNameRx : Spek({
class TestFunctionNameRx : DescribeSpec({
describe("A function name") {
mapOf(
"ivec4 aaa() {" to "aaa",
"ivec3 bbb() {" to "bbb",
@@ -31,8 +32,8 @@ object TestFunctionNameRx : Spek({
""".trimMargin() to "white"
).forEach { (goodGLSL, expectedFuncName) ->
it("can be extracted from valid GLSL") {
getGLSLFunctionName(goodGLSL) `should be equal to`
expectedFuncName
getGLSLFunctionName(goodGLSL).shouldBeEqual(
expectedFuncName)
}
}
}
@@ -43,7 +44,7 @@ object TestFunctionNameRx : Spek({
"float rnd {",
).forEach { badGLSL ->
it("is not extracted if GLSL function not declared") {
assertFails {
shouldThrowUnit<Throwable> {
val funcName = getGLSLFunctionName(badGLSL)
}
}

View File

@@ -1,10 +1,9 @@
import org.amshove.kluent.`should be`
import io.kotest.core.spec.style.DescribeSpec
import io.kotest.matchers.equals.shouldBeEqual
import org.openrndr.extra.shaderphrases.ShaderPhrase
import org.openrndr.extra.shaderphrases.ShaderPhraseRegistry
import org.spekframework.spek2.Spek
import org.spekframework.spek2.style.specification.describe
object TestShaderPhrase : Spek({
class TestShaderPhrase : DescribeSpec({
describe("A shader phrase") {
val phrase = ShaderPhrase(
"""
@@ -16,7 +15,7 @@ object TestShaderPhrase : Spek({
phrase.register()
}
it("can be found") {
ShaderPhraseRegistry.findPhrase("test_phrase") `should be` phrase
ShaderPhraseRegistry.findPhrase("test_phrase")?.shouldBeEqual(phrase)
}
}
})

View File

@@ -1,11 +1,10 @@
import org.amshove.kluent.`should be`
import io.kotest.core.spec.style.DescribeSpec
import io.kotest.matchers.equals.shouldBeEqual
import org.openrndr.extra.shaderphrases.ShaderPhrase
import org.openrndr.extra.shaderphrases.ShaderPhraseBook
import org.openrndr.extra.shaderphrases.ShaderPhraseRegistry
import org.spekframework.spek2.Spek
import org.spekframework.spek2.style.specification.describe
class TestShaderPhraseBook : Spek({
class TestShaderPhraseBook : DescribeSpec({
describe("A shader phrase book") {
val book = object : ShaderPhraseBook("testBook") {
val phrase = ShaderPhrase(
@@ -21,7 +20,7 @@ class TestShaderPhraseBook : Spek({
it("can be found") {
ShaderPhraseRegistry.findPhrase(
"testBook.test_phrase"
) `should be` book.phrase
)!!.shouldBeEqual(book.phrase)
}
}
})

View File

@@ -1,12 +1,11 @@
import org.amshove.kluent.`should contain`
import org.amshove.kluent.`should not contain`
import io.kotest.core.spec.style.DescribeSpec
import io.kotest.matchers.string.shouldContain
import io.kotest.matchers.string.shouldNotContain
import org.openrndr.extra.shaderphrases.ShaderPhrase
import org.openrndr.extra.shaderphrases.ShaderPhraseBook
import org.openrndr.extra.shaderphrases.preprocessShader
import org.spekframework.spek2.Spek
import org.spekframework.spek2.style.specification.describe
class TestShaderPhrasePreprocessing : Spek({
class TestShaderPhrasePreprocessing : DescribeSpec({
describe("the glsl code") {
val book = object : ShaderPhraseBook("testBook") {
val phrase1 = ShaderPhrase("vec3 phrase1() { }")
@@ -24,19 +23,19 @@ class TestShaderPhrasePreprocessing : Spek({
val glslProcessed = preprocessShader(glsl)
it("should not contain phrase1 before preprocessing") {
glsl `should not contain` book.phrase1.phrase
glsl.shouldNotContain(book.phrase1.phrase)
}
it("should not contain phrase2 before preprocessing") {
glsl `should not contain` book.phrase2.phrase
glsl.shouldNotContain(book.phrase2.phrase)
}
it("should contain phrase1 after preprocessing") {
glslProcessed `should contain` book.phrase1.phrase
glslProcessed.shouldContain(book.phrase1.phrase)
}
it("should contain phrase2 after preprocessing") {
glslProcessed `should contain` book.phrase2.phrase
glslProcessed.shouldContain(book.phrase2.phrase)
}
}
})

View File

@@ -1,18 +1,10 @@
plugins {
org.openrndr.extra.convention.`kotlin-multiplatform`
alias(libs.plugins.kotest.multiplatform)
}
kotlin {
jvm {
testRuns["test"].executionTask {
useJUnitPlatform {
includeEngines("spek2")
}
}
}
sourceSets {
@Suppress("UNUSED_VARIABLE")
val commonMain by getting {
dependencies {
implementation(project(":orx-parameters"))
@@ -25,24 +17,21 @@ kotlin {
}
}
@Suppress("UNUSED_VARIABLE")
val jvmMain by getting {
dependencies {
implementation(project(":orx-triangulation"))
}
}
@Suppress("UNUSED_VARIABLE")
val jvmTest by getting {
dependencies {
implementation(libs.kluent)
implementation(libs.spek.dsl)
runtimeOnly(libs.spek.junit5)
implementation(libs.kotest.assertions)
implementation(libs.kotest.framework.engine)
implementation(libs.kotlin.serialization.json)
runtimeOnly(libs.kotlin.reflect)
}
}
@Suppress("UNUSED_VARIABLE")
val jvmDemo by getting {
dependencies {
implementation(project(":orx-camera"))

View File

@@ -1,7 +1,8 @@
import org.amshove.kluent.shouldBeInRange
import io.kotest.matchers.doubles.plusOrMinus
import io.kotest.matchers.shouldBe
import org.openrndr.math.Vector2
infix fun Vector2.`should be near`(other: Vector2) {
x shouldBeInRange (other.x - 0.00001..other.x + 0.00001)
y shouldBeInRange (other.y - 0.00001..other.y + 0.00001)
x shouldBe other.x.plusOrMinus(1E-5)
y shouldBe other.y.plusOrMinus(1E-5)
}

View File

@@ -1,13 +1,12 @@
import org.amshove.kluent.`should be equal to`
import io.kotest.core.spec.style.DescribeSpec
import io.kotest.matchers.equals.shouldBeEqual
import org.openrndr.extra.shapes.operators.bevelCorners
import org.openrndr.extra.shapes.operators.roundCorners
import org.openrndr.extra.shapes.regularPolygon
import org.openrndr.shape.Circle
import org.openrndr.shape.contour
import org.spekframework.spek2.Spek
import org.spekframework.spek2.style.specification.describe
object TestChamferCorners : Spek({
class TestChamferCorners : DescribeSpec({
describe("a single segment linear contour") {
val c = contour {
@@ -17,10 +16,10 @@ object TestChamferCorners : Spek({
it("should be similar to a chamfered version") {
val cc = c.bevelCorners(10.0)
cc.segments.size `should be equal to` 1
cc.segments.size shouldBeEqual 1
cc.position(0.0) `should be near` c.position(0.0)
cc.position(1.0) `should be near` c.position(1.0)
cc.closed `should be equal to` c.closed
cc.closed shouldBeEqual c.closed
}
}
@@ -32,7 +31,7 @@ object TestChamferCorners : Spek({
it("should be similar to a chamfered version") {
val cc = c.bevelCorners(10.0)
cc.segments.size `should be equal to` 1
cc.segments.size shouldBeEqual 1
cc.position(0.0) `should be near` c.position(0.0)
cc.position(0.5) `should be near` c.position(0.5)
cc.position(1.0) `should be near` c.position(1.0)
@@ -44,12 +43,12 @@ object TestChamferCorners : Spek({
it("should be similar to a chamfered version") {
val cc = c.bevelCorners(10.0)
cc.segments.size `should be equal to` c.segments.size
cc.segments.size shouldBeEqual c.segments.size
cc.position(0.0) `should be near` c.position(0.0)
cc.position(0.5) `should be near` c.position(0.5)
cc.position(1.0) `should be near` c.position(1.0)
cc.closed `should be equal to` c.closed
c.winding `should be equal to` cc.winding
cc.closed shouldBeEqual c.closed
c.winding shouldBeEqual cc.winding
}
}
@@ -61,10 +60,10 @@ object TestChamferCorners : Spek({
}
it("should chamfer correctly") {
val cc = c.bevelCorners(10.0)
cc.segments.size `should be equal to` 3
cc.segments.size shouldBeEqual 3
cc.position(0.0) `should be near` c.position(0.0)
cc.position(1.0) `should be near` c.position(1.0)
cc.closed `should be equal to` c.closed
cc.closed shouldBeEqual c.closed
}
}
@@ -76,10 +75,10 @@ object TestChamferCorners : Spek({
}
it("should be identical to the chamfered version") {
val cc = c.bevelCorners(10.0)
cc.segments.size `should be equal to` c.segments.size
cc.segments.size shouldBeEqual c.segments.size
cc.position(0.0) `should be near` c.position(0.0)
cc.position(1.0) `should be near` c.position(1.0)
cc.closed `should be equal to` c.closed
cc.closed shouldBeEqual c.closed
}
}
@@ -92,14 +91,14 @@ object TestChamferCorners : Spek({
}
it("should be identical to the chamfered version") {
val cc = c.bevelCorners(10.0)
cc.segments.size `should be equal to` c.segments.size
cc.segments.size shouldBeEqual c.segments.size
cc.position(0.0) `should be near` c.position(0.0)
cc.position(1.0) `should be near` c.position(1.0)
cc.closed `should be equal to` c.closed
cc.closed shouldBeEqual c.closed
}
}
describe("a two segment curve-linear contour") {
describe("another two segment curve-linear contour") {
val c = contour {
moveTo(0.0, 0.0)
curveTo(80.0, 120.0, 50.0, 50.0)
@@ -108,29 +107,29 @@ object TestChamferCorners : Spek({
}
it("should be identical to the chamfered version") {
val cc = c.bevelCorners(10.0)
cc.segments.size `should be equal to` c.segments.size
cc.segments.size shouldBeEqual c.segments.size
cc.position(0.0) `should be near` c.position(0.0)
cc.position(1.0) `should be near` c.position(1.0)
cc.closed `should be equal to` c.closed
cc.closed shouldBeEqual c.closed
}
}
describe("a triangle") {
val c = regularPolygon(3, radius = 100.0)
c.closed `should be equal to` true
c.closed shouldBeEqual true
val cc = c.roundCorners(1.0)
c.winding `should be equal to` cc.winding
c.winding shouldBeEqual cc.winding
c.closed `should be equal to` cc.closed
c.closed shouldBeEqual cc.closed
val ccc = cc.roundCorners(1.0)
ccc.closed `should be equal to` cc.closed
ccc.closed shouldBeEqual cc.closed
cc.segments.size `should be equal to` 6
cc.segments.size shouldBeEqual 6
// cc.segments.forEach {
// println(it)
@@ -141,7 +140,7 @@ object TestChamferCorners : Spek({
// println(it)
// }
it("should have 6 sides") {
ccc.segments.size `should be equal to` cc.segments.size
ccc.segments.size shouldBeEqual cc.segments.size
}
it("should start at the right position") {
ccc.position(0.0) `should be near` cc.position(0.0)

View File

@@ -1,23 +1,21 @@
import org.amshove.kluent.`should be equal to`
import io.kotest.core.spec.style.DescribeSpec
import io.kotest.matchers.booleans.shouldBeTrue
import io.kotest.matchers.equals.shouldBeEqual
import org.openrndr.extra.shapes.regularPolygon
import org.openrndr.extra.shapes.regularPolygonBeveled
import org.openrndr.extra.shapes.regularPolygonRounded
import org.openrndr.shape.Winding
import org.spekframework.spek2.Spek
import org.spekframework.spek2.style.specification.describe
object TestRegularPolygon : Spek({
class TestRegularPolygon : DescribeSpec({
describe("a regular polygon with 3 sides") {
val rp = regularPolygon(3)
it("is closed") {
rp.closed `should be equal to` true
rp.closed.shouldBeTrue()
}
it("has clockwise winding") {
rp.winding `should be equal to` Winding.CLOCKWISE
rp.winding.shouldBeEqual(Winding.CLOCKWISE)
}
}
@@ -25,11 +23,11 @@ object TestRegularPolygon : Spek({
val rp = regularPolygonRounded(3)
it("is closed") {
rp.closed `should be equal to` true
rp.closed.shouldBeTrue()
}
it("has clockwise winding") {
rp.winding `should be equal to` Winding.CLOCKWISE
rp.winding.shouldBeEqual(Winding.CLOCKWISE)
}
}
@@ -37,13 +35,11 @@ object TestRegularPolygon : Spek({
val rp = regularPolygonBeveled(3)
it("is closed") {
rp.closed `should be equal to` true
rp.closed.shouldBeTrue()
}
it("has clockwise winding") {
rp.winding `should be equal to` Winding.CLOCKWISE
rp.winding.shouldBeEqual(Winding.CLOCKWISE)
}
}
})

View File

@@ -1,22 +1,22 @@
import org.amshove.kluent.`should be equal to`
import io.kotest.core.spec.style.DescribeSpec
import io.kotest.matchers.booleans.shouldBeTrue
import io.kotest.matchers.equals.shouldBeEqual
import org.openrndr.extra.shapes.regularPolygonBeveled
import org.openrndr.extra.shapes.regularPolygonRounded
import org.openrndr.extra.shapes.regularStar
import org.openrndr.extra.shapes.regularStarRounded
import org.openrndr.shape.Winding
import org.spekframework.spek2.Spek
import org.spekframework.spek2.style.specification.describe
object TestRegularStar : Spek({
describe("a regular star with 5 points") {
class TestRegularStar : DescribeSpec({
describe("the regular star with 5 points") {
val rs = regularStar(5, 10.0, 20.0)
it("is closed") {
rs.closed `should be equal to` true
it("should be closed") {
rs.closed.shouldBeTrue()
}
it("has clockwise winding") {
rs.winding `should be equal to` Winding.CLOCKWISE
it("should have clockwise winding") {
rs.winding.shouldBeEqual(Winding.CLOCKWISE)
}
}
@@ -24,11 +24,11 @@ object TestRegularStar : Spek({
val rs = regularStarRounded(5, 10.0, 20.0, 0.2, 0.2)
it("is closed") {
rs.closed `should be equal to` true
rs.closed.shouldBeTrue()
}
it("has clockwise winding") {
rs.winding `should be equal to` Winding.CLOCKWISE
rs.winding.shouldBeEqual(Winding.CLOCKWISE)
}
}
@@ -36,12 +36,11 @@ object TestRegularStar : Spek({
val rs = regularPolygonBeveled(5, 0.5)
it("is closed") {
rs.closed `should be equal to` true
rs.closed.shouldBeTrue()
}
it("has clockwise winding") {
rs.winding `should be equal to` Winding.CLOCKWISE
rs.winding.shouldBeEqual(Winding.CLOCKWISE)
}
}
})

View File

@@ -1,20 +1,19 @@
import org.amshove.kluent.`should be equal to`
import io.kotest.core.spec.style.DescribeSpec
import io.kotest.matchers.booleans.shouldBeTrue
import io.kotest.matchers.equals.shouldBeEqual
import org.openrndr.extra.shapes.*
import org.openrndr.shape.Winding
import org.spekframework.spek2.Spek
import org.spekframework.spek2.style.specification.describe
object TestRoundedRectangle : Spek({
class TestRoundedRectangle : DescribeSpec({
describe("a rounded square") {
val rs = RoundedRectangle(100.0, 100.0, 200.0, 200.0, 20.0).contour
it("is closed") {
rs.closed `should be equal to` true
rs.closed.shouldBeTrue()
}
it("has clockwise winding") {
rs.winding `should be equal to` Winding.CLOCKWISE
rs.winding.shouldBeEqual(Winding.CLOCKWISE)
}
}
})

View File

@@ -6,7 +6,6 @@ kotlin {
jvm {
testRuns["test"].executionTask {
useJUnitPlatform {
includeEngines("spek2")
}
}
}