removed send_message_with_str(), find_method_with_str()

registered some commonly used method names as symbols - doesNotUnderstand:, unwindTo:return:, primitiveFailed
invocation of the above methods doesn't need send_message_with_str()
changed startup method invocation to look up for a symbol first instead of using the above functions removed
This commit is contained in:
hyunghwan.chung
2019-06-23 04:49:38 +00:00
parent ae20171772
commit 3419097054
5 changed files with 124 additions and 155 deletions

View File

@ -8,6 +8,53 @@
class MyObject(Object)
{
var(#class) a := 100.
var(#class) ensure_tester_v := 0.
method(#class) test_quicksort: anArray
{
| quicksort |
quicksort := nil.
quicksort := [ :data :from :to |
(from < to)
ifTrue: [ | pivot index |
pivot := data at: from.
data swap: from with: to.
index := from.
from to: (to - 1) do: [ :each |
(data at: each) < pivot
ifTrue: [
data swap: each with: index.
index := index + 1
]
].
data swap: to with: index.
quicksort value: data value: from value: index - 1.
quicksort value: data value: index + 1 value: to
].
data
].
^(quicksort value: anArray value: 0 value: (anArray size - 1))
}
method(#class) test_on_do_with: dividend with: divisor
{
## it returns 0 upon an exception otherwise, division result.
^[ dividend div: divisor ] on: Exception do: [:ex | 0 ]
}
method(#class) test_ensure_with: v
{
[
[ Exception signal: "test ensure exception" ] ensure: [ self.ensure_tester_v := v ].
] on: Exception do: [:ex | /* do nothing */ ].
}
method(#class) test_ensure2_with: v
{
[ ^v * v ] ensure: [ self.ensure_tester_v := v ].
}
method(#class) proc1
{
@ -103,48 +150,27 @@ class MyObject(Object)
}
*/
method(#class) test_quicksort: anArray
{
| quicksort |
quicksort := nil.
quicksort := [ :data :from :to |
(from < to)
ifTrue: [ | pivot index |
pivot := data at: from.
data swap: from with: to.
index := from.
from to: (to - 1) do: [ :each |
(data at: each) < pivot
ifTrue: [
data swap: each with: index.
index := index + 1
]
].
data swap: to with: index.
quicksort value: data value: from value: index - 1.
quicksort value: data value: index + 1 value: to
].
data
].
^(quicksort value: anArray value: 0 value: (anArray size - 1))
}
method(#class) main
{
| tc limit |
tc := %(
## 0 - 4
[ (self test_quicksort: #(7 12 3 20 5 8 2) copy) = #(2 3 5 7 8 12 20)],
[ (self test_quicksort: %(99, 12, 18, 7, 12, 3, 20, 5, 8, 2)) = #(2 3 5 7 8 12 12 18 20 99)],
[ (self test_on_do_with: 10 with: 2) == 5 ],
[ (self test_on_do_with: -10 with: 0) == 0 ],
[ self test_ensure_with: -20945. self.ensure_tester_v == -20945 ],
## 5-9
[ ((self test_ensure2_with: 8) == 64) and: [self.ensure_tester_v == 8] ],
[ self proc1 == 100 ],
[ System sleepForSecs: 2. self proc1 == 200 ],
[ self test_semaphore_heap == true ],
[ self test_mutex = #(2000 6000) ],
####[ self test_sem_sig ],
[ (self test_quicksort: #(7 12 3 20 5 8 2) copy) = #(2 3 5 7 8 12 20)],
[ (self test_quicksort: %(99, 12, 18, 7, 12, 3, 20, 5, 8, 2)) = #(2 3 5 7 8 12 12 18 20 99)],
## 10-14
####[ self test_sem_sig ],
[ System sleepForSecs: 2. self.a == 300 ] ## sleep before checking self.a to prevent different result depending on process switching frequency and speed
).