40 lines
690 B
Plaintext
40 lines
690 B
Plaintext
function safe_add(a, b) {
|
|
return a + b
|
|
} disruption {
|
|
print("disruption caught in safe_add")
|
|
}
|
|
|
|
function inner() {
|
|
disrupt
|
|
}
|
|
|
|
function outer() {
|
|
inner()
|
|
} disruption {
|
|
print("disruption caught in outer — from inner()")
|
|
}
|
|
|
|
// Test 1: explicit disrupt with handler
|
|
function test_explicit() {
|
|
disrupt
|
|
} disruption {
|
|
print("test 1: explicit disrupt handled")
|
|
}
|
|
test_explicit()
|
|
|
|
// Test 2: type error disrupt (number + function)
|
|
safe_add(1, print)
|
|
|
|
// Test 3: unwinding — inner disrupts, outer catches
|
|
outer()
|
|
|
|
// Test 4: disrupt from inside disruption clause
|
|
function test_nested() {
|
|
disrupt
|
|
} disruption {
|
|
print("test 4: first disruption")
|
|
}
|
|
test_nested()
|
|
|
|
print("done")
|