mirror of
https://github.com/lightbend/config.git
synced 2025-01-15 23:01:05 +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 == '_')
|
||||
|
@ -265,11 +265,11 @@ class ConfigValueTest extends TestUtils {
|
||||
@Test
|
||||
def configConfigSerializable() {
|
||||
val expectedSerialization = "" +
|
||||
"ACED0005_s_r00_._c_o_m_._t_y_p_e_s_a_f_e_._c_o_n_f_i_g_._i_m_p_l_._S_e_r_i_a_l_i" +
|
||||
"_z_e_d_C_o_n_f_i_g_V_a_l_u_e00000000000000010C0000_x_p_w_z02000000_n050000001906" +
|
||||
"0000000D000B_f_a_k_e_ _o_r_i_g_i_n0900000001000104000000_J07000000030001_a050000" +
|
||||
"000101040000000802000000010001_1010001_b050000000101040000000802000000020001_201" +
|
||||
"0001_c050000000101040000000802000000030001_3010103000000010101_x"
|
||||
"ACED0005_s_r00_._c_o_m_._t_y_p_e_s_a_f_e_._c_o_n_f_i_g_._i_m_p_l_._S_e_r_i_a_l_i" +
|
||||
"_z_e_d_C_o_n_f_i_g_V_a_l_u_e00000000000000010C0000_x_p_w_z02000000_n050000001906" +
|
||||
"0000000D000B_f_a_k_e_ _o_r_i_g_i_n0900000001000104000000_J07000000030001_a050000" +
|
||||
"000101040000000802000000010001_1010001_b050000000101040000000802000000020001_201" +
|
||||
"0001_c050000000101040000000802000000030001_3010103000000010101_x"
|
||||
|
||||
val aMap = configMap("a" -> 1, "b" -> 2, "c" -> 3)
|
||||
val a = new SimpleConfigObject(fakeOrigin(), aMap)
|
||||
|
@ -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