This commit is contained in:
2026-04-28 09:48:16 -05:00
parent 44a51acad1
commit 30ecab3403
3 changed files with 85 additions and 76 deletions

View File

@@ -84,8 +84,8 @@ TEST(Bytecode, Constants)
0x54, 'H', 'E', 'L', 'L', 'O', 0x00
};
Bytecode bc(bp);
ASSERT_EQ(bc.data(), expected);
ByteArray ba = Bytecode::generate(bp);
ASSERT_EQ(ba.data(), expected);
}
TEST(Bytecode, Code)
@@ -122,6 +122,11 @@ TEST(Bytecode, Code)
// code
0x68, 0x54, 0x42,
};
/*
ByteArray ba = Bytecode::generate(bp);
ASSERT_EQ(ba.data(), expected);
*/
}
TEST(Bytecode, Parsing)
@@ -141,12 +146,11 @@ TEST(Bytecode, Parsing)
auto& f2 = bp.functions.emplace_back(2, 1);
f2.code.append_byte(0x42);
Bytecode bc1(bp);
auto data = bc1.data();
ByteArray ba = Bytecode::generate(bp);
// read bytecode
Bytecode bc2(data);
Bytecode bc2(std::move(ba));
ASSERT_EQ(bc2.n_constants(), 3);
ASSERT_EQ(bc2.n_functions(), 2);