From 039bb97123fd8a74b9954598d7a102e235fd108d Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Wed, 30 Nov 2016 18:25:57 +0300 Subject: Fixed tests for sample formats --- .../test/kotlin/format/KotlinWebSiteFormatTest.kt | 4 --- .../KotlinWebSiteRunnableSamplesFormatTest.kt | 23 +++++++++++++ core/testdata/format/website-samples/sample.kt | 16 +++++++++ core/testdata/format/website-samples/sample.md | 38 ++++++++++++++++++++++ .../format/website-samples/sampleWithAsserts.kt | 15 +++++++++ .../format/website-samples/sampleWithAsserts.md | 23 +++++++++++++ core/testdata/format/website/sample.md | 9 ----- core/testdata/format/website/sampleWithAsserts.kt | 15 --------- core/testdata/format/website/sampleWithAsserts.md | 23 ------------- 9 files changed, 115 insertions(+), 51 deletions(-) create mode 100644 core/src/test/kotlin/format/KotlinWebSiteRunnableSamplesFormatTest.kt create mode 100644 core/testdata/format/website-samples/sample.kt create mode 100644 core/testdata/format/website-samples/sample.md create mode 100644 core/testdata/format/website-samples/sampleWithAsserts.kt create mode 100644 core/testdata/format/website-samples/sampleWithAsserts.md delete mode 100644 core/testdata/format/website/sampleWithAsserts.kt delete mode 100644 core/testdata/format/website/sampleWithAsserts.md diff --git a/core/src/test/kotlin/format/KotlinWebSiteFormatTest.kt b/core/src/test/kotlin/format/KotlinWebSiteFormatTest.kt index e7677862..3363b0a3 100644 --- a/core/src/test/kotlin/format/KotlinWebSiteFormatTest.kt +++ b/core/src/test/kotlin/format/KotlinWebSiteFormatTest.kt @@ -19,10 +19,6 @@ class KotlinWebSiteFormatTest { verifyKWSNodeByName("overloadGroup", "magic") } - @Test fun sampleWithAsserts() { - verifyKWSNodeByName("sampleWithAsserts", "a") - } - private fun verifyKWSNodeByName(fileName: String, name: String) { verifyOutput("testdata/format/website/$fileName.kt", ".md", format = "kotlin-website") { model, output -> kwsService.createOutputBuilder(output, tempLocation).appendNodes(model.members.single().members.filter { it.name == name }) diff --git a/core/src/test/kotlin/format/KotlinWebSiteRunnableSamplesFormatTest.kt b/core/src/test/kotlin/format/KotlinWebSiteRunnableSamplesFormatTest.kt new file mode 100644 index 00000000..1f514932 --- /dev/null +++ b/core/src/test/kotlin/format/KotlinWebSiteRunnableSamplesFormatTest.kt @@ -0,0 +1,23 @@ +package org.jetbrains.dokka.tests + +import org.jetbrains.dokka.KotlinLanguageService +import org.jetbrains.dokka.KotlinWebsiteRunnableSamplesFormatService +import org.junit.Test + +class KotlinWebSiteRunnableSamplesFormatTest { + private val kwsService = KotlinWebsiteRunnableSamplesFormatService(InMemoryLocationService, KotlinLanguageService()) + + @Test fun sample() { + verifyKWSNodeByName("sample", "foo") + } + + @Test fun sampleWithAsserts() { + verifyKWSNodeByName("sampleWithAsserts", "a") + } + + private fun verifyKWSNodeByName(fileName: String, name: String) { + verifyOutput("testdata/format/website-samples/$fileName.kt", ".md", format = "kotlin-website-samples") { model, output -> + kwsService.createOutputBuilder(output, tempLocation).appendNodes(model.members.single().members.filter { it.name == name }) + } + } +} diff --git a/core/testdata/format/website-samples/sample.kt b/core/testdata/format/website-samples/sample.kt new file mode 100644 index 00000000..a664c2f5 --- /dev/null +++ b/core/testdata/format/website-samples/sample.kt @@ -0,0 +1,16 @@ +/** + * Groups elements of the original sequence by the key returned by the given [keySelector] function + * applied to each element and returns a map where each group key is associated with a list of corresponding elements. + * @sample example1 + */ +fun foo(): Int { + return 0 +} + +fun foo(i: Int): Int { + return 1 +} + +fun example1(node: String) = if (true) { + println(property) +} diff --git a/core/testdata/format/website-samples/sample.md b/core/testdata/format/website-samples/sample.md new file mode 100644 index 00000000..203f1b02 --- /dev/null +++ b/core/testdata/format/website-samples/sample.md @@ -0,0 +1,38 @@ +--- +title: foo - test +layout: api +--- + +
test / foo
+ +# foo + +
+ +
fun foo(): Int
+ +Groups elements of the original sequence by the key returned by the given keySelector function +applied to each element and returns a map where each group key is associated with a list of corresponding elements. + +
+ +``` kotlin + +fun main(args: Array) { +//sampleStart +if (true) { + println(property) +} +//sampleEnd +} +``` + +
+ +
+ +
+ +
fun foo(i: Int): Int
+ +
diff --git a/core/testdata/format/website-samples/sampleWithAsserts.kt b/core/testdata/format/website-samples/sampleWithAsserts.kt new file mode 100644 index 00000000..bb9732d5 --- /dev/null +++ b/core/testdata/format/website-samples/sampleWithAsserts.kt @@ -0,0 +1,15 @@ +/** + * @sample sample + */ +fun a(): String { + return "Hello, Work" +} + +fun b(): String { + return "Hello, Rest" +} + +fun sample() { + assertPrints(a(), "Hello, Work") + assertTrue(a() == b()) +} \ No newline at end of file diff --git a/core/testdata/format/website-samples/sampleWithAsserts.md b/core/testdata/format/website-samples/sampleWithAsserts.md new file mode 100644 index 00000000..98d7df33 --- /dev/null +++ b/core/testdata/format/website-samples/sampleWithAsserts.md @@ -0,0 +1,23 @@ +--- +title: a - test +layout: api +--- + +
test / a
+ +# a + +
fun a(): String
+
+ +``` kotlin + +fun main(args: Array) { +//sampleStart +println(a()) // Hello, Work +println("a() == b() is ${a() == b()}") // true +//sampleEnd +} +``` + +
diff --git a/core/testdata/format/website/sample.md b/core/testdata/format/website/sample.md index 203f1b02..7c11790f 100644 --- a/core/testdata/format/website/sample.md +++ b/core/testdata/format/website/sample.md @@ -14,23 +14,14 @@ layout: api Groups elements of the original sequence by the key returned by the given keySelector function applied to each element and returns a map where each group key is associated with a list of corresponding elements. -
- ``` kotlin - -fun main(args: Array) { -//sampleStart if (true) { println(property) } -//sampleEnd -} ```
- -
fun foo(i: Int): Int
diff --git a/core/testdata/format/website/sampleWithAsserts.kt b/core/testdata/format/website/sampleWithAsserts.kt deleted file mode 100644 index bb9732d5..00000000 --- a/core/testdata/format/website/sampleWithAsserts.kt +++ /dev/null @@ -1,15 +0,0 @@ -/** - * @sample sample - */ -fun a(): String { - return "Hello, Work" -} - -fun b(): String { - return "Hello, Rest" -} - -fun sample() { - assertPrints(a(), "Hello, Work") - assertTrue(a() == b()) -} \ No newline at end of file diff --git a/core/testdata/format/website/sampleWithAsserts.md b/core/testdata/format/website/sampleWithAsserts.md deleted file mode 100644 index 98d7df33..00000000 --- a/core/testdata/format/website/sampleWithAsserts.md +++ /dev/null @@ -1,23 +0,0 @@ ---- -title: a - test -layout: api ---- - - - -# a - -
fun a(): String
-
- -``` kotlin - -fun main(args: Array) { -//sampleStart -println(a()) // Hello, Work -println("a() == b() is ${a() == b()}") // true -//sampleEnd -} -``` - -
-- cgit