Skip to content

Commit

Permalink
Fix test failures on 2.12/2.11
Browse files Browse the repository at this point in the history
  • Loading branch information
Olafur Pall Geirsson committed Oct 30, 2019
1 parent 6071d2b commit ec09ef4
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 105 deletions.
2 changes: 0 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,6 @@ lazy val unit = project
skip in publish := true,
addCompilerPlugin("org.typelevel" %% "kind-projector" % "0.10.3"),
resolvers += Resolver.bintrayRepo("cibotech", "public"),
libraryDependencies += "com.lihaoyi" %% "utest" % "0.7.1" % Test,
testFrameworks += new TestFramework("utest.runner.Framework"),
scala212LibraryDependencies(
List(
"com.cibo" %% "evilplot" % "0.6.0"
Expand Down
3 changes: 0 additions & 3 deletions mdoc-sbt/src/sbt-test/sbt-mdoc/basic/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,8 @@ println(example.Example.greeting)
```scala
println("Hello Scala.js!")
```
<div id="mdoc-js-run0" data-mdoc-js></div>
<script type="text/javascript" src="readme.md.js" defer></script>
<script type="text/javascript" src="mdoc.js" defer></script>
""".trim,
"\"\"\"\n" + obtained + "\n\"\"\""
Expand Down
190 changes: 90 additions & 100 deletions tests/unit/src/test/scala/tests/markdown/MarkdownFileSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,113 +8,103 @@ import mdoc.internal.io.ConsoleReporter
import mdoc.internal.markdown.Text
import mdoc.internal.markdown.MarkdownPart
import mdoc.internal.markdown.CodeFence
import utest._
import scala.meta.io.RelativePath

object Assertions extends DiffAssertions

object MarkdownFileSuite extends TestSuite {
import Assertions._
class MarkdownFileSuite extends FunSuite with DiffAssertions {
val reporter = new ConsoleReporter(System.out)

def check(original: String, expected: MarkdownPart*)(
implicit path: utest.framework.TestPath
): Unit = {
reporter.reset()
val input = Input.VirtualFile(path.value.mkString("."), original)
val relpath = RelativePath(input.path)
val obtained = MarkdownFile.parse(input, relpath, reporter).parts
require(!reporter.hasErrors)
val expectedParts = expected.toList
assertNoDiff(
pprint.tokenize(obtained).mkString,
pprint.tokenize(expectedParts).mkString
)
}
val tests = Tests {

test("basic") {
check(
"""# Hello
|World
|```scala mdoc
|println(42)
|```
|End.
|""".stripMargin,
Text("# Hello\n"),
Text("World\n"),
CodeFence(
Text("```"),
Text("scala mdoc\n"),
Text("println(42)"),
Text("\n```\n")
),
Text("End.\n")
def check(name: String, original: String, expected: MarkdownPart*): Unit = {
test(name) {
reporter.reset()
val input = Input.VirtualFile(name, original)
val relpath = RelativePath(input.path)
val obtained = MarkdownFile.parse(input, relpath, reporter).parts
require(!reporter.hasErrors)
val expectedParts = expected.toList
assertNoDiff(
pprint.tokenize(obtained).mkString,
pprint.tokenize(expectedParts).mkString
)
}
}

test("four-backtick") {
check(
"""# Hello
|World
|````scala mdoc
|```
|println(42)
|```
|````
|End.
|""".stripMargin,
Text("# Hello\n"),
Text("World\n"),
CodeFence(
Text("````"),
Text("scala mdoc\n"),
Text("```\nprintln(42)\n```"),
Text("\n````\n")
),
Text("End.\n")
)
}
check(
"basic",
"""# Hello
|World
|```scala mdoc
|println(42)
|```
|End.
|""".stripMargin,
Text("# Hello\n"),
Text("World\n"),
CodeFence(
Text("```"),
Text("scala mdoc\n"),
Text("println(42)"),
Text("\n```\n")
),
Text("End.\n")
)

test("two-backtick") {
check(
"""# Hello
|World
|``scala mdoc
|println(42)
|``
|End.
|""".stripMargin,
Text("# Hello\n"),
Text("World\n"),
Text("``scala mdoc\n"),
Text("println(42)\n"),
Text("``\n"),
Text("End.\n")
)
}
check(
"four-backtick",
"""# Hello
|World
|````scala mdoc
|```
|println(42)
|```
|````
|End.
|""".stripMargin,
Text("# Hello\n"),
Text("World\n"),
CodeFence(
Text("````"),
Text("scala mdoc\n"),
Text("```\nprintln(42)\n```"),
Text("\n````\n")
),
Text("End.\n")
)

test("backtick-mismatch") {
check(
"""|````scala mdoc
|`````
|````
|42
|""".stripMargin,
CodeFence(
Text("````"),
Text("scala mdoc\n"),
Text(""),
Text("\n`````\n")
),
CodeFence(
Text("````"),
Text("\n"),
Text("42"),
Text("\n")
)
)
}
}
check(
"two-backtick",
"""# Hello
|World
|``scala mdoc
|println(42)
|``
|End.
|""".stripMargin,
Text("# Hello\n"),
Text("World\n"),
Text("``scala mdoc\n"),
Text("println(42)\n"),
Text("``\n"),
Text("End.\n")
)

check(
"backtick-mismatch",
"""|````scala mdoc
|`````
|````
|42
|""".stripMargin,
CodeFence(
Text("````"),
Text("scala mdoc\n"),
Text(""),
Text("\n`````\n")
),
CodeFence(
Text("````"),
Text("\n"),
Text("42"),
Text("\n")
)
)
}

0 comments on commit ec09ef4

Please sign in to comment.