kotlinx-knit icon indicating copy to clipboard operation
kotlinx-knit copied to clipboard

Error when document starts with example, before the test

Open aSemy opened this issue 1 year ago • 0 comments

I have a Markdown doc that contains an example before the Knit tests begin


Here's an example of a tuple definition in TypeScript:

```typescript
type StringNumberPair = [str: string, num: number];
```

<!--- CLEAR -->
<!--- TEST_NAME TuplesTest -->
<!--- INCLUDE .*\.kt
-->

```kotlin
fun main() {
  // ...
}
```

> You can get the full code [here](./code/example/example-tuple-01.kt).

```typescript
export type SimpleTypes = [
  aString: string,
  anInt: number,
  aDouble: number | null,
  bool: boolean,
  privateMember: string,
];
```

<!--- TEST -->

When I run ./gradlew knit I get an error:

Previous test was not emitted with TEST

Cause

I believe this is caused by the CLEAR directive clearing codeLines, but not testLines

https://github.com/Kotlin/kotlinx-knit/blob/bd8e2728f3a801a5eaa63f46779a2eb57dfb1ae7/src/Knit.kt#L293-L298

Context

  • Gradle 8.3
  • Knit 0.4.0

aSemy avatar Sep 17 '23 12:09 aSemy