Skip to content

Reapply "[YAML][NFC] precommit wrong test case (#131782)" #132936

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 25, 2025

Conversation

HerrCai0907
Copy link
Contributor

This reverts commit 6477945.

@llvmbot
Copy link
Member

llvmbot commented Mar 25, 2025

@llvm/pr-subscribers-llvm-support

Author: Congcong Cai (HerrCai0907)

Changes

This reverts commit 6477945.


Full diff: https://github.com/llvm/llvm-project/pull/132936.diff

1 Files Affected:

  • (modified) llvm/unittests/Support/YAMLIOTest.cpp (+30)
diff --git a/llvm/unittests/Support/YAMLIOTest.cpp b/llvm/unittests/Support/YAMLIOTest.cpp
index c0e9c57a77f19..f03563cd5bc2e 100644
--- a/llvm/unittests/Support/YAMLIOTest.cpp
+++ b/llvm/unittests/Support/YAMLIOTest.cpp
@@ -1273,6 +1273,36 @@ TEST(YAMLIO, TestReadWriteBlockScalarValue) {
   }
 }
 
+struct V {
+  MultilineStringType doc;
+  std::string str;
+};
+template <> struct llvm::yaml::MappingTraits<V> {
+  static void mapping(IO &io, V &v) {
+    io.mapRequired("block_scalac", v.doc);
+    io.mapRequired("scalar", v.str);
+  }
+};
+template <> struct llvm::yaml::SequenceElementTraits<V> {
+  static const bool flow = false;
+};
+TEST(YAMLIO, TestScalarAfterBlockScalar) {
+  std::vector<V> v{V{}};
+  v[0].doc.str = "AA\nBB";
+  v[0].str = "a";
+  std::string output;
+  llvm::raw_string_ostream ostr(output);
+  Output yout(ostr);
+  yout << v;
+  EXPECT_EQ(output, R"(---
+- block_scalac:     |
+    AA
+    BB
+scalar:          a
+...
+)");
+}
+
 //===----------------------------------------------------------------------===//
 //  Test flow sequences
 //===----------------------------------------------------------------------===//

@HerrCai0907 HerrCai0907 merged commit feecb20 into llvm:main Mar 25, 2025
13 checks passed
@HerrCai0907 HerrCai0907 deleted the reland-test branch March 25, 2025 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants