-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Several cosmetic fixes for multiline strings (#217)
### What's done: - On multiline strings we forgot to update isMultiline flag while decoding and parsing - Adding extra info to prettyPrint - Adding a test for validation of line numbers - Removing deprecated 'content' from the TomlNode - Added newline alignment for multiline strings (newlines after/before quotes-separators)
- Loading branch information
Showing
7 changed files
with
151 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
ktoml-core/src/commonTest/kotlin/com/akuleshov7/ktoml/parsers/SetLineNoTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
package com.akuleshov7.ktoml.parsers | ||
|
||
import com.akuleshov7.ktoml.Toml | ||
import kotlin.test.Test | ||
import kotlin.test.assertEquals | ||
|
||
class SetLineNoTest { | ||
@Test | ||
fun checkingLineNumbersGeneral() { | ||
val string = | ||
""" | ||
# comment 1 | ||
[a] # comment 2 | ||
# comment 3 | ||
test = 1 # comment 4 | ||
# ==== | ||
[[a.b]] # comment 5 | ||
test = 1 | ||
mlls = ''' | ||
1 | ||
2 | ||
3 | ||
''' | ||
mla = [ | ||
"a", | ||
"b", | ||
"c" | ||
] | ||
""".trimIndent() | ||
val parsedToml = Toml.tomlParser.parseString(string) | ||
|
||
parsedToml.prettyPrint(true) | ||
assertEquals( | ||
""" | ||
| - TomlFile (rootNode)[line:0] | ||
| - TomlTablePrimitive ([a])[line:4] | ||
| - TomlKeyValuePrimitive (test=1)[line:6] | ||
| - TomlArrayOfTables ([[a.b]])[line:10] | ||
| - TomlArrayOfTablesElement (technical_node)[line:10] | ||
| - TomlKeyValuePrimitive (test=1)[line:11] | ||
| - TomlKeyValuePrimitive (mlls=''' | ||
| 1 | ||
| 2 | ||
| 3 | ||
| | ||
|''')[line:13] | ||
| - TomlKeyValueArray (mla=[ "a", "b", "c" ])[line:18] | ||
| | ||
""".trimMargin(), | ||
parsedToml.prettyStr(true) | ||
) | ||
} | ||
|
||
@Test | ||
fun checkingLineNumbers() { | ||
val string = "\n\n" + | ||
"mlls = '''\n" + | ||
"1\n" + | ||
"\n" + | ||
"2\n" + | ||
"3" + | ||
"'''" | ||
val parsedToml = Toml.tomlParser.parseString(string) | ||
parsedToml.prettyPrint(true) | ||
|
||
assertEquals( | ||
""" | ||
| - TomlFile (rootNode)[line:0] | ||
| - TomlKeyValuePrimitive (mlls=''' | ||
|1 | ||
| | ||
|2 | ||
|3 | ||
|''')[line:3] | ||
| | ||
""".trimMargin(), | ||
parsedToml.prettyStr(true) | ||
) | ||
} | ||
} |