upTreeTraversal finished, fixed a bug in fixture parser where every node had parent set to 0

unfinished test that checks agains that error
This commit is contained in:
2026-07-20 18:15:50 +02:00
parent e89cec47d9
commit 46f9e05d63
4 changed files with 29 additions and 3 deletions
+24 -1
View File
@@ -1,8 +1,9 @@
import { FileSystem } from "@core/filesystem/filesystem";
import { TreeNodeType, type DirectoryNode, type FileNode, type TreeNode } from "@core/filesystem/treenode";
import { createImmutableBuffer } from "@core/util/immutable_buffer";
import { dnTraverseTree } from "@core/util/tree_traversal";
import { buildTestFS, type FixtureNode } from "@tests/helpers/filesystems_fixture";
import { describe, expect, it } from "vitest";
import { describe, expect, it, test } from "vitest";
const testTree: FixtureNode = {
inode: 0,
@@ -35,6 +36,28 @@ const testTree: FixtureNode = {
const fs = buildTestFS(testTree);
test("walks down the tree to check if every node has the parent set correctly", () => {
const result = dnTraverseTree(fs, 0);
const out: boolean[] = [];
let parentInode = 0;
for (const inode of result) {
const node = fs.getNode(inode) as TreeNode;
if (node.parent !== parentInode) {
console.log(node.inode);
out.push(false);
}
parentInode = node.parent;
}
console.log(out, result);
expect(out.includes(false)).toBe(false);
});
describe("FileSystem.init", () => {
const map: Map<number, TreeNode> = new Map();
const time = Date.now();