Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions conformance/bundles/01-roman-numerals/numerals.steps.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
@file:JvmName("NumeralsSteps")

// Kotlin sibling of numerals.steps.ts / numerals.steps.py / NumeralsSteps.java
// (bundle 01-roman-numerals). Unlike the Java fixture, the file keeps the
// shared cross-language stem naming (numerals.steps.kt -> "numerals.steps" by
// plain extension-stripping) — Kotlin has no file-name/class-name coupling, so
// no PascalCase workaround is needed; @file:JvmName pins the facade class the
// harness loads instead.
package com.oselvar.varkt.conformance.bundle01

import com.oselvar.varkt.action
import com.oselvar.varkt.defineState
import com.oselvar.varkt.sensor

data class Ctx(val result: String? = null)

private val ROMAN = mapOf(1 to "I", 4 to "IV", 9 to "IX", 40 to "XL")

val steps = defineState(::Ctx) {
action("I convert {int} to roman numerals") { n: Int ->
copy(result = ROMAN[n])
}
sensor("The result is {word}") { expected: String ->
// {word} greedily captures trailing punctuation ("I."), mirroring the
// TS/Java fixtures: strip it, assert directly, and return null to opt
// out of the compare-against-last-captured-param convenience (which
// would wrongly compare the raw punctuated capture).
val cleaned = expected.replace(Regex("[.!?]$"), "")
if (cleaned != result) throw AssertionError("expected $cleaned but got $result")
null
}
}
16 changes: 16 additions & 0 deletions conformance/bundles/02-context-isolation/counter.steps.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@file:JvmName("CounterSteps")

// Kotlin sibling of counter.steps.ts / counter.steps.py / CounterSteps.java
// (bundle 02-context-isolation).
package com.oselvar.varkt.conformance.bundle02

import com.oselvar.varkt.action
import com.oselvar.varkt.defineState
import com.oselvar.varkt.sensor

data class Ctx(val count: Int = 0)

val steps = defineState(::Ctx) {
action("I increment") { copy(count = count + 1) }
sensor("The count is {int}") { n: Int -> count }
}
17 changes: 17 additions & 0 deletions conformance/bundles/03-expected-failure/division.steps.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@file:JvmName("DivisionSteps")

// Kotlin sibling of division.steps.ts / division.steps.py / DivisionSteps.java
// (bundle 03-expected-failure).
package com.oselvar.varkt.conformance.bundle03

import com.oselvar.varkt.action
import com.oselvar.varkt.defineState

class Ctx

val steps = defineState(::Ctx) {
action("I divide {int} by {int}") { a: Int, b: Int ->
if (b == 0) throw ArithmeticException("division by zero")
this
}
}
16 changes: 16 additions & 0 deletions conformance/bundles/04-tables-and-docstrings/echo.steps.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@file:JvmName("EchoSteps")

// Kotlin sibling of echo.steps.ts / echo.steps.py / EchoSteps.java (bundle
// 04-tables-and-docstrings): the doc string arrives as the trailing handler
// argument after the expression's own captures (here: none) and is echoed back
// for the core's doc-string comparison.
package com.oselvar.varkt.conformance.bundle04

import com.oselvar.varkt.defineState
import com.oselvar.varkt.sensor

class Ctx

val steps = defineState(::Ctx) {
sensor("I echo the following:") { doc: String -> doc }
}
16 changes: 16 additions & 0 deletions conformance/bundles/05-ambiguous-match/cukes.steps.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@file:JvmName("CukesSteps")

// Kotlin sibling of cukes.steps.ts / cukes.steps.py / CukesSteps.java (bundle
// 05-ambiguous-match): both expressions match "I have 5 cukes" -> ambiguous-
// match diagnostic at the plan stage; this stage only needs both registered.
package com.oselvar.varkt.conformance.bundle05

import com.oselvar.varkt.action
import com.oselvar.varkt.defineState

class Ctx

val steps = defineState(::Ctx) {
action("I have {int} cukes") { n: Int -> this }
action("I have 5 cukes") { this }
}
15 changes: 15 additions & 0 deletions conformance/bundles/06-doc-string-mismatch/echo.steps.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@file:JvmName("EchoSteps")

// Kotlin sibling of echo.steps.ts / echo.steps.py / EchoSteps.java (bundle
// 06-doc-string-mismatch): deliberately returns the WRONG string so the core's
// doc-string comparison fails at the trace stage.
package com.oselvar.varkt.conformance.bundle06

import com.oselvar.varkt.defineState
import com.oselvar.varkt.sensor

class Ctx

val steps = defineState(::Ctx) {
sensor("I echo the following:") { doc: String -> "goodbye" }
}
18 changes: 18 additions & 0 deletions conformance/bundles/07-row-check-mismatch/report.steps.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
@file:JvmName("ReportSteps")

// Kotlin sibling of report.steps.ts / report.steps.py / ReportSteps.java
// (bundle 07-row-check-mismatch): header-bound row step — receives the current
// row (Map keyed by header cell) as the trailing argument and returns hardcoded
// (wrong) columns, producing a cell mismatch at the trace stage.
package com.oselvar.varkt.conformance.bundle07

import com.oselvar.varkt.defineState
import com.oselvar.varkt.sensor

class Ctx

val steps = defineState(::Ctx) {
sensor("I report the score and grade") { row: Map<String, String> ->
mapOf("score" to "99", "grade" to "A")
}
}
14 changes: 14 additions & 0 deletions conformance/bundles/08-string-capture/greet.steps.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@file:JvmName("GreetSteps")

// Kotlin sibling of greet.steps.ts / greet.steps.py / GreetSteps.java (bundle
// 08-string-capture).
package com.oselvar.varkt.conformance.bundle08

import com.oselvar.varkt.action
import com.oselvar.varkt.defineState

class Ctx

val steps = defineState(::Ctx) {
action("I greet {string}") { name: String -> this }
}
17 changes: 17 additions & 0 deletions conformance/bundles/09-expected-message-mismatch/boom.steps.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@file:JvmName("BoomSteps")

// Kotlin sibling of boom.steps.ts / boom.steps.py / BoomSteps.java (bundle
// 09-expected-message-mismatch): throws a message NOT containing the expected
// substring, so the error fence is not satisfied at the trace stage.
package com.oselvar.varkt.conformance.bundle09

import com.oselvar.varkt.action
import com.oselvar.varkt.defineState

class Ctx

val steps = defineState(::Ctx) {
action("I always boom") {
throw RuntimeException("actual different error")
}
}
16 changes: 16 additions & 0 deletions conformance/bundles/10-error-fence-without-step/cukes.steps.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@file:JvmName("CukesSteps")

// Kotlin sibling of cukes.steps.ts / cukes.steps.py / CukesSteps.java (bundle
// 10-error-fence-without-step): the example's prose matches no step, so the
// error fence has nothing to run — a plan-stage diagnostic; this stage only
// needs the one step registered.
package com.oselvar.varkt.conformance.bundle10

import com.oselvar.varkt.action
import com.oselvar.varkt.defineState

class Ctx

val steps = defineState(::Ctx) {
action("I have {int} cukes") { n: Int -> this }
}
16 changes: 16 additions & 0 deletions conformance/bundles/11-emoji-offsets/greet.steps.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@file:JvmName("GreetSteps")

// Kotlin sibling of greet.steps.ts / greet.steps.py / GreetSteps.java (bundle
// 11-emoji-offsets): the example's non-header-bound trailing table arrives as
// the trailing argument after the {string} capture; the null return skips
// every comparison (mirrors TS's `() => undefined`).
package com.oselvar.varkt.conformance.bundle11

import com.oselvar.varkt.defineState
import com.oselvar.varkt.sensor

class Ctx

val steps = defineState(::Ctx) {
sensor("I greet {string}") { name: String, table: List<List<String>> -> null }
}
14 changes: 14 additions & 0 deletions conformance/bundles/12-combining-marks/greet.steps.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@file:JvmName("GreetSteps")

// Kotlin sibling of greet.steps.ts / greet.steps.py / GreetSteps.java (bundle
// 12-combining-marks).
package com.oselvar.varkt.conformance.bundle12

import com.oselvar.varkt.defineState
import com.oselvar.varkt.sensor

class Ctx

val steps = defineState(::Ctx) {
sensor("I greet {string}") { name: String -> null }
}
Loading
Loading