Add comprehensive tests for ProcessKernel and Usecode VM functionality
- Implemented tests for ProcessKernel in entity_dispatch_entry_tests.cpp, covering process creation, termination, and scanning of runnable processes. - Enhanced fixed_map_tests.cpp with tests for item allocation and release, including recycling of items and process ownership. - Expanded flex_archive_tests.cpp to validate the interaction between usecode events and item processes, ensuring correct behavior of spawned tasks and rendering. - Introduced usecode_vm_tests.cpp to thoroughly test the UsecodeInterpreterState and UsecodeProcessTask functionalities, including stack operations and opcode services.
This commit is contained in:
parent
e757bb33d0
commit
08a907f322
14 changed files with 1784 additions and 34 deletions
|
|
@ -236,6 +236,13 @@ int main()
|
|||
assert(allocatedItems.allocateItem(newItem) == 0x107);
|
||||
newItem.data.x = 0x8000;
|
||||
assert(!allocatedItems.allocateItem(newItem) && !allocatedItems.findItem(0x108));
|
||||
newItem.data.x = 511;
|
||||
remorse::ProcessKernel recyclingKernel;
|
||||
assert(allocatedItems.releaseItem(0x106, recyclingKernel));
|
||||
assert(allocatedItems.releaseItem(0x107, recyclingKernel));
|
||||
assert(allocatedItems.allocateItem(newItem) == 0x107);
|
||||
assert(allocatedItems.allocateItem(newItem) == 0x106);
|
||||
|
||||
remorse::StagedFixedMapItem globEgg;
|
||||
globEgg.itemNumber = 0x100;
|
||||
globEgg.data.x = 0x403;
|
||||
|
|
@ -254,6 +261,24 @@ int main()
|
|||
assert(child->data.x == 0x405 && child->data.y == 0x60b && child->data.z == 15);
|
||||
assert(child->data.flags == 0x82 && child->data.frame == 2);
|
||||
assert(hatchedItems.isGlobHatched(0x100) && !hatchedItems.hatchGlobEgg(0x100, glob, globShapes));
|
||||
|
||||
remorse::LiveFixedMapItems processOwnedItems({globEgg});
|
||||
remorse::ProcessKernel itemOwnerKernel;
|
||||
remorse::u16 itemOwnerGroups[32]{};
|
||||
for (int index = 0; index < 3; ++index) {
|
||||
itemOwnerKernel.createProcess(1, itemOwnerGroups);
|
||||
}
|
||||
auto* itemOwner = itemOwnerKernel.createItemProcess(1, 0x100, itemOwnerGroups);
|
||||
assert(itemOwnerKernel.itemHasProcess(0x100));
|
||||
assert(!processOwnedItems.releaseItem(0x100, itemOwnerKernel));
|
||||
const remorse::u16 itemOwnerProcessId = static_cast<remorse::u16>(
|
||||
itemOwner->bytes[0x02] | (static_cast<remorse::u16>(itemOwner->bytes[0x03]) << 8));
|
||||
itemOwnerKernel.terminateProcess(itemOwnerProcessId, itemOwnerGroups);
|
||||
itemOwnerKernel.clearTerminatedProcesses();
|
||||
assert(!itemOwnerKernel.itemHasProcess(0x100));
|
||||
assert(processOwnedItems.releaseItem(0x100, itemOwnerKernel));
|
||||
assert(processOwnedItems.allocateItem(globEgg) == 0x100);
|
||||
|
||||
remorse::LiveFixedMapItems movingItems(blockItems);
|
||||
remorse::ProcessKernel movingKernel;
|
||||
remorse::u16 movingGroups[32]{};
|
||||
|
|
@ -372,16 +397,51 @@ int main()
|
|||
assert((*contained)[2].itemNumber == 0x103 && (*contained)[2].parentItemNumber == 0x100);
|
||||
const auto directContainerItems = remorse::stageFixedMapItems(containedMap);
|
||||
assert(directContainerItems && directContainerItems->size() == 2);
|
||||
auto monsterEggShapes = containerShapes;
|
||||
monsterEggShapes[1].family = 7;
|
||||
const auto monsterEggContents = remorse::stageContainedFixedMapItems(containedMap, monsterEggShapes);
|
||||
assert(monsterEggContents && monsterEggContents->size() == 3 &&
|
||||
(*monsterEggContents)[0].parentItemNumber == 0x100 &&
|
||||
(*monsterEggContents)[1].parentItemNumber == 0x101 &&
|
||||
(*monsterEggContents)[2].parentItemNumber == 0x100);
|
||||
remorse::LiveFixedMapItems monsterEggItems(*directContainerItems, *monsterEggContents);
|
||||
assert((monsterEggItems.containedChildren(0x100) == std::vector<remorse::u16>{0x101, 0x103}));
|
||||
assert(monsterEggItems.findItem(0x100)->data.quality == 0x101);
|
||||
assert(!monsterEggItems.moveItemIntoContainer(0x104, 0x100, monsterEggShapes));
|
||||
assert(monsterEggItems.moveContainedItemToWorld(0x101, 600, 700, 12));
|
||||
assert(monsterEggItems.findItem(0x101)->data.quality == 0x102 &&
|
||||
monsterEggItems.findItem(0x100)->data.quality == 0x103);
|
||||
remorse::LiveFixedMapItems nestedItems(*directContainerItems, *contained);
|
||||
assert(nestedItems.containedParent(0x101) == 0x100 &&
|
||||
nestedItems.containedParent(0x102) == 0x101 && nestedItems.containedParent(0x103) == 0x100);
|
||||
assert((nestedItems.containedChildren(0x100) == std::vector<remorse::u16>{0x101, 0x103}));
|
||||
assert((nestedItems.containedChildren(0x101) == std::vector<remorse::u16>{0x102}));
|
||||
assert(nestedItems.findItem(0x100)->data.quality == 0x101);
|
||||
assert(!nestedItems.moveItemIntoContainer(0x100, 0x102, containerShapes));
|
||||
assert(nestedItems.moveItemIntoContainer(0x104, 0x100, containerShapes));
|
||||
assert((nestedItems.containedChildren(0x100) == std::vector<remorse::u16>{0x104, 0x101, 0x103}));
|
||||
assert(nestedItems.findItem(0x100)->data.quality == 0x104);
|
||||
assert(!nestedItems.findItem(0x104) && nestedItems.containedParent(0x104) == 0x100);
|
||||
assert(nestedItems.moveContainedItemToWorld(0x104, 700, 800, 12));
|
||||
assert((nestedItems.containedChildren(0x100) == std::vector<remorse::u16>{0x101, 0x103}));
|
||||
assert(nestedItems.findItem(0x100)->data.quality == 0x101);
|
||||
assert(nestedItems.findItem(0x104)->data.x == 700 && nestedItems.findItem(0x104)->data.y == 800);
|
||||
assert(nestedItems.containedParent(0x102) == 0x101);
|
||||
remorse::StagedFixedMapItem nestedNewItem = directContainerItems->front();
|
||||
assert(nestedItems.allocateItem(nestedNewItem) == 0x105);
|
||||
remorse::ProcessKernel noItemProcesses;
|
||||
assert(nestedItems.releaseItem(0x105, noItemProcesses));
|
||||
assert(!nestedItems.findItem(0x105));
|
||||
assert(nestedItems.allocateItem(nestedNewItem) == 0x105);
|
||||
assert(!nestedItems.findItem(0x101) && !nestedItems.findItem(0x102) &&
|
||||
!nestedItems.findItem(0x103) && nestedItems.findItem(0x105));
|
||||
nestedNewItem.itemNumber = 0x101;
|
||||
assert(nestedItems.insertItem(nestedNewItem));
|
||||
assert(nestedItems.findItem(0x100)->data.quality == 0x103);
|
||||
assert(nestedItems.containedParent(0x101) == 0 && nestedItems.containedParent(0x102) == 0x101);
|
||||
assert((nestedItems.containedChildren(0x100) == std::vector<remorse::u16>{0x103}));
|
||||
assert((nestedItems.containedChildren(0x101) == std::vector<remorse::u16>{0x102}));
|
||||
assert(!nestedItems.releaseItem(0x101, noItemProcesses));
|
||||
std::vector<remorse::StagedContainedFixedMapItem> fullItemRange;
|
||||
for (remorse::u16 itemNumber = 0x101; itemNumber < 0x2800; ++itemNumber) {
|
||||
fullItemRange.push_back({itemNumber, 0x100, 0});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue