diff --git a/src/ast/entry_point.cc b/src/ast/entry_point.cc index a433be1e6a..69a449395e 100644 --- a/src/ast/entry_point.cc +++ b/src/ast/entry_point.cc @@ -42,8 +42,11 @@ bool EntryPoint::IsValid() const { void EntryPoint::to_str(std::ostream& out, size_t indent) const { make_indent(out, indent); - out << R"(EntryPoint{")" << stage_ << R"(" as ")" << name_ << R"(" = )" - << fn_name_ << "}" << std::endl; + out << "EntryPoint{" << stage_; + if (name_.length() > 0) + out << " as " << name_; + + out << " = " << fn_name_ << "}" << std::endl; } } // namespace ast diff --git a/src/ast/entry_point_test.cc b/src/ast/entry_point_test.cc index 57659248f9..3d8a1b555b 100644 --- a/src/ast/entry_point_test.cc +++ b/src/ast/entry_point_test.cc @@ -59,16 +59,8 @@ TEST_F(EntryPointTest, CreationEmpty) { EXPECT_EQ(e.column(), 4); } -TEST_F(EntryPointTest, to_str) { - EntryPoint e(PipelineStage::kVertex, "text", "vtx_main"); - std::ostringstream out; - e.to_str(out, 0); - EXPECT_EQ(out.str(), R"(EntryPoint{"vertex" as "text" = vtx_main} -)"); -} - TEST_F(EntryPointTest, IsValid) { - EntryPoint e(PipelineStage::kVertex, "main", "vtx_main"); + EntryPoint e(PipelineStage::kVertex, "", "vtx_main"); EXPECT_TRUE(e.IsValid()); } @@ -87,5 +79,21 @@ TEST_F(EntryPointTest, IsValid_MissingBoth) { EXPECT_FALSE(e.IsValid()); } +TEST_F(EntryPointTest, ToStr) { + EntryPoint e(PipelineStage::kVertex, "text", "vtx_main"); + std::ostringstream out; + e.to_str(out, 2); + EXPECT_EQ(out.str(), R"( EntryPoint{vertex as text = vtx_main} +)"); +} + +TEST_F(EntryPointTest, ToStr_NoName) { + EntryPoint e(PipelineStage::kVertex, "", "vtx_main"); + std::ostringstream out; + e.to_str(out, 2); + EXPECT_EQ(out.str(), R"( EntryPoint{vertex = vtx_main} +)"); +} + } // namespace ast } // namespace tint