mirror of
https://github.com/lightbend/config.git
synced 2025-01-25 19:50:09 +08:00
Merge pull request #258 from typesafehub/scalariform
Scalariform the tests, discovering a bug in the process
This commit is contained in:
commit
2028cff9f6
@ -1,6 +1,17 @@
|
||||
import de.johoop.findbugs4sbt.FindBugs._
|
||||
import de.johoop.findbugs4sbt.{ Effort, ReportType }
|
||||
import de.johoop.jacoco4sbt.JacocoPlugin.jacoco
|
||||
import com.typesafe.sbt.SbtScalariform
|
||||
import com.typesafe.sbt.SbtScalariform.ScalariformKeys
|
||||
import scalariform.formatter.preferences._
|
||||
|
||||
SbtScalariform.scalariformSettings
|
||||
|
||||
val formatPrefs = FormattingPreferences()
|
||||
.setPreference(IndentSpaces, 4)
|
||||
|
||||
ScalariformKeys.preferences in Compile := formatPrefs
|
||||
ScalariformKeys.preferences in Test := formatPrefs
|
||||
|
||||
fork in test := true
|
||||
fork in run := true
|
||||
|
@ -167,15 +167,7 @@ final class Path {
|
||||
if (length == 0)
|
||||
return false;
|
||||
|
||||
// if the path starts with something that could be a number,
|
||||
// we need to quote it because the number could be invalid,
|
||||
// for example it could be a hyphen with no digit afterward
|
||||
// or the exponent "e" notation could be mangled.
|
||||
char first = s.charAt(0);
|
||||
if (!(Character.isLetter(first)))
|
||||
return true;
|
||||
|
||||
for (int i = 1; i < length; ++i) {
|
||||
for (int i = 0; i < length; ++i) {
|
||||
char c = s.charAt(i);
|
||||
|
||||
if (Character.isLetterOrDigit(c) || c == '-' || c == '_')
|
||||
|
@ -56,9 +56,9 @@ class PathTest extends TestUtils {
|
||||
RenderTest("foo-bar", path("foo-bar")),
|
||||
RenderTest("foo_bar", path("foo_bar")),
|
||||
// starts with hyphen
|
||||
RenderTest("\"-foo\"", path("-foo")),
|
||||
RenderTest("-foo", path("-foo")),
|
||||
// starts with number
|
||||
RenderTest("\"10foo\"", path("10foo")),
|
||||
RenderTest("10foo", path("10foo")),
|
||||
// empty elements
|
||||
RenderTest("\"\".\"\"", path("", "")),
|
||||
// internal space
|
||||
@ -66,10 +66,10 @@ class PathTest extends TestUtils {
|
||||
// leading and trailing spaces
|
||||
RenderTest("\" foo \"", path(" foo ")),
|
||||
// trailing space only
|
||||
RenderTest("\"foo \"", path("foo ")))
|
||||
RenderTest("\"foo \"", path("foo ")),
|
||||
// numbers with decimal points
|
||||
RenderTest("1.2", path("1", "2"))
|
||||
RenderTest("1.2.3.4", path("1", "2", "3", "4"))
|
||||
RenderTest("1.2", path("1", "2")),
|
||||
RenderTest("1.2.3.4", path("1", "2", "3", "4")))
|
||||
|
||||
for (t <- tests) {
|
||||
assertEquals(t.expected, t.path.render())
|
||||
|
@ -2,6 +2,7 @@ addSbtPlugin("de.johoop" % "findbugs4sbt" % "1.2.1")
|
||||
addSbtPlugin("de.johoop" % "jacoco4sbt" % "2.1.1")
|
||||
addSbtPlugin("com.typesafe.sbt" % "sbt-pgp" % "0.8.1")
|
||||
addSbtPlugin("com.typesafe.sbt" % "sbt-osgi" % "0.6.0")
|
||||
addSbtPlugin("com.typesafe.sbt" % "sbt-scalariform" % "1.2.1")
|
||||
|
||||
resolvers += "jgit-repo" at "http://download.eclipse.org/jgit/maven"
|
||||
addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "0.6.2")
|
||||
|
Loading…
Reference in New Issue
Block a user