Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(214)

Unified Diff: courgette/adjustment_method_unittest.cc

Issue 2462993003: [Courgette] Refactor: Add and use Instruction*Receptor classes; call ParseFile() in 2 passes. (Closed)
Patch Set: Make AssemblyProgram::CreateInstruction*Receptor() return CheckBool. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | courgette/assembly_program.h » ('j') | courgette/assembly_program.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: courgette/adjustment_method_unittest.cc
diff --git a/courgette/adjustment_method_unittest.cc b/courgette/adjustment_method_unittest.cc
index d8b987c2d89e1ac6be8abe036bfa13f72f5ea31b..b560f17692a4d6a0b81cf4ba4fda2db38ee4e811 100644
--- a/courgette/adjustment_method_unittest.cc
+++ b/courgette/adjustment_method_unittest.cc
@@ -49,12 +49,25 @@ class AdjustmentMethodTest : public testing::Test {
courgette::Label* labelA = prog->FindAbs32Label(kRvaA);
courgette::Label* labelB = prog->FindAbs32Label(kRvaB);
- EXPECT_TRUE(prog->EmitAbs32(labelA));
- EXPECT_TRUE(prog->EmitAbs32(labelA));
- EXPECT_TRUE(prog->EmitAbs32(labelB));
- EXPECT_TRUE(prog->EmitAbs32(labelA));
- EXPECT_TRUE(prog->EmitAbs32(labelA));
- EXPECT_TRUE(prog->EmitAbs32(labelB));
+ auto emit_all = [](courgette::Label* labelA, courgette::Label* labelB,
+ courgette::InstructionReceptor* receptor) {
+ EXPECT_TRUE(receptor->EmitAbs32(labelA));
+ EXPECT_TRUE(receptor->EmitAbs32(labelA));
+ EXPECT_TRUE(receptor->EmitAbs32(labelB));
+ EXPECT_TRUE(receptor->EmitAbs32(labelA));
+ EXPECT_TRUE(receptor->EmitAbs32(labelA));
+ EXPECT_TRUE(receptor->EmitAbs32(labelB));
+ };
+
+ // Pass 1: Count the space needed to store instructions.
+ courgette::InstructionCountReceptor* count_receptor = nullptr;
+ EXPECT_TRUE(prog->CreateInstructionCountReceptor(&count_receptor));
+ emit_all(labelA, labelB, count_receptor);
+
+ // Pass 2: Emit all instructions.
+ courgette::InstructionStoreReceptor* store_receptor = nullptr;
+ EXPECT_TRUE(prog->CreateInstructionStoreReceptor(&store_receptor));
+ emit_all(labelA, labelB, store_receptor);
if (kind == 0) {
labelA->index_ = 0;
« no previous file with comments | « no previous file | courgette/assembly_program.h » ('j') | courgette/assembly_program.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698