aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/Support/YAMLParserTest.cpp
diff options
context:
space:
mode:
authorAlex Lorenz <arphaman@gmail.com>2015-05-13 23:10:51 +0000
committerAlex Lorenz <arphaman@gmail.com>2015-05-13 23:10:51 +0000
commita22b250c6ffaba93b5de2b126eac260585b19dd5 (patch)
treea14a08de72bd30cdc7d6b7ff7c4ddcb5dc774fc5 /llvm/unittests/Support/YAMLParserTest.cpp
parentaf0494f1585f4d41c4eb9c64930fb077289d1190 (diff)
downloadllvm-a22b250c6ffaba93b5de2b126eac260585b19dd5.zip
llvm-a22b250c6ffaba93b5de2b126eac260585b19dd5.tar.gz
llvm-a22b250c6ffaba93b5de2b126eac260585b19dd5.tar.bz2
YAML: Implement block scalar parsing.
This commit implements the parsing of YAML block scalars. Some code existed for it before, but it couldn't parse block scalars. This commit adds a new yaml node type to represent the block scalar values. This commit also deletes the 'spec-09-27' and 'spec-09-28' tests as they are identical to the test file 'spec-09-26'. This commit introduces 3 new utility functions to the YAML scanner class: `skip_s_space`, `advanceWhile` and `consumeLineBreakIfPresent`. Reviewers: Duncan P. N. Exon Smith Differential Revision: http://reviews.llvm.org/D9503 llvm-svn: 237314
Diffstat (limited to 'llvm/unittests/Support/YAMLParserTest.cpp')
-rw-r--r--llvm/unittests/Support/YAMLParserTest.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/llvm/unittests/Support/YAMLParserTest.cpp b/llvm/unittests/Support/YAMLParserTest.cpp
index 918c205..d3ee8af 100644
--- a/llvm/unittests/Support/YAMLParserTest.cpp
+++ b/llvm/unittests/Support/YAMLParserTest.cpp
@@ -130,6 +130,33 @@ TEST(YAMLParser, ParsesArrayOfArrays) {
ExpectParseSuccess("Array of arrays", "[[]]");
}
+TEST(YAMLParser, ParsesBlockLiteralScalars) {
+ ExpectParseSuccess("Block literal scalar", "test: |\n Hello\n World\n");
+ ExpectParseSuccess("Block literal scalar EOF", "test: |\n Hello\n World");
+ ExpectParseSuccess("Empty block literal scalar header EOF", "test: | ");
+ ExpectParseSuccess("Empty block literal scalar", "test: |\ntest2: 20");
+ ExpectParseSuccess("Empty block literal scalar 2", "- | \n \n\n \n- 42");
+ ExpectParseSuccess("Block literal scalar in sequence",
+ "- |\n Testing\n Out\n\n- 22");
+ ExpectParseSuccess("Block literal scalar in document",
+ "--- |\n Document\n...");
+ ExpectParseSuccess("Empty non indented lines still count",
+ "- |\n First line\n \n\n Another line\n\n- 2");
+ ExpectParseSuccess("Comment in block literal scalar header",
+ "test: | # Comment \n No Comment\ntest 2: | # Void");
+ ExpectParseSuccess("Chomping indicators in block literal scalar header",
+ "test: |- \n Hello\n\ntest 2: |+ \n\n World\n\n\n");
+ ExpectParseSuccess("Indent indicators in block literal scalar header",
+ "test: |1 \n \n Hello \n World\n");
+ ExpectParseSuccess("Chomping and indent indicators in block literals",
+ "test: |-1\n Hello\ntest 2: |9+\n World");
+ ExpectParseSuccess("Trailing comments in block literals",
+ "test: |\n Content\n # Trailing\n #Comment\ntest 2: 3");
+ ExpectParseError("Invalid block scalar header", "test: | failure");
+ ExpectParseError("Invalid line indentation", "test: |\n First line\n Error");
+ ExpectParseError("Long leading space line", "test: |\n \n Test\n");
+}
+
TEST(YAMLParser, HandlesEndOfFileGracefully) {
ExpectParseError("In string starting with EOF", "[\"");
ExpectParseError("In string hitting EOF", "[\" ");