[yul-phaser] Add --prefix option

This commit is contained in:
Kamil Śliwak
2020-03-23 16:31:35 +01:00
parent 148b87c977
commit a66ceb11c6
3 changed files with 49 additions and 5 deletions
+33 -5
View File
@@ -324,11 +324,14 @@ BOOST_AUTO_TEST_CASE(build_should_load_programs_from_files)
{
TemporaryDirectory tempDir;
vector<string> sources{"{}", "{{}}", "{{{}}}"};
ProgramFactory::Options options{/* inputFiles = */ {
tempDir.memberPath("program1.yul"),
tempDir.memberPath("program2.yul"),
tempDir.memberPath("program3.yul"),
}};
ProgramFactory::Options options{
/* inputFiles = */ {
tempDir.memberPath("program1.yul"),
tempDir.memberPath("program2.yul"),
tempDir.memberPath("program3.yul"),
},
/* prefix = */ "",
};
for (size_t i = 0; i < sources.size(); ++i)
{
@@ -346,6 +349,31 @@ BOOST_AUTO_TEST_CASE(build_should_load_programs_from_files)
}
}
BOOST_AUTO_TEST_CASE(build_should_apply_prefix)
{
TemporaryDirectory tempDir;
ProgramFactory::Options options{
/* inputFiles = */ {tempDir.memberPath("program1.yul")},
/* prefix = */ "f",
};
CharStream nestedSource("{{{let x:= 1}}}", "");
Program nestedProgram = get<Program>(Program::load(nestedSource));
Program flatProgram = get<Program>(Program::load(nestedSource));
flatProgram.optimise(Chromosome("f").optimisationSteps());
assert(toString(nestedProgram) != toString(flatProgram));
{
ofstream tmpFile(options.inputFiles[0]);
tmpFile << nestedSource.source() << endl;
}
vector<Program> programs = ProgramFactory::build(options);
BOOST_TEST(programs.size() == 1);
BOOST_TEST(toString(programs[0]) == toString(flatProgram));
}
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_SUITE_END()