Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Removed/changed senders of addPrototype:.

  • Loading branch information...
commit 963c98553aa36ee1daa85205006a7e59d9a3d2aa 1 parent 217708e
Brian T. Rice authored
2  src/core/collection.slate
... ... @@ -1,4 +1,4 @@
1   -collections addPrototype: #Collection derivedFrom: {Cloneable}.
  1 +collections definePrototype: #Collection &basis: Cloneable.
2 2 "The abstract object type for Collections, objects which other objects can be
3 3 added and removed and tested for as elements."
4 4
7 src/lib/heap.slate
... ... @@ -1,10 +1,9 @@
1   -
2   -collections addPrototype: #Heap derivedFrom: {SortedArray}.
  1 +collections definePrototype: #Heap &basis: SortedArray &doing: [
  2 + sortBlock := #< `er. "The block used for comparing items for sorting."
  3 +].
3 4 "A heap is a SortedArray of items.
4 5 It is more efficient than a standard SortedArray if elements are only
5 6 removed at the beginning, and elements are added in arbitrary sort order."
6   -Heap sortBlock := #< `er.
7   -"The block used for comparing items for sorting."
8 7
9 8 h@(Heap traits) push: obj
10 9 [
11 src/lib/random.slate
... ... @@ -1,12 +1,13 @@
1   -streams addPrototype: #RandomStream derivedFrom: {PositionableReadStream}.
  1 +streams define: #RandomStream &basis: PositionableReadStream &doing: [
  2 + #state := (Array newSize: 624).
  3 +"This array is used for the calculations and works as a kind of history buffer.
  4 +The particular size of the array corresponds to / is determined by the
  5 +desired range of the outputs. See the website for particulars when porting."
  6 +].
2 7 "Answers a series of pseudo-random positive SmallIntegers across the entire
3 8 value range. It is very fast and has an extremely long period (2^19937-1).
4 9 Based off the Mersenne Twister code in C at:
5 10 http://www.math.keio.ac.jp/~matumoto/emt.html"
6   -RandomStream addSlot: #state valued: (Array newSize: 624).
7   -"This array is used for the calculations and works as a kind of history buffer.
8   -The particular size of the array corresponds to / is determined by the
9   -desired range of the outputs. See the website for particulars when porting."
10 11
11 12 rs@(RandomStream traits) collectionType
12 13 [
6 src/ui/SDL/tests/evts.slate
... ... @@ -1,6 +1,4 @@
1   -prototypes addPrototype: #EventTest derivedFrom: {Cloneable}.
2   -
3   -EventTest addSlot: #fini valued: False.
  1 +prototypes define: #EventTest &slots: {#fini -> False}.
4 2
5 3 et@(EventTest traits) showEvents
6 4 [| evt evt_type |
@@ -65,4 +63,4 @@ _@(EventTest traits) showOther: event
65 63 inform: 'Some other event going on'.
66 64 ].
67 65
68   -EventTest showEvents.
  66 +EventTest showEvents.
2  tests/file.slate
... ... @@ -1,4 +1,4 @@
1   -UnitTests addPrototype: #File derivedFrom: {TestCase}.
  1 +UnitTests definePrototype: #File &basis: TestCase.
2 2 "Unit test for file functionality."
3 3
4 4 UnitTests File addSlot: #inputFileName valued: ('LICENSE' as: File Locator).
2  tests/mapoverlay.slate
... ... @@ -1,4 +1,4 @@
1   -UnitTests addPrototype: #MapOverlay derivedFrom: { TestCase }.
  1 +UnitTests definePrototype: #MapOverlay &basis: TestCase.
2 2
3 3 "Tests the MapOverlay class"
4 4
2  tests/regex.slate
... ... @@ -1,6 +1,6 @@
1 1 load: 'src/lib/regex.slate'.
2 2
3   -"UnitTests addPrototype: #Regex derivedFrom: {TestCase}.
  3 +"UnitTests definePrototype: #Regex &basis: TestCase.
4 4
5 5 tc@(UnitTests Regex traits) shouldMatch: string against: regex withMatches: c
6 6 [| matcher |
4 tests/regression/collection.slate
... ... @@ -1,4 +1,4 @@
1   -RegressionTests addPrototype: #CollectionHash derivedFrom: {TestCase}.
  1 +RegressionTests definePrototype: #CollectionHash &basis: TestCase.
2 2 "Checks whether hash value for collections with same elements is equal."
3 3
4 4 t@(RegressionTests CollectionHash traits) testCollection: c1 against: c2
@@ -40,7 +40,7 @@ t@(RegressionTests CollectionHash traits) suite
40 40 #testSequence.
41 41 }].
42 42
43   -RegressionTests addPrototype: #ExtSeqWriter derivedFrom: {TestCase}.
  43 +RegressionTests definePrototype: #ExtSeqWriter &basis: TestCase.
