Skip to content

Commit 409a125

Browse files
committed
Merge pull request scala-ide#6 from pvlugter/format-spec
Add format tests from play
2 parents a052762 + 3d5d667 commit 409a125

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed
+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright (C) 2009-2014 Typesafe Inc. <http://www.typesafe.com>
3+
*/
4+
package play.twirl.api
5+
package test
6+
7+
import org.specs2.mutable._
8+
9+
object FormatSpec extends Specification {
10+
"HtmlFormat" should {
11+
"escape '<', '&' and '>'" in {
12+
HtmlFormat.escape("foo < bar & baz >").body must_== "foo &lt; bar &amp; baz &gt;"
13+
}
14+
15+
"escape single quotes" in {
16+
HtmlFormat.escape("'single quotes'").body must_== "&#x27;single quotes&#x27;"
17+
}
18+
19+
"escape double quotes" in {
20+
HtmlFormat.escape("\"double quotes\"").body must_== "&quot;double quotes&quot;"
21+
}
22+
23+
"not escape non-ASCII characters" in {
24+
HtmlFormat.escape("こんにちは").body must_== "こんにちは"
25+
}
26+
}
27+
28+
"JavaScriptFormat" should {
29+
"""escape ''', '"' and '\'""" in {
30+
JavaScriptFormat.escape("""foo ' bar " baz \""").body must equalTo ("""foo \' bar \" baz \\""")
31+
}
32+
}
33+
34+
}

Diff for: build.sbt

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ lazy val api = project
1111
.settings(crossScala: _*)
1212
.settings(
1313
name := "twirl-api",
14-
libraryDependencies += commonsLang
14+
libraryDependencies += commonsLang,
15+
libraryDependencies += specs2(scalaBinaryVersion.value)
1516
)
1617

1718
lazy val parser = project

0 commit comments

Comments
 (0)