--- a/RegressionTests__BinaryIOTests.st Thu Mar 10 13:14:51 2016 +0100
+++ b/RegressionTests__BinaryIOTests.st Thu Mar 10 13:27:15 2016 +0100
@@ -392,8 +392,12 @@
testSaveReadBOS
- |obj fn bos child privateClass didConvert|
+ |objStored childStored childrenStored objLoaded childrenLoaded childLoaded
+ fn bos privateClass didConvert verbose|
+ verbose := false.
+ verbose := true.
+
Class withoutUpdatingChangesDo:[
HierarchicalItem subclass:#XHierarchicalItem
instanceVariableNames:''
@@ -404,26 +408,38 @@
privateClass := Smalltalk at:#XHierarchicalItem.
].
- obj := privateClass new.
- child := privateClass new.
- obj add: child.
- child instVarNamed:#width put:privateClass.
+ objStored := privateClass new.
+ childStored := privateClass new.
+ objStored add: childStored.
+ childStored instVarNamed:#width put:privateClass.
+ self assert:(objStored hasChildren).
+ self assert:(objStored children size == 1).
+ self assert:(objStored children first == childStored).
+
"/ fn := '/tmp/HI' asFilename.
fn := Filename newTemporary.
bos := BinaryObjectStorage onNew: (fn writeStream).
- bos nextPut: obj.
+ bos nextPut: objStored.
- Stdout showCR:'object saved:'.
- "/ obj inspect.
- ObjectMemory dumpObject:obj.
+ verbose ifTrue:[
+ Transcript showCR:'object saved:'.
+ "/ obj inspect.
+ ObjectMemory dumpObject:objStored.
+ ].
bos close.
didConvert := false.
- "/ now, change the class (store object is old)
+ "/ now, change the class (stored object is old)
Class withoutUpdatingChangesDo:[
- privateClass addInstVarName:'foo'
+ verbose ifTrue:[
+ Transcript showCR:'changing the class (add a slot)...'.
+ ].
+ privateClass addInstVarName:'foo'.
+ verbose ifTrue:[
+ Transcript showCR:'done.'.
+ ].
].
bos := BinaryObjectStorage onOld: fn readStream.
@@ -432,7 +448,9 @@
newClass := ex parameter key.
oldObject := ex parameter value.
- Stdout showCR: 'converting...'.
+ verbose ifTrue:[
+ Transcript showCR: 'converting...'.
+ ].
didConvert := true.
ex proceedWith: (newClass cloneFrom: oldObject).
] do:[
@@ -442,19 +460,27 @@
newClass := Smalltalk at: ex2 parameter name asSymbol.
oldClass := ex2 parameter.
- Transcript showCR: 'will convert instance of ',oldClass name.
+ verbose ifTrue:[
+ Transcript showCR: 'will convert instance of ',oldClass name.
+ ].
proceedClass :=(((newClass isSubclassOf: HierarchicalItem) or:[newClass == HierarchicalItem]) ifTrue:[newClass] ifFalse:[oldClass]).
ex2 proceedWith: proceedClass.
] do:[
- obj := bos next.
- "/ obj inspect.
- Stdout showCR:'object restored (new class):'.
- ObjectMemory dumpObject:obj.
+ objLoaded := bos next.
+ verbose ifTrue:[
+ "/ obj inspect.
+ Transcript showCR:'object restored (new class):'.
+ ObjectMemory dumpObject:objLoaded.
+ ].
].
].
self assert:(didConvert).
- self assert:(obj class instSize == (HierarchicalItem instSize + 1)).
+ self assert:(objLoaded class instSize == (HierarchicalItem instSize + 1)).
+
+ self assert:(objLoaded hasChildren).
+ self assert:(objLoaded children size == 1).
+ self assert:(objLoaded children == (objLoaded instVarNamed:#children) ).
"Created: / 26-09-2007 / 18:21:11 / cg"
"Modified: / 07-08-2011 / 15:29:35 / cg"