[View]  [Edit]  [Lock]  [References]  [Attachments]  [History]  [Home]  [Changes]  [Search]  [Help] 

test[py8] 40

.
self running: 'PoolDictionary tests...'
PoolDictionary new notNil
PoolDictionary new isEmpty
PoolDictionary new keys isEmpty
T := PoolDictionary new. ^T notNil
T isEmpty
T at: #hello put: 1. ^T size = 1
T at: #hello put: #world. ^(T at: #hello ifAbsent: []) = #world
(T at: #two put: 2) = 2
T keys size = 2
T removeKey: #hello. ^T notEmpty
T includesKey: #two
T at: #two put: 2. ^(T at: #two) = 2
T removeKey: #two. ^T isEmpty
Smalltalk removeKey: #T ifAbsent: [^false]. ^(Smalltalk includesKey: #T) not
| p | p := PoolDictionary new. p at: #x put: #x. ^(p at: #x) = #x
| p | p := PoolDictionary new. p at: #x put: #x. ^(p at: #y ifAbsent: [#x]) = #x

self running: 'HashedSet tests...'
HashedSet new notNil
HashedSet new isEmpty
T := HashedSet with: #hello with: #world. T remove: #hello.T remove: #world. ^T isEmpty
T := HashedSet new. ^T notNil
T isEmpty
T add: #hello. ^T size = 1
T add: #hello; add: #world. ^T includes: #hello
T size = 2
T remove: #hello. ^T notEmpty
T includes: #world
T remove: #world. ^T isEmpty
T add: #two. ^T size = 1
T remove: #two. ^T isEmpty
Smalltalk removeKey: #T ifAbsent: [^false]. ^(Smalltalk includesKey: #T) not

self running: 'Stream tests...'
| stream | stream := '' writeStream. stream nextPutAll: #hello; nextPutAll: ' world'. ^stream contents = 'hello world'
('hello world' stream upTo: $ ) = #hello
#hello stream nextLine; atEnd

self running: 'String tests...'
#hello size = 5
('hello world' upTo: $ ) = #hello
'hello world' asArrayOfSubstrings = #(hello world)
#hello ,#world = #helloworld