Skip to content

Error when document starts with example, before the test #57

@aSemy

Description

@aSemy

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

kotlinx-knit/src/Knit.kt

Lines 293 to 298 in bd8e272

CLEAR_DIRECTIVE -> {
requireSingleLine(directive)
require(directive.param.isEmpty()) { "$CLEAR_DIRECTIVE directive must not have parameters" }
codeLines.clear()
continue@mainLoop
}

Context

  • Gradle 8.3
  • Knit 0.4.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions