Commit de01797 1 parent 27636cc commit de01797 Copy full SHA for de01797
File tree 3 files changed +40
-12
lines changed
commonTest/kotlin/com/jillesvangurp/jsondsl
jvmTest/kotlin/com/jillesvangurp/jsondsl/readme
3 files changed +40
-12
lines changed Original file line number Diff line number Diff line change @@ -304,8 +304,8 @@ val dsl = YamlDSL().apply {
304
304
str= """
305
305
Multi line
306
306
Strings are
307
- supported
308
- and
307
+ supported
308
+ and
309
309
preserve their
310
310
indentation!
311
311
""" .trimIndent()
@@ -326,10 +326,10 @@ This prints the YAML below:
326
326
str : |
327
327
Multi line
328
328
Strings are
329
- supported
330
- and
329
+ supported
330
+ and
331
331
preserve their
332
- indentation!
332
+ indentation!
333
333
map :
334
334
foo : bar
335
335
num : 3.141592653589793
Original file line number Diff line number Diff line change @@ -5,11 +5,12 @@ import kotlin.test.Test
5
5
6
6
class YamlTest {
7
7
val serializer = SimpleYamlSerializer ()
8
+
8
9
@Test
9
10
fun shouldProduceYaml () {
10
11
val q = query {
11
- query = term(" foo" ," bar" ) {
12
- boost= 2.0
12
+ query = term(" foo" , " bar" ) {
13
+ boost = 2.0
13
14
}
14
15
}
15
16
val yaml = serializer.serialize(q)
@@ -111,8 +112,34 @@ class YamlTest {
111
112
// for now, I've passed this through yamllint.com and it seems OK
112
113
println (yaml)
113
114
}
114
- }
115
115
116
+ @Test
117
+ fun shouldNotAddSpaces () {
118
+
119
+ val yml = withJsonDsl {
120
+ val str = """
121
+ Multi line
122
+ Strings are
123
+ supported
124
+ and
125
+ preserve their
126
+ indentation!
127
+ """ .trimIndent()
128
+ this [" s" ] = str
129
+ this [" a" ] = """
130
+ noIndent
131
+ twoIndent
132
+ fourIndent
133
+ """ .trimIndent()
134
+ }.yaml()
135
+ println (yml)
136
+ yml.lines().let { lines ->
137
+ val indent = lines.first { it.contains(" noIndent" ) }.indexOf(" noIndent" )
138
+ (lines.first { it.contains(" twoIndent" ) }.indexOf(" twoIndent" ) - indent) shouldBe 2
139
+ (lines.first { it.contains(" fourIndent" ) }.indexOf(" fourIndent" ) - indent) shouldBe 4
140
+ }
141
+ }
142
+ }
116
143
117
144
118
145
val loremIpsumText = """
Original file line number Diff line number Diff line change @@ -234,10 +234,10 @@ val readmeMd = sourceGitRepository.md {
234
234
str= """
235
235
Multi line
236
236
Strings are
237
- supported
238
- and
237
+ supported
238
+ and
239
239
preserve their
240
- indentation!
240
+ indentation!
241
241
""" .trimIndent()
242
242
map = mapOf (
243
243
" foo" to " bar" ,
@@ -252,7 +252,8 @@ val readmeMd = sourceGitRepository.md {
252
252
+ """
253
253
This prints the YAML below:
254
254
""" .trimIndent()
255
- mdCodeBlock(it.stdOut," yaml" )
255
+
256
+ mdCodeBlock(it.stdOut," yaml" , reIndent = false )
256
257
}
257
258
258
259
}
You can’t perform that action at this time.
0 commit comments