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

test[sharing] S8-S8 03 series

Prerequisites

"Ensure Stringifier is present"
Smalltalk at: #Stringifier ifAbsent: [
	U8 require: 'u8:aleReimondo/sharing/Stringifier.st.js'.
	Smalltalk at: #Stringifier ifAbsent: [
		self print: 'Requires Stringifier. Aborting tests'.
		self abort
	]
]!


Tests for multiple objects (in a series).


"Read objects in a series"
| series objectifier sample object tag point tab stringifier |
tag := Stringifier new tagStart.
sample := #( 100 200 300 400 500 600 700.7 ) ,(Array with: #x with: nil with: tag with: tag ,#hello).
point := 700 @ sample.
sample at: 1 put: (Array with: sample with: point with: $A with: Object selectors asSet).
sample at: 2 put: point.
sample at: 3 put: (Association key: 'hello
world / crude',9 asCharacter,'world ',8 asCharacter ,200 asCharacter value: sample).
sample at: 4 put: String.
sample at: 5 put: tag,tag,tag.

self print: 'Stringifying Series...'.
stringifier := Stringifier to: #S8.
series := sample collect: [:each| stringifier literalFor: each ].
stringifier close.

self print: 'Objectifying series...'.
objectifier := Objectifier new.
sample := series collect: [:literal| objectifier objectFrom: literal ].

self print: 'Verifying...'.
sample isArray ifFalse: [ self error: 'Must be Array' ].
sample first first = sample ifFalse: [ self error: '1.1.- Must be sample' ].
sample first second x = 700 ifFalse: [ self error: '1.2.- Must be Point x 700' ].
sample first second y = sample ifFalse: [ self error: '1.2.- Must be Point y = sample' ].
sample first third = $A ifFalse: [ self error: '1.3.- Must be $A' ].
(sample first fourth isKindOf: Set) ifFalse: [ self error: '1.4.- Must be a Set' ].
(sample first fourth includes: #yourself) ifFalse: [ self error: '1.4.- #yourself must be present' ].
(sample second isKindOf: Point) ifFalse: [ self error: '2.- Must be aPoint' ].
sample second x = 700 ifFalse: [ self error: '2.1.- Must be Point x 700' ].
sample second y = sample ifFalse: [ self error: '2.2.- Must be Point y = sample' ].
(sample third isKindOf: Association) ifFalse: [ self error: '3.- Must be anAssociation' ].
(sample third key isKindOf: String) ifFalse: [ self error: '3.1.- key must be aString' ].
object := sample third.
(object key includes: 8 asCharacter) ifFalse: [ self error: '3.1.1.- Bs must be included' ].
object key last asciiValue = 200 ifFalse: [ self error: '3.1.2.- Character 200 must be included' ].
(object key indexOf: $/) = 14 ifFalse: [ self error: '3.1.3.- $/ must be at index 14' ].
object value = sample ifFalse: [ self error: '3.2.- Value must be sample' ].
sample fourth = String ifFalse: [ self error: '4.- Must be String' ].
(sample at: 6) = 600 ifFalse: [ self error: '6.- Must be 600' ].
(sample at: 7) = 700.7 ifFalse: [ self error: '7.- Must be 700.7' ].
(sample at: 8) = #x ifFalse: [ self error: '8.- Must be #x' ].
(sample at: 9) isNil ifFalse: [ self error: '9.- Must be nil' ].
(sample at: 10) ,#hello = (sample at: 11) ifFalse: [ self error: '10.- Wrong contents at 10&11' ].
self print: #Ok