-
Notifications
You must be signed in to change notification settings - Fork 249
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tryCatch): add an example and 2 tests for tryCatch
- Loading branch information
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env bash | ||
|
||
source "$( cd "${BASH_SOURCE[0]%/*}" && pwd )/../lib/oo-bootstrap.sh" | ||
|
||
import util/exception util/tryCatch util/log util/test | ||
|
||
describe 'Try Catch' | ||
it 'should throw a "test exception"' | ||
try | ||
try { | ||
e="test exception" throw | ||
} catch { | ||
[[ "${__EXCEPTION__[1]}" == "test exception" ]] | ||
} | ||
expectPass | ||
|
||
it 'should throw a general exception inside of a catch' | ||
try { | ||
try { | ||
false | ||
} catch { | ||
e="we throw again inside of a catch" throw | ||
echo this should not be displayed | ||
} | ||
echo this should not be displayed | ||
} | ||
expectFail | ||
|
||
summary |