Skip to content

Commit 101a70e

Browse files
committed
Remove oldtest function
1 parent 5b19049 commit 101a70e

File tree

5 files changed

+11
-13
lines changed

5 files changed

+11
-13
lines changed

playtest-core/src/main/kotlin/com/uzabase/playtest2/core/AssertionSteps.kt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ import com.thoughtworks.gauge.datastore.ScenarioDataStore
66
import com.uzabase.playtest2.core.assertion.*
77
import com.uzabase.playtest2.core.zoom.ToTable
88

9-
internal fun oldtest(message: String, assertExp: () -> Boolean) {
10-
if (!assertExp()) throw PlaytestAssertionError(message)
11-
}
129

1310
class AssertionSteps {
1411
@Step("小数値の<value>である")
@@ -112,7 +109,7 @@ class AssertionSteps {
112109
is ShouldBeEqualTable -> target
113110
else -> throw PlaytestAssertionError("AssertionTarget is not assertable type: ${target.javaClass}")
114111
}
115-
oldtest("should be equal to $table") {
112+
test {
116113
sut.shouldBeEqual(table)
117114
}
118115
}

playtest-core/src/main/kotlin/com/uzabase/playtest2/core/assertion/ForTable.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ package com.uzabase.playtest2.core.assertion
33
import com.thoughtworks.gauge.Table
44

55
fun interface ShouldBeEqualTable {
6-
fun shouldBeEqual(expected: Table): Boolean
6+
fun shouldBeEqual(expected: Table): TestResult
77
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.uzabase.playtest2.core.zoom
22

33
import com.thoughtworks.gauge.Table
4-
import com.uzabase.playtest2.core.assertion.ShouldBeEqualTable
4+
import com.uzabase.playtest2.core.assertion.*
55

66
fun interface ToTable {
77
fun toTable(): TableProxy
@@ -10,7 +10,7 @@ fun interface ToTable {
1010
data class TableProxy(
1111
val table: Table
1212
): ShouldBeEqualTable {
13-
override fun shouldBeEqual(expected: Table): Boolean {
13+
override fun shouldBeEqual(expected: Table): TestResult {
1414
val failed = mutableListOf<Triple<Int, String, String>>()
1515
expected.tableRows.forEachIndexed { index, expectedRow ->
1616
val actualRow = table.tableRows[index]
@@ -20,7 +20,7 @@ data class TableProxy(
2020
}
2121
}
2222
}
23-
return failed.isEmpty()
23+
return if (failed.isEmpty()) Ok else Failed { "Table comparison failed: $failed" }
2424
}
2525
}
2626

playtest-core/src/test/kotlin/com/uzabase/playtest2/core/AssertionStepsTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,13 +181,13 @@ class AssertionStepsTest : FunSpec({
181181
182182
context("table") {
183183
test("should be equal") {
184-
ScenarioDataStore.put(K.AssertionTarget, ShouldBeEqualTable { true })
184+
ScenarioDataStore.put(K.AssertionTarget, ShouldBeEqualTable { Ok })
185185
sut.shouldBeEqualTable(
186186
Table(listOf("ans")).apply { addRow(listOf("42")) })
187187
}
188188
189189
test("should be fail") {
190-
ScenarioDataStore.put(K.AssertionTarget, ShouldBeEqualTable { false })
190+
ScenarioDataStore.put(K.AssertionTarget, ShouldBeEqualTable { Failed { "should be equal to $it" } })
191191
shouldThrow<PlaytestAssertionError> {
192192
sut.shouldBeEqualTable(
193193
Table(listOf("ans"))

playtest-core/src/test/kotlin/com/uzabase/playtest2/core/zoom/TableTest.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package com.uzabase.playtest2.core.zoom
22

33
import com.thoughtworks.gauge.Table
4+
import com.uzabase.playtest2.core.assertion.Ok
45
import io.kotest.core.spec.style.FunSpec
5-
import io.kotest.matchers.booleans.shouldBeTrue
6+
import io.kotest.matchers.shouldBe
67

78
class TableTest : FunSpec({
89
test("should true when two tables are equal") {
@@ -14,7 +15,7 @@ class TableTest : FunSpec({
1415
addRow(listOf("1", "x", "a"))
1516
addRow(listOf("2", "y", "b"))
1617
addRow(listOf("3", "z", "c"))
17-
}).shouldBeTrue()
18+
}).shouldBe(Ok)
1819
}
1920

2021
test("should true when two tables are logically equal") {
@@ -26,6 +27,6 @@ class TableTest : FunSpec({
2627
addRow(listOf("1", "a", "x"))
2728
addRow(listOf("2", "b", "y"))
2829
addRow(listOf("3", "c", "z"))
29-
}).shouldBeTrue()
30+
}).shouldBe(Ok)
3031
}
3132
})

0 commit comments

Comments
 (0)