44 44 "Checks whether writer iterator of ExtensibleSequence is actually able to
45 45 extend the sequence."
46 46
10 tests/regression/wordcount.slate
... ... @@ -1,4 +1,4 @@
1   -RegressionTests addPrototype: #WordCount derivedFrom: {TestCase}.
  1 +RegressionTests definePrototype: #WordCount &basis: TestCase.
2 2 "A regression test playing with the LICENSE file"
3 3
4 4 t@(RegressionTests WordCount traits) testFileName
@@ -7,8 +7,8 @@ t@(RegressionTests WordCount traits) testFileName
7 7 ].
8 8
9 9 t@(RegressionTests WordCount traits) testWordCount
10   -[| words |
11   - words: Bag new.
  10 +[
  11 + words ::= Bag new.
12 12 (File newNamed: t testFileName &mode: File Read) sessionDo:
13 13 [| :file |
14 14 file reader split >> words writer.
@@ -20,11 +20,11 @@ t@(RegressionTests WordCount traits) testWordCount
20 20 t@(RegressionTests WordCount traits) testLineCount
21 21 "Note that empty lines will be ignored by #splitWith: "
22 22 [| lineCount |
23   - lineCount: 0.
  23 + lineCount := 0.
24 24 (File newNamed: t testFileName &mode: File Read) sessionDo:
25 25 [| :file |
26 26 (file reader splitWith: { $\n }) do:
27   - [| :line | lineCount: lineCount succ].
  27 + [| :line | lineCount += 1].
28 28 ].
29 29 "Console ; 'Number of lines ' ; (lineCount as: String) ; '\n'."
30 30 t assert: lineCount = 16 description: 'The number of lines found in the LICENSE file is not as expected.'.
3  tests/skiplist.slate
... ... @@ -1,5 +1,4 @@
1   -
2   -UnitTests addPrototype: #SkipList derivedFrom: {TestCase}.
  1 +UnitTests definePrototype: #SkipList &basis: TestCase.
3 2
4 3 tc@(UnitTests SkipList traits) isEmpty
5 4 [
120 tests/smartconsole.slate
@@ -8,57 +8,58 @@ CursesConsole traits lib: Nil.
8 8 Image save.
9 9 "
10 10
11   -UnitTests addPrototype: #SmartConsole derivedFrom: {Cloneable}.
  11 +UnitTests definePrototype: #SmartConsole.
12 12 "Not a real unit test, it's an object to dispatch on for a few
13 13 methods that test SmartConsole/Terminal functionality with human
14 14 interaction."
15 15
16 16 _@(UnitTests SmartConsole traits) streamedCommandProcessor
17 17 [
18   - SmartConsole new sessionDo: [| :console terminal editor reader |
19   - terminal: (Terminal newBasedOn: console).
20   - editor: terminal commandEditor.
21   - editor prompt: 'Prompt> '.
22   - reader: editor reader.
23   -
24   - terminal ; 'This test should echo all lines committed by enters, and exit if a \'q\' character is encountered'.
25   -
26   - [| char |
27   - char: reader next.
28   - terminal nextPut: char.
29   - "char printOn: terminal &radix: 16."
30   - terminal flush.
31   - char = $q
32   - ] whileFalse.
  18 + SmartConsole new sessionDo:
  19 + [| :console terminal editor reader |
  20 + terminal := Terminal newBasedOn: console.
  21 + editor := terminal commandEditor.
  22 + editor prompt := 'Prompt> '.
  23 + reader := editor reader.
  24 +
  25 + terminal ; 'This test should echo all lines committed by enters, and exit if a \'q\' character is encountered'.
  26 +
  27 + [| char |
  28 + char := reader next.
  29 + terminal nextPut: char.
  30 + "char printOn: terminal &radix: 16."
  31 + terminal flush.
  32 + char = $q] whileFalse
33 33 ].
34 34 ].
35 35
36 36 _@(UnitTests SmartConsole traits) commandProcessor
37 37 [
38   - SmartConsole new sessionDo: [| :console terminal editor |
39   - terminal: (Terminal newBasedOn: console).
40   - editor: terminal commandEditor.
41   - editor prompt: 'Prompt> '.
42   -
43   - terminal ; 'This test should echo lines ending with a dot and committed with enters; quit with the \'quit.\' command'.
44   - terminal newLine.
45   - console writer ; 'Also demonstrates editing at any column: '.
46   -
47   - [| line |
48   - [ line: editor readLine.
49   - ["console writeCursorPositionAt: (console width // 2) , (console height // 2)."
  38 + SmartConsole new sessionDo:
  39 + [| :console terminal editor |
  40 + terminal := (Terminal newBasedOn: console).
  41 + editor := terminal commandEditor.
  42 + editor prompt := 'Prompt> '.
  43 +
  44 + terminal ; 'This test should echo lines ending with a dot and committed with enters; quit with the \'quit.\' command'.
  45 + terminal newLine.
  46 + console writer ; 'Also demonstrates editing at any column: '.
  47 +
  48 + [| line |
  49 + [line := editor readLine.
  50 + ["console writeCursorPositionAt: (console width // 2) , (console height // 2)."
50 51 line size = 0 \/ [(line at: line indexLast) ~= $. ]]
51   - whileTrue: [line: (editor continue)].
  52 + whileTrue: [line := editor continue].
52 53
53   - terminal newLine.
54   - terminal ; '\'' ; line ; '\''.
55   - terminal newLine.
56   - terminal flush]
57   - on: Stream Exhaustion do: [| :_ |
58   - terminal ; '\nStream closed\n'].
  54 + terminal newLine.
  55 + terminal ; '\'' ; line ; '\''.
  56 + terminal newLine.
  57 + terminal flush]
  58 + on: Stream Exhaustion do: [| :_ |
  59 + terminal ; '\nStream closed\n'].
59 60
60   - line ~= Nil /\ [line = 'quit.']
61   - ] whileFalse.
  61 + line ~= Nil /\ [line = 'quit.']
  62 + ] whileFalse.
62 63 ].
63 64 ].
64 65
@@ -105,7 +106,7 @@ _@(UnitTests SmartConsole traits) draw
105 106
106 107 _@(UnitTests SmartConsole traits) echoEvent: event@(SmartConsole ResizeEvent traits) on: terminal
107 108 [| console |
108   - console: terminal console.
  109 + console := terminal console.
109 110 terminal ; 'Console resized to: ' ; (console width as: String) ; 'x' ; (console height as: String).
110 111 console clearToEOL.
111 112 terminal newLine.
@@ -114,7 +115,7 @@ _@(UnitTests SmartConsole traits) echoEvent: event@(SmartConsole ResizeEvent tra
114 115
115 116 _@(UnitTests SmartConsole traits) echoEvent: event@(SmartConsole KeyEvent traits) on: terminal
116 117 [| console |
117   - console: terminal console.
  118 + console := terminal console.
118 119 terminal ; 'Key code: ' ; (event keyCode as: String) ; ' - 16r' ;
119 120 (event keyCode printString &radix: 16).
120 121 console clearToEOL.
@@ -146,7 +147,7 @@ _@(UnitTests SmartConsole traits) echoEvent: event@(SmartConsole KeyEvent traits
146 147 t@(UnitTests SmartConsole traits) echoEvents
147 148 [
148 149 SmartConsole new sessionDo: [| :console terminal |
149   - terminal: (Terminal newBasedOn: console).
  150 + terminal := (Terminal newBasedOn: console).
150 151 terminal ; 'Press keys and their event will be printed, quit with Esc\n'.
151 152
152 153 [
@@ -159,42 +160,39 @@ t@(UnitTests SmartConsole traits) echoEvents
159 160 _@(UnitTests SmartConsole traits) echoRawCursesEvents
160 161 [
161 162 CursesConsole new sessionDo: [| :console terminal |
162   - terminal: (Terminal newBasedOn: console).
  163 + terminal := (Terminal newBasedOn: console).
163 164 terminal ; 'Press keys and raw key codes will be printed, quit with Enter\n'.
164 165
165   - [| keyCode |
166   - keyCode: (console primitives nextEvent applyTo: {-1}).
167   - terminal ; (keyCode as: String) ; ' - 16r' ;
168   - (keyCode printString &radix: 16).
169   - console clearToEOL.
170   - terminal newLine.
171   - keyCode = 10 \/ [keyCode = 13]
172   - ] whileFalse
  166 + [| keyCode |
  167 + keyCode := console primitives nextEvent apply*, -1.
  168 + terminal ; (keyCode as: String) ; ' - 16r' ; (keyCode printString &radix: 16).
  169 + console clearToEOL.
  170 + terminal newLine.
  171 + keyCode = 10 \/ [keyCode = 13]
  172 + ] whileFalse
173 173 ]
174 174 ].
175 175
176 176 _@(UnitTests SmartConsole traits) echoRawWindowsEvents &unicode: unicode
177 177 [| available |
178   - available: False.
179   - [WindowsConsole isAvailable ifTrue: [available: True]]
180   - breakOn: Error.
  178 + available := False.
  179 + [WindowsConsole isAvailable ifTrue: [available := True]] breakOn: Error.
181 180 available ifFalse: [error: 'Windows console plugin not loaded or otherwise not available'. ^ Nil].
182   - unicode ifNil: [unicode: False].
  181 + unicode `defaultsTo: False.
183 182
184 183 WindowsConsole clone sessionDo: [| :c record dword |
185 184 c ; 'Printing out raw console events coming from Windows, quit with Esc\n'.
186 185 c ; 'Codepage returned by GetConsoleCP: ' ; Windows Kernel GetConsoleCP do printString ; '\n'.
187 186
188   - record: Windows INPUT_RECORD clone.
189   - dword: (ByteArray new &capacity: #[Windows DWORD byteSize]).
  187 + record := Windows INPUT_RECORD clone.
  188 + dword := ByteArray new &capacity: #[Windows DWORD byteSize].
190 189 [
191 190 [| method |
192   - unicode
193   - ifTrue: [method: Windows Kernel ReadConsoleInputW]
194   - ifFalse: [method: Windows Kernel ReadConsoleInputA].
195   - method applyTo: {c consoleIn. record. 1. dword}.
196   - record EventType = #[Windows KEY_EVENT]
197   - ] whileFalse.
  191 + method := unicode
  192 + ifTrue: [Windows Kernel ReadConsoleInputW]
  193 + ifFalse: [Windows Kernel ReadConsoleInputA].
  194 + method apply*, c consoleIn, record, 1, dword.
  195 + record EventType = #[Windows KEY_EVENT]] whileFalse.
198 196
199 197 "record printOn: c writer.
200 198 c newLine."

0 comments on commit 963c985

Please sign in to comment.
Something went wrong with that request. Please try again.