File tree Expand file tree Collapse file tree 5 files changed +11
-13
lines changed
main/kotlin/com/uzabase/playtest2/core
test/kotlin/com/uzabase/playtest2/core Expand file tree Collapse file tree 5 files changed +11
-13
lines changed Original file line number Diff line number Diff line change @@ -6,9 +6,6 @@ import com.thoughtworks.gauge.datastore.ScenarioDataStore
66import com.uzabase.playtest2.core.assertion.*
77import com.uzabase.playtest2.core.zoom.ToTable
88
9- internal fun oldtest (message : String , assertExp : () -> Boolean ) {
10- if (! assertExp()) throw PlaytestAssertionError (message)
11- }
129
1310class 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 }
Original file line number Diff line number Diff line change @@ -3,5 +3,5 @@ package com.uzabase.playtest2.core.assertion
33import com.thoughtworks.gauge.Table
44
55fun interface ShouldBeEqualTable {
6- fun shouldBeEqual (expected : Table ): Boolean
6+ fun shouldBeEqual (expected : Table ): TestResult
77}
Original file line number Diff line number Diff line change 11package com.uzabase.playtest2.core.zoom
22
33import com.thoughtworks.gauge.Table
4- import com.uzabase.playtest2.core.assertion.ShouldBeEqualTable
4+ import com.uzabase.playtest2.core.assertion.*
55
66fun interface ToTable {
77 fun toTable (): TableProxy
@@ -10,7 +10,7 @@ fun interface ToTable {
1010data 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
Original file line number Diff line number Diff 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" ))
Original file line number Diff line number Diff line change 11package com.uzabase.playtest2.core.zoom
22
33import com.thoughtworks.gauge.Table
4+ import com.uzabase.playtest2.core.assertion.Ok
45import io.kotest.core.spec.style.FunSpec
5- import io.kotest.matchers.booleans.shouldBeTrue
6+ import io.kotest.matchers.shouldBe
67
78class 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})
You can’t perform that action at this time.
0 commit comments