2017-01-09 12:52:37 +00:00
|
|
|
|
|
|
|
#include 'Moo.moo'.
|
|
|
|
|
|
|
|
#################################################################
|
|
|
|
## MAIN
|
|
|
|
#################################################################
|
|
|
|
|
|
|
|
## TODO: use #define to define a class or use #class to define a class.
|
|
|
|
## use #extend to extend a class
|
|
|
|
## using #class for both feels confusing.
|
|
|
|
|
|
|
|
extend Apex
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
extend SmallInteger
|
|
|
|
{
|
|
|
|
method getTrue: anInteger
|
|
|
|
{
|
|
|
|
^anInteger + 9999.
|
|
|
|
}
|
|
|
|
|
|
|
|
method inc
|
|
|
|
{
|
|
|
|
^self + 1.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class TestObject(Object)
|
|
|
|
{
|
2017-04-24 09:20:27 +00:00
|
|
|
var(#class) Q, R.
|
|
|
|
var(#classinst) a1, a2.
|
2017-01-09 12:52:37 +00:00
|
|
|
|
|
|
|
method test999
|
|
|
|
{
|
|
|
|
^self.Q
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class B.TestObject(Object)
|
|
|
|
{
|
2017-04-24 09:20:27 +00:00
|
|
|
var(#class) Q, R.
|
|
|
|
var(#classinst) a1, a2.
|
2017-01-09 12:52:37 +00:00
|
|
|
|
|
|
|
method test000
|
|
|
|
{
|
|
|
|
^self.Q
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pooldic ABC
|
|
|
|
{
|
2017-04-24 09:20:27 +00:00
|
|
|
KKK := 20.
|
2017-01-09 12:52:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class MyObject(TestObject)
|
|
|
|
{
|
|
|
|
method(#class) aaa_123
|
|
|
|
{
|
|
|
|
| v1 |
|
|
|
|
v1 := [
|
|
|
|
| k |
|
|
|
|
k := 99.
|
|
|
|
[
|
|
|
|
[
|
2017-04-24 09:20:27 +00:00
|
|
|
##[ Exception signal: 'simulated error' ] ensure: [('ensure 1 ' & (k asString)) dump ].
|
|
|
|
[ ^ 20 ] ensure: [ ('ensure 1 ' & (k asString)) dump. ].
|
2017-01-09 12:52:37 +00:00
|
|
|
] ensure: ['ensure 2' dump ].
|
|
|
|
] ensure: ['ensure 3' dump ].
|
|
|
|
] on: Exception do: [:ex |
|
2017-04-24 09:20:27 +00:00
|
|
|
('EXCETION - ' & ex messageText) dump.
|
2017-01-09 12:52:37 +00:00
|
|
|
## Exception signal: 'qqq'.
|
|
|
|
].
|
|
|
|
^v1
|
|
|
|
}
|
|
|
|
method(#class) main
|
|
|
|
{
|
|
|
|
| v1 |
|
|
|
|
'START OF MAIN' dump.
|
|
|
|
##[1 xxx] ifCurtailed: ['XXXXXXXX CURTAILED XXXXXXXXX' dump].
|
|
|
|
##['ENSURE TEST' dump] ensure: ['XXXXXXXXX ENSURE XXXXXXXXXXXXXx' dump].
|
|
|
|
|
|
|
|
##v1 := [ ['kkk' dump.] ensure: ['XXXXXXXXX ENSURE XXXXXXXXXXXXXx' dump. 30] ] on: Exception do: [:ex | 'EXCEPTION OUTSIDE ENSURE...' dump. ].
|
|
|
|
##v1 dump.
|
|
|
|
|
|
|
|
|
|
|
|
##[ Exception signal: 'simulated error' ] on: Exception do: [:ex | 'CAUGHT...' dump. Exception signal: 'jjjjjjj' ].
|
|
|
|
|
2017-04-24 09:20:27 +00:00
|
|
|
(*[
|
2017-01-09 12:52:37 +00:00
|
|
|
[ Exception signal: 'simulated error' ] ensure: ['ensure 1' dump ].
|
2017-04-24 09:20:27 +00:00
|
|
|
] on: Exception do: [:ex | ('EXCETION - ' & ex messageText) dump. Exception signal: 'qqq'. ].
|
2017-01-09 12:52:37 +00:00
|
|
|
|
2017-04-24 09:20:27 +00:00
|
|
|
[1 xxx] ifCurtailed: ['XXXXXXXX CURTAILED XXXXXXXXX' dump. Exception signal: 'jjjj']. *)
|
2017-01-09 12:52:37 +00:00
|
|
|
|
|
|
|
v1 := [
|
|
|
|
[
|
|
|
|
| k |
|
|
|
|
k := 99.
|
|
|
|
[
|
|
|
|
[
|
|
|
|
[ '@@@@@' dump.
|
|
|
|
Exception signal: 'simulated error'.
|
|
|
|
'^^^^^^' dump. ] ensure: [
|
2017-04-24 09:20:27 +00:00
|
|
|
('ensure 11 ' & (k asString)) dump.
|
2017-01-09 12:52:37 +00:00
|
|
|
Exception signal: 'qqq'.
|
|
|
|
].
|
|
|
|
|
|
|
|
##[ ^20 ] ensure: [('ensure 1 ', (k asString)) dump ].
|
|
|
|
|
|
|
|
'KKKKKKKKKKKKKKKKKKKK' dump.
|
|
|
|
] ensure: ['ensure 2' dump ].
|
|
|
|
|
|
|
|
'JJJJJJJJJJJJJJJJJJJJJJJJJJJ' dump.
|
|
|
|
] ensure: ['ensure 3' dump ].
|
|
|
|
] on: Exception do: [:ex |
|
2017-04-24 09:20:27 +00:00
|
|
|
('>>>> EXCETION - ' & ex messageText) dump.
|
2017-01-09 12:52:37 +00:00
|
|
|
ex pass.
|
|
|
|
|
|
|
|
##Exception signal: 'XXXXXXXXXXXXx'.
|
|
|
|
## ex return: 10.
|
|
|
|
## Exception signal: 'qqq'.
|
|
|
|
].
|
|
|
|
'ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ' dump.
|
|
|
|
]
|
|
|
|
on: PrimitiveFailureException do: [:ex |
|
2017-04-24 09:20:27 +00:00
|
|
|
('PRIMITIVE FAILURE EXCETION AT OUTER - ' & ex messageText) dump.
|
2017-01-09 12:52:37 +00:00
|
|
|
]
|
|
|
|
on: Exception do: [:ex |
|
2017-04-24 09:20:27 +00:00
|
|
|
('>>>> EXCETION AT OUTER - ' & ex messageText) dump.
|
2017-01-09 12:52:37 +00:00
|
|
|
].
|
|
|
|
|
|
|
|
|
|
|
|
## v1 := self aaa_123.
|
|
|
|
'--------------------------------' dump.
|
|
|
|
v1 dump.
|
|
|
|
'--------------------------------' dump.
|
|
|
|
'END OF MAIN' dump.
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|