moo/kernel/test-012.moo

144 lines
2.9 KiB
Smalltalk
Raw Normal View History

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