Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add scala 2.11 to cross build #16

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name := "actuarius"

description := "Actuarius is a Markdown Processor written in Scala using parser combinators."

scalaVersion := "2.10.0"
scalaVersion := "2.11.0"

scalacOptions += "-deprecation"

Expand All @@ -19,13 +19,20 @@ resolvers += "Scala" at "https://oss.sonatype.org/content/groups/scala-tools/"

version := "0.2.7-SNAPSHOT"

crossScalaVersions in ThisBuild := Seq("2.9.2", "2.10.0")

libraryDependencies ++= {
Seq(
"org.scalatest" %% "scalatest" % "1.8" % "test" withSources(),
"junit" % "junit" % "4.8.2" % "test"
)
crossScalaVersions in ThisBuild := Seq("2.9.2", "2.10.0", "2.11.0")

libraryDependencies <++= (scalaVersion) { v:String =>
if (v.startsWith("2.11"))
Seq("org.scala-lang.modules" %% "scala-parser-combinators" % "1.0.1",
"org.scala-lang.modules" %% "scala-xml" % "1.0.2",
"org.scalatest" %% "scalatest" % "2.1.6" % "test" withSources(),
"junit" % "junit" % "4.8.2" % "test")
else if (v.startsWith("2.10"))
Seq("org.scalatest" %% "scalatest" % "2.1.6" % "test" withSources(),
"junit" % "junit" % "4.8.2" % "test")
else
Seq("org.scalatest" %% "scalatest" % "1.8" % "test" withSources(),
"junit" % "junit" % "4.8.2" % "test")
}

//TODO: reactivate once junit-XML listener is on maven central
Expand Down
26 changes: 14 additions & 12 deletions src/test/scala/eu/henkelmann/actuarius/LineTokenizerTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,25 @@ import org.scalatest.junit.JUnitRunner
* Tests the Line Tokenizer that prepares input for parsing.
*/
@RunWith(classOf[JUnitRunner])
class LineTokenizerTest extends LineTokenizer with FlatSpec with ShouldMatchers{
class LineTokenizerTest extends FlatSpec with ShouldMatchers{

val lineTokenizer = new LineTokenizer

"The LineTokenizer" should "split input lines correctly" in {
splitLines("line1\nline2\n") should equal (List("line1", "line2"))
splitLines("line1\nline2 no nl") should equal (List("line1", "line2 no nl"))
splitLines("test1\n\ntest2\n") should equal (List("test1", "", "test2"))
splitLines("test1\n\ntest2\n\n") should equal (List("test1", "", "test2"))
splitLines("\n\n") should equal (Nil)
splitLines("\n") should equal (Nil)
splitLines("") should equal (List(""))
lineTokenizer.splitLines("line1\nline2\n") should equal (List("line1", "line2"))
lineTokenizer.splitLines("line1\nline2 no nl") should equal (List("line1", "line2 no nl"))
lineTokenizer.splitLines("test1\n\ntest2\n") should equal (List("test1", "", "test2"))
lineTokenizer.splitLines("test1\n\ntest2\n\n") should equal (List("test1", "", "test2"))
lineTokenizer.splitLines("\n\n") should equal (Nil)
lineTokenizer.splitLines("\n") should equal (Nil)
lineTokenizer.splitLines("") should equal (List(""))
}

it should "preprocess the input correctly" in {
tokenize("[foo]: http://example.com/ \"Optional Title Here\"") should equal(
lineTokenizer.tokenize("[foo]: http://example.com/ \"Optional Title Here\"") should equal(
(new MarkdownLineReader(List(), Map( "foo"->new LinkDefinition("foo", "http://example.com/", Some("Optional Title Here")) )) ) )

tokenize(
lineTokenizer.tokenize(
"""[Baz]: http://foo.bar
'Title next line'
some text
Expand All @@ -49,8 +51,8 @@ new OtherLine("more text")

it should "parse different line types" in {
def p(line:String) = {
lineToken(new LineReader(Seq(line))) match {
case Success(result, _) => result
lineTokenizer.lineToken(new LineReader(Seq(line))) match {
case lineTokenizer.Success(result, _) => result
}
}
p("a line") should equal (new OtherLine("a line"))
Expand Down