From aea7dcea7ab809d526c85bdf432fa90f1a15efb8 Mon Sep 17 00:00:00 2001 From: "@nheuser" Date: Wed, 10 Jun 2026 20:40:02 +0200 Subject: [PATCH 1/2] added test that timeouts because of infinite loop --- .../test/delete-on-re-containers.spec.ts | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 projects/emfular/src/lib/referencing/test/delete-on-re-containers.spec.ts diff --git a/projects/emfular/src/lib/referencing/test/delete-on-re-containers.spec.ts b/projects/emfular/src/lib/referencing/test/delete-on-re-containers.spec.ts new file mode 100644 index 0000000..7f40eb8 --- /dev/null +++ b/projects/emfular/src/lib/referencing/test/delete-on-re-containers.spec.ts @@ -0,0 +1,64 @@ +import {Middle2WithChildren, ReChild3, RootWithChildren} from "./referencables-with-children"; +import {DeletionMode} from "../../utils/deletion-mode"; + +describe('ReContainer delete tests', () => { + it("should relaxed delete re-tree-container correctly", () =>{ + let root = new RootWithChildren(); + let child1 = new ReChild3(); + let child2 = new ReChild3(); + let middle = new Middle2WithChildren(); + root.link3.push(child1,child2); + middle.child3.push(child1,child2); + expect(root.link3.length).toBe(2); + expect(child1.link1).toContain(root); + expect(child2.link1).toContain(root); + expect(middle.child3.length).toBe(2); + expect(child1.parentPointer).toEqual(middle); + expect(child2.parentPointer).toEqual(middle); + middle.child3.delete(); + expect(root.link3.length).toBe(2); + expect(middle.child3.length).toBe(0); + expect(child1.parentPointer).toBeUndefined(); + expect(child2.parentPointer).toBeUndefined(); + }) + + it("should cascade delete re-tree-container correctly", () =>{ + let root = new RootWithChildren(); + let child1 = new ReChild3(); + let child2 = new ReChild3(); + let middle = new Middle2WithChildren(); + root.link3.push(child1,child2); + middle.child3.push(child1,child2); + expect(root.link3.length).toBe(2); + expect(child1.link1).toContain(root); + expect(child2.link1).toContain(root); + expect(middle.child3.length).toBe(2); + expect(child1.parentPointer).toEqual(middle); + expect(child2.parentPointer).toEqual(middle); + middle.child3.delete(); + expect(root.link3.length).toBe(2); + expect(middle.child3.length).toBe(0); + expect(child1.parentPointer).toBeUndefined(); + expect(child2.parentPointer).toBeUndefined(); + }) + + it("should delete re-list-container correctly", () =>{ + let root = new RootWithChildren(); + let child1 = new ReChild3(); + let child2 = new ReChild3(); + let middle = new Middle2WithChildren(); + root.link3.push(child1,child2); + middle.child3.push(child1,child2); + expect(root.link3.length).toBe(2); + expect(child1.link1).toContain(root); + expect(child2.link1).toContain(root); + expect(middle.child3.length).toBe(2); + expect(child1.parentPointer).toEqual(middle); + expect(child2.parentPointer).toEqual(middle); + root.link3.delete(); + expect(root.link3.length).toBe(0); + expect(middle.child3.length).toBe(2); + expect(child1.parentPointer).toBeDefined(); + expect(child2.parentPointer).toBeDefined(); + }) +}); \ No newline at end of file From 72e70b277aa242e70aa931ace87da9d9a1a4c1b2 Mon Sep 17 00:00:00 2001 From: "@nheuser" Date: Wed, 10 Jun 2026 20:42:05 +0200 Subject: [PATCH 2/2] overide delete method for ReLinkListContainer --- .../referencable/container/link/re-link-list-container.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/projects/emfular/src/lib/referencing/referencable/container/link/re-link-list-container.ts b/projects/emfular/src/lib/referencing/referencable/container/link/re-link-list-container.ts index 2db6574..1fc2b5b 100644 --- a/projects/emfular/src/lib/referencing/referencable/container/link/re-link-list-container.ts +++ b/projects/emfular/src/lib/referencing/referencable/container/link/re-link-list-container.ts @@ -45,6 +45,12 @@ implements ReLinkContainer { return res; //todo behaviour of flag different to add?? } + override delete(mode: DeletionMode = DeletionMode.RELAXED): void { + while (this._instance.length > 0) { + this.remove(this._instance[0], mode); + } + } + removeFromInverse(item: T, mode: DeletionMode = DeletionMode.RELAXED): boolean { if(this.inverseName !== undefined) { for (const child of [...this._instance]) {