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