added some test scripts

This commit is contained in:
hyunghwan.chung 2016-03-28 13:27:03 +00:00
parent 77f0bfad5d
commit e52fe398c7
10 changed files with 746 additions and 0 deletions

68
stix/kernel/test-001.st Normal file
View File

@ -0,0 +1,68 @@
#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
{
}
#extend SmallInteger
{
#method getTrue: anInteger
{
^anInteger + 9999.
}
#method inc
{
^self + 1.
}
}
#class TestObject(Object)
{
#dcl(#class) Q R.
#dcl(#classinst) a1 a2.
}
#class MyObject(TestObject)
{
#declare(#classinst) t1 t2.
#method(#class) xxxx
{
| g1 g2 |
t1 dump.
t2 := [ g1 := 50. g2 := 100. ^g1 + g2 ].
(t1 < 100) ifFalse: [ ^self ].
t1 := t1 + 1.
^self xxxx.
}
#method(#class) zzz
{
'zzzzzzzzzzzzzzzzzz' dump.
^self.
}
#method(#class) yyy
{
^[123456789 dump. ^200].
}
#method(#class) main
{
'START OF MAIN' dump.
['1111111' dump. '111111111' dump. '22222222222' dump.
'3333333' dump. '444444444' dump. '55555555555' dump] newProcess resume.
'EDN OF MAIN' dump.
}
}

87
stix/kernel/test-002.st Normal file
View File

@ -0,0 +1,87 @@
#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
{
}
#extend SmallInteger
{
#method getTrue: anInteger
{
^anInteger + 9999.
}
#method inc
{
^self + 1.
}
}
#class TestObject(Object)
{
#dcl(#class) Q R.
#dcl(#classinst) a1 a2.
}
#class MyObject(TestObject)
{
#declare(#classinst) t1 t2.
#method(#class) xxxx
{
| g1 g2 |
t1 dump.
t2 := [ g1 := 50. g2 := 100. ^g1 + g2 ].
(t1 < 100) ifFalse: [ ^self ].
t1 := t1 + 1.
^self xxxx.
}
#method(#class) zzz
{
'zzzzzzzzzzzzzzzzzz' dump.
^self.
}
#method(#class) yyy
{
^[123456789 dump. ^200].
}
#method(#class) main2
{
'START OF MAIN2' dump.
##[thisContext dump. ^100] newProcess resume.
[ |k| thisContext dump. self zzz. "k := self yyy. k value." ['ok' dump. ^100] value] newProcess resume.
'1111' dump.
'1111' dump.
'1111' dump.
'1111' dump.
'1111' dump.
'EDN OF MAIN2' dump.
}
#method(#class) main1
{
'START OF MAIN1' dump.
self main2.
'END OF MAIN1' dump.
}
#method(#class) main
{
'START OF MAIN' dump.
self main1.
'EDN OF MAIN' dump.
}
}

56
stix/kernel/test-003.st Normal file
View File

@ -0,0 +1,56 @@
#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
{
}
#extend SmallInteger
{
#method getTrue: anInteger
{
^anInteger + 9999.
}
#method inc
{
^self + 1.
}
}
#class TestObject(Object)
{
#dcl(#class) Q R.
#dcl(#classinst) a1 a2.
}
#class MyObject(TestObject)
{
#declare(#classinst) t1 t2.
#method(#class) xxxx
{
| g1 g2 |
t1 dump.
t2 := [ g1 := 50. g2 := 100. ^g1 + g2 ].
(t1 < 100) ifFalse: [ ^self ].
t1 := t1 + 1.
^self xxxx.
}
#method(#class) main
{
'START OF MAIN' dump.
'EDN OF MAIN' dump.
}
}

57
stix/kernel/test-004.st Normal file
View File

@ -0,0 +1,57 @@
#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
{
}
#extend SmallInteger
{
#method getTrue: anInteger
{
^anInteger + 9999.
}
#method inc
{
^self + 1.
}
}
#class TestObject(Object)
{
#dcl(#class) Q R.
#dcl(#classinst) a1 a2.
}
#class MyObject(TestObject)
{
#declare(#classinst) t1 t2.
#method(#class) xxxx
{
| g1 g2 |
t1 dump.
t2 := [ g1 := 50. g2 := 100. ^g1 + g2 ].
(t1 < 100) ifFalse: [ ^self ].
t1 := t1 + 1.
^self xxxx.
}
#method(#class) main
{
'START OF MAIN' dump.
Processor activeProcess terminate.
'EDN OF MAIN' dump.
}
}

105
stix/kernel/test-006.st Normal file
View File

@ -0,0 +1,105 @@
#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
{
}
#extend SmallInteger
{
#method getTrue: anInteger
{
^anInteger + 9999.
}
#method inc
{
^self + 1.
}
}
#class TestObject(Object)
{
#dcl(#class) Q R.
#dcl(#classinst) t1 t2.
}
#class MyObject(TestObject)
{
#dcl(#class) C B A.
#method getTrue
{
^true.
}
#method getTrue: anInteger
{
^ anInteger
}
#method getFalse
{
^false
}
#method a { ^ 10 }
#method b { ^ 20 }
#method c { ^ 30 }
#method(#class) a: a b: b c: c
{
^ a + b + c.
}
#method(#class) getBlock
{
| a |
a := 7777777.
"
^[1 + [^a]].
1234567 dump.
"
^[self a: a b: 3 c: ([[[^6] value] value ] value)].
}
#method(#class) main
{
"
| k |
k := 30.
k := k + 10; + 20.
k dump.
(self a: 1 b: 2 c: 3) dump.
[self a: 1 b: 2 c: 3] value dump.
[self a: 1 b: 2 c: 3] value dump.
[self a: 9 b: 10 c: 11] value dump.
((k = 2) ifTrue: [11111] ifFalse: [2222])dump.
self getBlock value dump.
[10 + [^20]] value dump.
"
'START OF MAIN' dump.
[2 + 3 + 1 + [[[^6] value] value ] value] value dump.
## ^(self a: (self new a) b: ([:a :b | a + b] value: 10 value: 20) c: (self new c)) dump.
##self getBlock value dump.
'END OF MAIN' dump.
}
}

