moo/kernel/test-007.moo

99 lines
1.9 KiB
Smalltalk
Raw Permalink Normal View History

2016-03-28 13:27:03 +00:00
2017-01-09 12:52:37 +00:00
#include 'Moo.moo'.
2016-03-28 13:27:03 +00:00
////////////////////////////////////////////////////////////////#
// MAIN
////////////////////////////////////////////////////////////////#
2016-03-28 13:27:03 +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.
2016-03-28 13:27:03 +00:00
extend Apex
2016-03-28 13:27:03 +00:00
{
}
extend SmallInteger
2016-03-28 13:27:03 +00:00
{
method getTrue: anInteger
2016-03-28 13:27:03 +00:00
{
^anInteger + 9999.
}
method inc
2016-03-28 13:27:03 +00:00
{
^self + 1.
}
}
class TestObject(Object)
2016-03-28 13:27:03 +00:00
{
var(#class) Q, R.
var(#classinst) t1, t2.
2016-03-28 13:27:03 +00:00
}
class MyObject(TestObject)
2016-03-28 13:27:03 +00:00
{
var(#class) C, B, A.
2016-03-28 13:27:03 +00:00
method getTrue
2016-03-28 13:27:03 +00:00
{
^true.
}
method getTrue: anInteger
2016-03-28 13:27:03 +00:00
{
^ anInteger
}
method getFalse
2016-03-28 13:27:03 +00:00
{
^false
}
method a { ^ 10 }
method b { ^ 20 }
method c { ^ 30 }
2016-03-28 13:27:03 +00:00
method(#class) a: a b: b c: c
2016-03-28 13:27:03 +00:00
{
^ a + b + c.
}
method(#class) main
2016-03-28 13:27:03 +00:00
{
| p p2 |
'START OF MAIN' dump.
//p := [ :a :b :c :d | a dump. b dump. (c + d) dump. ^10. ] newProcessWith: #(#abc #def 10 20).
p := [ :a :b :c :d | a dump. b dump. (c + d) dump. ] newProcessWith: #(#abc #def 10 20).
2016-03-28 13:27:03 +00:00
p2 := [ :a :b :c :d | a dump. b dump. a dump. b dump. (c + d) dump. ^10000 ] newProcessWith: #(
#AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
#BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
2016-03-28 13:27:03 +00:00
1000000000000000
299999999999999999999999999999999999999999
).
p resume.
p2 resume.
'MIDDLE OF MAIN' dump.
Processor activeProcess terminate.
//p terminate.
2016-03-28 13:27:03 +00:00
'999999999999999999' dump.
'999999999999999999' dump.
'999999999999999999' dump.
'999999999999999999' dump.
'999999999999999999' dump.
'999999999999999999' dump.
'999999999999999999' dump.
// p resume.
2016-03-28 13:27:03 +00:00
'999999999999999999' dump.
'999999999999999999' dump.
'999999999999999999' dump.
'END OF MAIN' dump.
}
}