From e52fe398c7135871a54e6aa35fe674906898399b Mon Sep 17 00:00:00 2001 From: "hyunghwan.chung" Date: Mon, 28 Mar 2016 13:27:03 +0000 Subject: [PATCH] added some test scripts --- stix/kernel/test-001.st | 68 ++++++++++++++++++++++++++ stix/kernel/test-002.st | 87 +++++++++++++++++++++++++++++++++ stix/kernel/test-003.st | 56 +++++++++++++++++++++ stix/kernel/test-004.st | 57 +++++++++++++++++++++ stix/kernel/test-006.st | 105 +++++++++++++++++++++++++++++++++++++++ stix/kernel/test-007.st | 98 +++++++++++++++++++++++++++++++++++++ stix/kernel/test-008.st | 60 +++++++++++++++++++++++ stix/kernel/test-009.st | 65 ++++++++++++++++++++++++ stix/kernel/test-010.st | 106 ++++++++++++++++++++++++++++++++++++++++ stix/kernel/test-011.st | 44 +++++++++++++++++ 10 files changed, 746 insertions(+) create mode 100644 stix/kernel/test-001.st create mode 100644 stix/kernel/test-002.st create mode 100644 stix/kernel/test-003.st create mode 100644 stix/kernel/test-004.st create mode 100644 stix/kernel/test-006.st create mode 100644 stix/kernel/test-007.st create mode 100644 stix/kernel/test-008.st create mode 100644 stix/kernel/test-009.st create mode 100644 stix/kernel/test-010.st create mode 100644 stix/kernel/test-011.st diff --git a/stix/kernel/test-001.st b/stix/kernel/test-001.st new file mode 100644 index 0000000..a0f6934 --- /dev/null +++ b/stix/kernel/test-001.st @@ -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. + } + +} diff --git a/stix/kernel/test-002.st b/stix/kernel/test-002.st new file mode 100644 index 0000000..06d0ff7 --- /dev/null +++ b/stix/kernel/test-002.st @@ -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. + } + +} diff --git a/stix/kernel/test-003.st b/stix/kernel/test-003.st new file mode 100644 index 0000000..fa0ef3a --- /dev/null +++ b/stix/kernel/test-003.st @@ -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. + } + +} diff --git a/stix/kernel/test-004.st b/stix/kernel/test-004.st new file mode 100644 index 0000000..3899fd7 --- /dev/null +++ b/stix/kernel/test-004.st @@ -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. + } + +} diff --git a/stix/kernel/test-006.st b/stix/kernel/test-006.st new file mode 100644 index 0000000..5a8ee94 --- /dev/null +++ b/stix/kernel/test-006.st @@ -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. + } + +} diff --git a/stix/kernel/test-007.st b/stix/kernel/test-007.st new file mode 100644 index 0000000..2ad0084 --- /dev/null +++ b/stix/kernel/test-007.st @@ -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. + } + +} diff --git a/stix/kernel/test-008.st b/stix/kernel/test-008.st new file mode 100644 index 0000000..29078c4 --- /dev/null +++ b/stix/kernel/test-008.st @@ -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. + } + +} diff --git a/stix/kernel/test-009.st b/stix/kernel/test-009.st new file mode 100644 index 0000000..be36d26 --- /dev/null +++ b/stix/kernel/test-009.st @@ -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. + } + +} diff --git a/stix/kernel/test-010.st b/stix/kernel/test-010.st new file mode 100644 index 0000000..08c62c4 --- /dev/null +++ b/stix/kernel/test-010.st @@ -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. + ] + } +} diff --git a/stix/kernel/test-011.st b/stix/kernel/test-011.st new file mode 100644 index 0000000..395b7eb --- /dev/null +++ b/stix/kernel/test-011.st @@ -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 ]. + } +}