Skip to content

Commit

Permalink
small bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
amihaiemil committed May 1, 2024
1 parent 7f591dd commit a669f80
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/main/java/com/amihaiemil/eoyaml/AllYamlLines.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ private YamlNode mappingSequenceOrPlainScalar(final YamlLine prev) {
new Edited(prev.trimmed()
+ " null #" + prev.comment(), prev)
);
} else if(first.trimmed().matches("^\\s*-?\\s*\\[.*$")) {
} else if(first.trimmed().matches("^\\s*\\[.*$")) {
node = new ReadFlowSequence(prev, this);
} else if(first.trimmed().matches("^\\s*-?\\s*\\{.*$")) {
} else if(first.trimmed().matches("^\\s*\\{.*$")) {
node = new ReadFlowMapping(prev, this);
} else {
Matcher matcher = SEQUENCE_OR_MAP.matcher(first.trimmed());
Expand Down
7 changes: 7 additions & 0 deletions src/test/java/com/amihaiemil/eoyaml/YamlMappingPrintTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public void printsReadYamlMappingWithAllNodes() throws Exception {
final YamlMapping read = Yaml.createYamlInput(
new File("src/test/resources/printing_tests/yamlMappingAllNodes.txt")
).readYamlMapping();
System.out.println(read);
MatcherAssert.assertThat(
read.toString(),
Matchers.equalTo(
Expand Down Expand Up @@ -191,6 +192,12 @@ public void printsBuiltYamlMappingWithAllNodes() throws Exception {
)
.build()
)
.add(
"someFlowMap",
Yaml.createYamlSequenceBuilder()
.add(Json.createObjectBuilder().add("a", "b").build())
.build()
)
.build();
MatcherAssert.assertThat(
built.toString(),
Expand Down
4 changes: 3 additions & 1 deletion src/test/resources/printing_tests/yamlMappingAllNodes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,6 @@ key10: {a: b, c: d, e: f}
[a, b, c]
: scalarToFlowSequence
someFlowSeq:
- [a, b, c]
- [a, b, c]
someFlowMap:
- {a: b}

0 comments on commit a669f80

Please sign in to comment.