98
stix/kernel/test-007.st Normal file
View File

@ -0,0 +1,98 @@
#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
{
}
#extend SmallInteger
{
#method getTrue: anInteger
{
^anInteger + 9999.
}
#method inc
{
^self + 1.
}
}
#class TestObject(Object)
{
#dcl(#class) Q R.
#dcl(#classinst) t1 t2.
}
#class MyObject(TestObject)
{
#dcl(#class) C B A.
#method getTrue
{
^true.
}
#method getTrue: anInteger
{
^ anInteger
}
#method getFalse
{
^false
}
#method a { ^ 10 }
#method b { ^ 20 }
#method c { ^ 30 }
#method(#class) a: a b: b c: c
{
^ a + b + c.
}
#method(#class) main
{
| 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.
}
}

60
stix/kernel/test-008.st Normal file
View File

@ -0,0 +1,60 @@
#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
{
}
#extend SmallInteger
{
#method getTrue: anInteger
{
^anInteger + 9999.
}
#method inc
{
^self + 1.
}
}
#class TestObject(Object)
{
#dcl(#class) Q R.
#dcl(#classinst) a1 a2.
}
#class MyObject(TestObject)
{
#declare(#classinst) t1 t2.
#method(#class) xxxx
{
| g1 g2 |
t1 dump.
t2 := [ g1 := 50. g2 := 100. ^g1 + g2 ].
(t1 < 10) ifFalse: [ ^self ].
t1 := t1 + 1.
^self xxxx.
}
#method(#class) main
{
t1 := 1.
self xxxx.
'END OF XXX' dump.
t2 := t2 value.
'END OF t2 value' dump.
t2 dump.
}
}

65
stix/kernel/test-009.st Normal file
View File

@ -0,0 +1,65 @@
#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
{
}
#extend SmallInteger
{
#method getTrue: anInteger
{
^anInteger + 9999.
}
#method inc
{
^self + 1.
}
}
#class TestObject(Object)
{
#dcl(#class) Q R.
#dcl(#classinst) a1 a2.
}
#class MyObject(TestObject)
{
#declare(#classinst) t1 t2.
#method(#class) main2
{
'START OF MAIN2' dump.
t1 value.
'END OF MAIN2' dump.
}
#method(#class) main1
{
'START OF MAIN1' dump.
self main2.
t2 := [ 'BLOCK #2' dump. ^200].
'END OF MAIN1' dump.
}
#method(#class) main
{
'START OF MAIN' dump.
t1 := ['BLOCK #1' dump. ^100].
self main1.
'END OF MAIN' dump.
}
}

106
stix/kernel/test-010.st Normal file
View File

@ -0,0 +1,106 @@
#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
{
}
#extend SmallInteger
{
#method getTrue: anInteger
{
^anInteger + 9999.
}
#method inc
{
^self + 1.
}
}
#class TestObject(Object)
{
#dcl(#class) Q R.
#dcl(#classinst) a1 a2.
}
#class MyObject(TestObject)
{
#method(#class) main111
{
| s3 |
s3 := Semaphore new.
Processor signal: s3 after: 1 and: 50.
s3 wait.
'END OF MAIN' dump.
}
#method(#class) main
{
|t1 t2 s1 s2 s3|
'START OF MAIN' dump.
s1 := Semaphore new.
s2 := Semaphore new.
s3 := Semaphore new.
t1 := [
10 timesRepeat: ['BLOCK #1' dump. Processor activeProcess sleep: 1.].
s1 signal
] newProcess.
t2 := [ 5 timesRepeat: ['BLOCK #2' dump]. s2 signal. ] newProcess.
t1 resume.
t2 resume.
Processor signal: s3 after: 10.
'STARTED t1 and t2' dump.
s1 wait.
s2 wait.
##Processor unsignal: s3.
s3 wait.
10 timesRepeat: ['WAITED t1 and t2' dump].
'END OF MAIN' dump.
}
#method(#class) test_semaphore_heap
{
| sempq a |
sempq := SemaphoreHeap new.
'--------------------------' dump.
1 to: 200 by: 1 do: [ :i |
| sem |
sem := Semaphore new.
sem fireTime: (200 - i).
sempq insert: sem
].
'--------------------------' dump.
sempq deleteAt: 40.
sempq deleteAt: 50.
[sempq size > 0] whileTrue: [
| sem |
sem := sempq popTop.
sem fireTime dump.
]
}
}

44
stix/kernel/test-011.st Normal file
View File

@ -0,0 +1,44 @@
#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
{
}
#extend SmallInteger
{
#method getTrue: anInteger
{
^anInteger + 9999.
}
#method inc
{
^self + 1.
}
}
#class TestObject(Object)
{
#dcl(#class) Q R.
#dcl(#classinst) a1 a2.
}
#class MyObject(TestObject)
{
#method(#class) main
{
['this is test-011' dump. Exception signal. ] on: Exception do: [ :ex | 'Exception occurred' dump ].
}
}