Use the TestCase settings mechanism for object compiler tests.

This commit is contained in:
Daniel Kirchner 2019-06-11 14:11:27 +02:00
parent 547173533c
commit ba8ad1a1d9
3 changed files with 18 additions and 18 deletions

View File

@ -46,14 +46,12 @@ ObjectCompilerTest::ObjectCompilerTest(string const& _filename)
BOOST_THROW_EXCEPTION(runtime_error("Cannot open test case: \"" + _filename + "\".")); BOOST_THROW_EXCEPTION(runtime_error("Cannot open test case: \"" + _filename + "\"."));
file.exceptions(ios::badbit); file.exceptions(ios::badbit);
string line; m_source = parseSourceAndSettings(file);
while (getline(file, line)) if (m_settings.count("optimize"))
{ {
if (boost::algorithm::starts_with(line, "// ----")) m_optimize = true;
break; m_validatedSettings["optimize"] = "true";
if (m_source.empty() && boost::algorithm::starts_with(line, "// optimize")) m_settings.erase("optimize");
m_optimize = true;
m_source += line + "\n";
} }
m_expectation = parseSimpleExpectations(file); m_expectation = parseSimpleExpectations(file);
} }

View File

@ -1,4 +1,3 @@
// optimize
object "a" { object "a" {
code { code {
let x := calldataload(0) let x := calldataload(0)
@ -15,24 +14,26 @@ object "a" {
} }
} }
} }
// ====
// optimize: true
// ---- // ----
// Assembly: // Assembly:
// /* "source":60:61 */ // /* "source":48:49 */
// 0x00 // 0x00
// 0x00 // 0x00
// /* "source":47:62 */ // /* "source":35:50 */
// calldataload // calldataload
// /* "source":119:139 */ // /* "source":107:127 */
// sstore // sstore
// stop // stop
// //
// sub_0: assembly { // sub_0: assembly {
// /* "source":200:201 */ // /* "source":188:189 */
// 0x00 // 0x00
// 0x00 // 0x00
// /* "source":187:202 */ // /* "source":175:190 */
// calldataload // calldataload
// /* "source":265:285 */ // /* "source":253:273 */
// sstore // sstore
// } // }
// Bytecode: 600060003555fe // Bytecode: 600060003555fe

View File

@ -1,18 +1,19 @@
// optimize
{ {
let x := calldataload(0) let x := calldataload(0)
let y := calldataload(0) let y := calldataload(0)
let z := sub(y, x) let z := sub(y, x)
sstore(add(x, 0), z) sstore(add(x, 0), z)
} }
// ====
// optimize: true
// ---- // ----
// Assembly: // Assembly:
// /* "source":38:39 */ // /* "source":26:27 */
// 0x00 // 0x00
// 0x00 // 0x00
// /* "source":25:40 */ // /* "source":13:28 */
// calldataload // calldataload
// /* "source":91:111 */ // /* "source":79:99 */
// sstore // sstore
// Bytecode: 600060003555 // Bytecode: 600060003555
// Opcodes: PUSH1 0x0 PUSH1 0x0 CALLDATALOAD SSTORE // Opcodes: PUSH1 0x0 PUSH1 0x0 CALLDATALOAD SSTORE