aboutsummaryrefslogtreecommitdiff
path: root/test/src
diff options
context:
space:
mode:
authorDmitry Jemerov <yole@jetbrains.com>2015-09-09 15:39:42 +0200
committerDmitry Jemerov <yole@jetbrains.com>2015-09-09 15:39:42 +0200
commit41e36c030dd481b43ef9596df030677016eab2db (patch)
treeabc0d9dd753d844e7aac32d3f5edda9c78124d54 /test/src
parentac91c6f29205029b751cec527c5691697093457d (diff)
downloaddokka-41e36c030dd481b43ef9596df030677016eab2db.tar.gz
dokka-41e36c030dd481b43ef9596df030677016eab2db.tar.bz2
dokka-41e36c030dd481b43ef9596df030677016eab2db.zip
delete some incomplete and irrelevant Markdown parsing test code
Diffstat (limited to 'test/src')
-rw-r--r--test/src/markdown/MarkdownTestRunner.kt133
-rw-r--r--test/src/markdown/Specification.kt11
2 files changed, 0 insertions, 144 deletions
diff --git a/test/src/markdown/MarkdownTestRunner.kt b/test/src/markdown/MarkdownTestRunner.kt
deleted file mode 100644
index 867deece..00000000
--- a/test/src/markdown/MarkdownTestRunner.kt
+++ /dev/null
@@ -1,133 +0,0 @@
-package org.jetbrains.kmark.test
-
-import org.junit.runner.*
-import org.junit.runner.notification.*
-import java.io.File
-import org.junit.runners.ParentRunner
-import java.io.Serializable
-import kotlin.properties.Delegates
-import org.junit.ComparisonFailure
-
-data class MarkdownTestUniqueId(val id: Int) : Serializable {
- companion object {
- var id = 0
- fun next() = MarkdownTestUniqueId(id++)
- }
-}
-
-public open class MarkdownSpecification(val path: String, val processor: (String) -> String)
-
-
-interface MarkdownTest {
- fun description(): Description
-}
-
-public open class MarkdownTestCase(val spec: MarkdownSpecification, val input: String, val expected: String) : MarkdownTest, Runner() {
- val _description by Delegates.lazy {
- Description.createSuiteDescription(input, MarkdownTestUniqueId.next())!!
- }
-
- override fun description(): Description = _description
-
- override fun getDescription(): Description? = description()
- override fun run(notifier: RunNotifier?) {
- notifier!!
-
- notifier.fireTestStarted(_description)
- val result = spec.processor(input)
- when (result) {
- expected -> notifier.fireTestFinished(_description)
- else -> notifier.fireTestFailure(Failure(_description, ComparisonFailure("Output mismatch", expected, result)))
- }
- }
-}
-
-public open class MarkdownTestSection(val spec: MarkdownSpecification, val title: String) : MarkdownTest, ParentRunner<MarkdownTest>(spec.javaClass) {
- val children = arrayListOf<MarkdownTest>();
-
- val _description by Delegates.lazy {
- val desc = Description.createSuiteDescription(title, MarkdownTestUniqueId.next())!!
- for (item in getChildren()!!) {
- desc.addChild(describeChild(item))
- }
- desc
- }
-
- override fun description(): Description = _description
-
- override fun getChildren(): MutableList<MarkdownTest>? = children
-
- override fun describeChild(child: MarkdownTest?): Description? = child!!.description()
-
- override fun runChild(child: MarkdownTest?, notifier: RunNotifier?) {
- notifier!!
- when (child) {
- is MarkdownTestCase -> child.run(notifier)
- is MarkdownTestSection -> {
- if (child.children.size() == 0) {
- notifier.fireTestStarted(child.description())
- notifier.fireTestFinished(child.description())
- } else {
- child.run(notifier)
- }
- }
- }
- }
-}
-
-public class MarkdownTestRunner(specificationClass: Class<MarkdownSpecification>) : MarkdownTestSection(specificationClass.newInstance(), "Tests") {
- init {
- val lines = File(spec.path).readLines()
- createSections(this, lines, 1)
- }
-
- private fun createTests(parent: MarkdownTestSection, lines: List<String>): Int {
- val testMark = lines.takeWhile { it.trim() != "." }
- val testHtml = lines.drop(testMark.size()).drop(1).takeWhile { it.trim() != "." }
- val markdown = testMark.join("\n", postfix = "\n", prefix = "\n")
- val html = testHtml.join("\n", postfix = "\n")
- val markdownTestCase = MarkdownTestCase(spec, markdown, html)
- parent.children.add(markdownTestCase)
- return testMark.size() + testHtml.size() + 3
- }
-
- private fun createSections(parent: MarkdownTestSection, lines: List<String>, level: Int): Int {
- var sectionNumber = 1
- var index = 0
- while (index < lines.size()) {
- val line = lines[index]
-
- if (line.trim() == ".") {
- index = createTests(parent, lines.subList(index + 1, lines.lastIndex)) + index + 1
- continue
- }
-
- val head = line.takeWhile { it == '#' }.length()
- if (head == 0) {
- index++
- continue
- }
-
- if (head < level) {
- return index
- }
-
- if (head == level) {
- val title = lines[index].dropWhile { it == '#' }.dropWhile { it.isWhitespace() }
- sectionNumber++
- val section = MarkdownTestSection(spec, title)
- val lastIndex = createSections(section, lines.subList(index + 1, lines.lastIndex), level + 1) + index + 1
- if (section.children.size() > 0)
- parent.children.add(section)
- val nextHead = lines[lastIndex].takeWhile { it == '#' }.length()
- if (nextHead < level) {
- return lastIndex
- }
- index = lastIndex
- continue
- }
- index++
- }
- return lines.size()
- }
-} \ No newline at end of file
diff --git a/test/src/markdown/Specification.kt b/test/src/markdown/Specification.kt
deleted file mode 100644
index 429317c2..00000000
--- a/test/src/markdown/Specification.kt
+++ /dev/null
@@ -1,11 +0,0 @@
-package org.jetbrains.kmark.test
-
-import org.junit.runner.*
-import org.jetbrains.kmark.test.*
-import org.jetbrains.dokka.*
-
-//[RunWith(javaClass<MarkdownTestRunner>())]
-class Specification : MarkdownSpecification("test/data/markdown/spec.txt", {
-// markdownToHtml(it.replace("→", "\t"))
- ""
-}) \ No newline at end of file