|
Revision 1177, 0.8 KB
(checked in by chuck, 4 years ago)
|
|
Importing test cases.
|
-
Property svn:eol-style set to
native
|
| Line | |
|---|
| 1 | namespace Test |
|---|
| 2 | |
|---|
| 3 | class Test |
|---|
| 4 | |
|---|
| 5 | def main |
|---|
| 6 | is shared |
|---|
| 7 | |
|---|
| 8 | # more testing of the assert statement |
|---|
| 9 | # now that we can intercept the exception |
|---|
| 10 | |
|---|
| 11 | loc as int |
|---|
| 12 | |
|---|
| 13 | # general catch |
|---|
| 14 | loc = 0 |
|---|
| 15 | try |
|---|
| 16 | assert 0 |
|---|
| 17 | catch |
|---|
| 18 | loc = 1 |
|---|
| 19 | assert loc==1 |
|---|
| 20 | |
|---|
| 21 | # specific catch |
|---|
| 22 | loc = 0 |
|---|
| 23 | try |
|---|
| 24 | assert 0 |
|---|
| 25 | catch ae as AssertException |
|---|
| 26 | loc = 1 |
|---|
| 27 | catch e as Exception |
|---|
| 28 | CobraCore.noOp(e) |
|---|
| 29 | loc = 2 |
|---|
| 30 | assert loc==1 |
|---|
| 31 | |
|---|
| 32 | # no info |
|---|
| 33 | try |
|---|
| 34 | assert 0 |
|---|
| 35 | catch ae as AssertException |
|---|
| 36 | assert ae.info is nil |
|---|
| 37 | |
|---|
| 38 | success |
|---|
| 39 | assert 0 |
|---|
| 40 | |
|---|
| 41 | # string info |
|---|
| 42 | try |
|---|
| 43 | assert 0, 'hi' |
|---|
| 44 | catch ae as AssertException |
|---|
| 45 | assert ae.info.equals('hi') |
|---|
| 46 | success |
|---|
| 47 | assert 0 |
|---|
| 48 | |
|---|
| 49 | # int info |
|---|
| 50 | try |
|---|
| 51 | assert 0, 1 |
|---|
| 52 | catch ae as AssertException |
|---|
| 53 | assert ae.info.equals(1) |
|---|
| 54 | success |
|---|
| 55 | assert 0 |
|---|
| 56 | |
|---|
| 57 | # TODO: assert something about the ae.message in the last 3 cases |
|---|