moo/stix/kernel/test-007.st

99 lines
1.9 KiB
Smalltalk
Raw Normal View History

2016-03-28 13:27:03 +00:00
#include 'Stix.st'.
#################################################################
## 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
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
{
dcl(#class) Q R.
dcl(#classinst) t1 t2.
2016-03-28 13:27:03 +00:00
}
class MyObject(TestObject)
2016-03-28 13:27:03 +00:00
{
dcl(#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).
p2 := [ :a :b :c :d | a dump. b dump. a dump. b dump. (c + d) dump. ^10000 ] newProcessWith: #(
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
1000000000000000
299999999999999999999999999999999999999999
).
p resume.
p2 resume.
'MIDDLE OF MAIN' dump.
Processor activeProcess terminate.
##p terminate.
'999999999999999999' dump.
'999999999999999999' dump.
'999999999999999999' dump.
'999999999999999999' dump.
'999999999999999999' dump.
'999999999999999999' dump.
'999999999999999999' dump.
## p resume.
'999999999999999999' dump.
'999999999999999999' dump.
'999999999999999999' dump.
'END OF MAIN' dump.
}
}