Skip to content

Commit

Permalink
#6031: Change a few assertions in the MaterialExport tests which were…
Browse files Browse the repository at this point in the history
… tailored to the old algorithm that replaced the entire decl including the whitespace and comments outside the braced block.
  • Loading branch information
codereader committed Aug 13, 2022
1 parent 3f14603 commit 0a234c9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion libs/parser/DefBlockSyntaxParser.h
Expand Up @@ -323,7 +323,7 @@ class DefBlockSyntax :

int nameIndex = static_cast<int>(headerNodes.size());
headerNodes.emplace_back(DefNameSyntax::Create(name));
headerNodes.emplace_back(DefWhitespaceSyntax::Create(" "));
headerNodes.emplace_back(DefWhitespaceSyntax::Create("\n"));

DefSyntaxToken blockToken(DefSyntaxToken::Type::BracedBlock, "{}");
return std::make_shared<DefBlockSyntax>(blockToken, std::move(headerNodes), nameIndex, typeIndex);
Expand Down
13 changes: 9 additions & 4 deletions test/MaterialExport.cpp
Expand Up @@ -1267,7 +1267,7 @@ TEST_F(MaterialExportTest, WritingMaterialFiles)

GlobalMaterialManager().saveMaterial(material->getName());

EXPECT_TRUE(algorithm::fileContainsText(exportTestFile, material->getName() + "\n{" + material->getDefinition() + "}"))
EXPECT_TRUE(algorithm::fileContainsText(exportTestFile, material->getName() + " {" + material->getDefinition() + "}"))
<< "New definition not found in file";
EXPECT_FALSE(algorithm::fileContainsText(exportTestFile, originalDefinition))
<< "Original definition still in file";
Expand All @@ -1284,7 +1284,9 @@ TEST_F(MaterialExportTest, WritingMaterialFiles)

GlobalMaterialManager().saveMaterial(material->getName());

EXPECT_TRUE(algorithm::fileContainsText(exportTestFile, material->getName() + "\n{" + material->getDefinition() + "}"))
// Saving doesn't alter any whitespace or comments around the curly braces
EXPECT_TRUE(algorithm::fileContainsText(exportTestFile,
"textures/exporttest/renderBump2 // Comment in the same line as the name (DON'T REMOVE THIS)\n{" + material->getDefinition() + "}"))
<< "New definition not found in file";
EXPECT_FALSE(algorithm::fileContainsText(exportTestFile, originalDefinition))
<< "Original definition still in file";
Expand All @@ -1302,7 +1304,10 @@ TEST_F(MaterialExportTest, WritingMaterialFiles)

GlobalMaterialManager().saveMaterial(material->getName());

EXPECT_TRUE(algorithm::fileContainsText(exportTestFile, material->getName() + "\n{" + material->getDefinition() + "}"))
EXPECT_TRUE(algorithm::fileContainsText(exportTestFile,
"textures/exporttest/renderBump3\n"
" // Comment in between the name and the definition (DON'T REMOVE THIS)\n"
"{" + material->getDefinition() + "}"))
<< "New definition not found in file";
EXPECT_FALSE(algorithm::fileContainsText(exportTestFile, originalDefinition))
<< "Original definition still in file";
Expand All @@ -1318,7 +1323,7 @@ TEST_F(MaterialExportTest, WritingMaterialFiles)

GlobalMaterialManager().saveMaterial(material->getName());

EXPECT_TRUE(algorithm::fileContainsText(exportTestFile, material->getName() + "\n{" + material->getDefinition() + "}"))
EXPECT_TRUE(algorithm::fileContainsText(exportTestFile, material->getName() + " {" + material->getDefinition() + "}"))
<< "New definition not found in file";
EXPECT_FALSE(algorithm::fileContainsText(exportTestFile, originalDefinition))
<< "Original definition still in file";
Expand Down

0 comments on commit 0a234c9

Please sign in to comment.