// šŸ”„ fini System Violation Tests - Testing guards and prohibitions box TestResource { init { name } pack(resourceName) { me.name = resourceName } getData() { return "Resource: " + me.name.toString() } fini() { print("šŸ”„ TestResource.fini(): Finalizing " + me.name.toString()) } } box BadExample { init { weak weakRef, strongRef } pack(name) { me.strongRef = new TestResource(name + "_strong") me.weakRef = new TestResource(name + "_weak") // Will be set as weak } // This should trigger weak-fini prohibition badFini() { print("šŸ”„ BadExample.badFini(): Attempting illegal operations") me.weakRef.fini() // Should fail with "Cannot finalize weak field" } } static box Main { main() { print("=== šŸ”„ fini System Violation Tests ===") // Test 1: Usage after finalization prohibition print("\nšŸ“‹ Test 1: Usage after finalization (should fail)") local resource = new TestResource("TestViolation") print("Before fini: " + resource.getData()) resource.fini() print("Resource finalized") print("Attempting to access finalized resource...") resource.getData() // Should fail with "Instance was finalized" return "Test should have failed before reaching here" } }