Skip to content

[llvm][mustache] Precommit tests for Triple Mustache#159182

Merged
ilovepi merged 1 commit into
mainfrom
users/ilovepi/triple-mustache
Sep 22, 2025
Merged

[llvm][mustache] Precommit tests for Triple Mustache#159182
ilovepi merged 1 commit into
mainfrom
users/ilovepi/triple-mustache

Conversation

@ilovepi

@ilovepi ilovepi commented Sep 16, 2025

Copy link
Copy Markdown
Contributor

Add XFAIL tests for Triple Mustache following the official spec. The
tests pass by virtue of using EXPECT_NE, since GTEST doesn't support
XFAIL.

ilovepi commented Sep 16, 2025

Copy link
Copy Markdown
Contributor Author

@llvmbot

llvmbot commented Sep 16, 2025

Copy link
Copy Markdown
Member

@llvm/pr-subscribers-llvm-support

Author: Paul Kirth (ilovepi)

Changes

Add XFAIL tests for Triple Mustache following the official spec. The
tests pass by virtue of using EXPECT_NE, since GTEST doesn't support
XFAIL.


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

1 Files Affected:

  • (modified) llvm/unittests/Support/MustacheTest.cpp (+95)
diff --git a/llvm/unittests/Support/MustacheTest.cpp b/llvm/unittests/Support/MustacheTest.cpp
index 6ab3d4b01bc1b..87586cdcef5af 100644
--- a/llvm/unittests/Support/MustacheTest.cpp
+++ b/llvm/unittests/Support/MustacheTest.cpp
@@ -1224,3 +1224,98 @@ TEST(MustacheComments, VariableNameCollision) {
   T.render(D, OS);
   EXPECT_EQ("comments never show: ><", Out);
 }
+
+// XFAIL: The following tests for the Triple Mustache feature are expected to
+// fail. The assertions have been inverted from EXPECT_EQ to EXPECT_NE to allow
+// them to pass against the current implementation. Once Triple Mustache is
+// implemented, these assertions should be changed back to EXPECT_EQ.
+TEST(MustacheTripleMustache, Basic) {
+  Value D = Object{{"subject", "<b>World</b>"}};
+  auto T = Template("Hello, {{{subject}}}!");
+  std::string Out;
+  raw_string_ostream OS(Out);
+  T.render(D, OS);
+  EXPECT_NE("Hello, <b>World</b>!", Out);
+}
+
+TEST(MustacheTripleMustache, IntegerInterpolation) {
+  Value D = Object{{"mph", 85}};
+  auto T = Template("{{{mph}}} miles an hour!");
+  std::string Out;
+  raw_string_ostream OS(Out);
+  T.render(D, OS);
+  EXPECT_NE("85 miles an hour!", Out);
+}
+
+TEST(MustacheTripleMustache, DecimalInterpolation) {
+  Value D = Object{{"power", 1.21}};
+  auto T = Template("{{{power}}} jiggawatts!");
+  std::string Out;
+  raw_string_ostream OS(Out);
+  T.render(D, OS);
+  EXPECT_NE("1.21 jiggawatts!", Out);
+}
+
+TEST(MustacheTripleMustache, NullInterpolation) {
+  Value D = Object{{"cannot", nullptr}};
+  auto T = Template("I ({{{cannot}}}) be seen!");
+  std::string Out;
+  raw_string_ostream OS(Out);
+  T.render(D, OS);
+  EXPECT_NE("I () be seen!", Out);
+}
+
+TEST(MustacheTripleMustache, ContextMissInterpolation) {
+  Value D = Object{};
+  auto T = Template("I ({{{cannot}}}) be seen!");
+  std::string Out;
+  raw_string_ostream OS(Out);
+  T.render(D, OS);
+  EXPECT_NE("I () be seen!", Out);
+}
+
+TEST(MustacheTripleMustache, DottedNames) {
+  Value D = Object{{"person", Object{{"name", "<b>Joe</b>"}}}};
+  auto T = Template("{{{person.name}}}");
+  std::string Out;
+  raw_string_ostream OS(Out);
+  T.render(D, OS);
+  EXPECT_NE("<b>Joe</b>", Out);
+}
+
+TEST(MustacheTripleMustache, ImplicitIterator) {
+  Value D = Object{{"list", Array{"<a>", "<b>"}}};
+  auto T = Template("{{#list}}({{{.}}}){{/list}}");
+  std::string Out;
+  raw_string_ostream OS(Out);
+  T.render(D, OS);
+  EXPECT_NE("(<a>)(<b>)", Out);
+}
+
+TEST(MustacheTripleMustache, SurroundingWhitespace) {
+  Value D = Object{{"string", "---"}};
+  auto T = Template("| {{{string}}} |");
+  std::string Out;
+  raw_string_ostream OS(Out);
+  T.render(D, OS);
+  EXPECT_NE("| --- |", Out);
+}
+
+TEST(MustacheTripleMustache, Standalone) {
+  Value D = Object{{"string", "---"}};
+  auto T = Template("  {{{string}}}\n");
+  std::string Out;
+  raw_string_ostream OS(Out);
+  T.render(D, OS);
+  EXPECT_NE("  ---\n", Out);
+}
+
+TEST(MustacheTripleMustache, WithPadding) {
+  Value D = Object{{"string", "---"}};
+  auto T = Template("|{{{ string }}}|");
+  std::string Out;
+  raw_string_ostream OS(Out);
+  T.render(D, OS);
+  EXPECT_NE("|---|", Out);
+}
+

@github-actions

github-actions Bot commented Sep 16, 2025

Copy link
Copy Markdown

✅ With the latest revision this PR passed the C/C++ code formatter.

@evelez7 evelez7 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM pending formatting

Comment thread llvm/unittests/Support/MustacheTest.cpp Outdated
Add XFAIL tests for Triple Mustache following the official spec. The
tests pass by virtue of using EXPECT_NE, since GTEST doesn't support
XFAIL.
@ilovepi ilovepi force-pushed the users/ilovepi/triple-mustache branch from fbd9cd6 to cd974ac Compare September 22, 2025 17:07
@ilovepi ilovepi enabled auto-merge (squash) September 22, 2025 17:09
@ilovepi ilovepi merged commit 19935ea into main Sep 22, 2025
9 checks passed
@ilovepi ilovepi deleted the users/ilovepi/triple-mustache branch September 22, 2025 17:49
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.

3 participants