Skip to content

Commit 4173451

Browse files
committed
fix CLEAR directive clearing test lines, with test
1 parent e72f453 commit 4173451

File tree

7 files changed

+69
-1
lines changed

7 files changed

+69
-1
lines changed

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ allprojects {
3636
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.11.1")
3737
testImplementation(kotlin("test-junit"))
3838
}
39-
39+
4040
tasks.withType<KotlinCompile> {
4141
kotlinOptions.apply {
4242
languageVersion = "1.4"

src/Knit.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ fun KnitContext.knit(inputFile: File): Boolean {
294294
requireSingleLine(directive)
295295
require(directive.param.isEmpty()) { "$CLEAR_DIRECTIVE directive must not have parameters" }
296296
codeLines.clear()
297+
testLines.clear()
297298
continue@mainLoop
298299
}
299300
KNIT_DIRECTIVE -> {

test/TestDataTest.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,17 @@ class TestDataTest {
247247
)
248248
}
249249

250+
// !!! AUTOMATICALLY GENERATED BY TestDataGen. DO NOT EDIT !!!
251+
@Test
252+
fun testTestClear() {
253+
verifyTestData(
254+
"TestClear",
255+
"testdata/test-clear.in.md",
256+
"testdata/test-clear.in.md",
257+
"testdata/test-clear.properties"
258+
)
259+
}
260+
250261
// !!! AUTOMATICALLY GENERATED BY TestDataGen. DO NOT EDIT !!!
251262
@Test
252263
fun testTestHidden() {

testdata/test-clear.in.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
```kotlin
3+
fun main() {
4+
// this code should be cleared
5+
}
6+
```
7+
8+
```text
9+
this text should be cleared
10+
```
11+
12+
<!--- CLEAR -->
13+
<!--- TEST_NAME ClearTest -->
14+
15+
Here is some explanatory text
16+
17+
```kotlin
18+
fun main() {
19+
println("Hello, world!")
20+
}
21+
```
22+
23+
> You can get the full code [here](test-clear/example-clear-01.kt).
24+
25+
This code prints:
26+
27+
```text
28+
Hello, world!
29+
```
30+
31+
<!--- TEST -->

testdata/test-clear.properties

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
knit.dir=test-clear/
2+
knit.package=com.example
3+
4+
test.dir=test-clear/test/
5+
test.package=com.example.test
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// This file was automatically generated from test-basic.in.md by Knit tool. Do not edit.
2+
package com.example.exampleBasic01
3+
4+
fun main() {
5+
println("Hello, world!")
6+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// This file was automatically generated from test-basic.in.md by Knit tool. Do not edit.
2+
package com.example.test
3+
4+
import org.junit.Test
5+
import kotlinx.knit.test.*
6+
7+
class ClearTest {
8+
@Test
9+
fun testExampleBasic01() {
10+
captureOutput("ExampleClear01") { com.example.exampleClear01.main() }.verifyOutputLines(
11+
"Hello, world!"
12+
)
13+
}
14+
}

0 commit comments

Comments
 (0)