<html><head></head><body bgcolor="#FFFFFF"><div>Do I understand correctly that this test just shows that you can use a ByteArray to store ints in a endian aware way? If so, why did Andreas use -1, which wouldn't show an endian reversal?<br><br>frank</div><div><br>On 04 Nov 2013, at 22:04, Nicolas Cellier &lt;<a href="mailto:nicolas.cellier.aka.nice@gmail.com">nicolas.cellier.aka.nice@gmail.com</a>&gt; wrote:<br><br></div><div></div><blockquote type="cite"><div><div dir="ltr">Beside the form, isn't -1 a palindrome? (if you reverse bit/bytes you still get -1, so it's a poor value)<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/11/4 Frank Shearar <span dir="ltr">&lt;<a href="mailto:frank.shearar@gmail.com" target="_blank">frank.shearar@gmail.com</a>&gt;</span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I really hate just having the lines under test just lying around like this:<br>
<br>
testByteArrayLongAt<br>
&nbsp; &nbsp; | ba value |<br>
<div class="im">&nbsp; &nbsp; ba := ByteArray new: 4.<br>
</div>&nbsp; &nbsp; value := -1.<br>
&nbsp; &nbsp; ba longAt: 1 put: value bigEndian: true.<br>
<div class="im">&nbsp; &nbsp; self assert: (ba longAt: 1 bigEndian: true) = value.<br>
</div>&nbsp; &nbsp; ba longAt: 1 put: value bigEndian: false.<br>
<div class="im">&nbsp; &nbsp; self assert: (ba longAt: 1 bigEndian: false) = value.<br>
<br>
</div>I mean, it'd get the job done. Any better ideas?<br>
<br>
frank<br>
<br>
On 4 November 2013 21:51, Nicolas Cellier<br>
<div class="HOEnZb"><div class="h5">&lt;<a href="mailto:nicolas.cellier.aka.nice@gmail.com">nicolas.cellier.aka.nice@gmail.com</a>&gt; wrote:<br>
&gt; It does not cost to ask ;)<br>
&gt; If you're in the mood and if our server is too, go for it...<br>
&gt;<br>
&gt;<br>
&gt; 2013/11/4 Frank Shearar &lt;<a href="mailto:frank.shearar@gmail.com">frank.shearar@gmail.com</a>&gt;<br>
&gt;&gt;<br>
&gt;&gt; Are you hinting that I should now fix the things post move? :)<br>
&gt;&gt;<br>
&gt;&gt; frank<br>
&gt;&gt;<br>
&gt;&gt; On 4 November 2013 21:15, Nicolas Cellier<br>
&gt;&gt; &lt;<a href="mailto:nicolas.cellier.aka.nice@gmail.com">nicolas.cellier.aka.nice@gmail.com</a>&gt; wrote:<br>
&gt;&gt; &gt; Sure! I said while at it ;)<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; 2013/11/4 Frank Shearar &lt;<a href="mailto:frank.shearar@gmail.com">frank.shearar@gmail.com</a>&gt;<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; Yes. #shouldnt:raise: is evil when you catch Error.<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; I deliberately didn't do that here so that reviewers could see that I<br>
&gt;&gt; &gt;&gt; moved methods, not added some random new test.<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; frank<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; On 4 November 2013 20:56, Nicolas Cellier<br>
&gt;&gt; &gt;&gt; &lt;<a href="mailto:nicolas.cellier.aka.nice@gmail.com">nicolas.cellier.aka.nice@gmail.com</a>&gt; wrote:<br>
&gt;&gt; &gt;&gt; &gt; While at it, there were a discussion in Pharo about shouldnt: []<br>
&gt;&gt; &gt;&gt; &gt; raise:<br>
&gt;&gt; &gt;&gt; &gt; Error, and it's generally considered a poor test<br>
&gt;&gt; &gt;&gt; &gt; - practically nothing should raise Error, unless in the few cases<br>
&gt;&gt; &gt;&gt; &gt; when<br>
&gt;&gt; &gt;&gt; &gt; you<br>
&gt;&gt; &gt;&gt; &gt; create a block that should:raise:<br>
&gt;&gt; &gt;&gt; &gt; &nbsp; so should:raise: is usefull, but shouldnt:raise: is generally<br>
&gt;&gt; &gt;&gt; &gt; useless<br>
&gt;&gt; &gt;&gt; &gt; &nbsp; (unless maybe if you are testing an Error inhibition mechanism with<br>
&gt;&gt; &gt;&gt; &gt; a<br>
&gt;&gt; &gt;&gt; &gt; block that shouldNormally:raise: Error)<br>
&gt;&gt; &gt;&gt; &gt; - if ever, it effectively raises an Error, you have no information<br>
&gt;&gt; &gt;&gt; &gt; why<br>
&gt;&gt; &gt;&gt; &gt; I fully agree with this.<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt; 2013/11/4 &lt;<a href="mailto:commits@source.squeak.org">commits@source.squeak.org</a>&gt;<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt;&gt; Frank Shearar uploaded a new version of CollectionsTests to project<br>
&gt;&gt; &gt;&gt; &gt;&gt; The<br>
&gt;&gt; &gt;&gt; &gt;&gt; Trunk:<br>
&gt;&gt; &gt;&gt; &gt;&gt; <a href="http://source.squeak.org/trunk/CollectionsTests-fbs.207.mcz" target="_blank">http://source.squeak.org/trunk/CollectionsTests-fbs.207.mcz</a><br>
&gt;&gt; &gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; &gt;&gt; ==================== Summary ====================<br>
&gt;&gt; &gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; &gt;&gt; Name: CollectionsTests-fbs.207<br>
&gt;&gt; &gt;&gt; &gt;&gt; Author: fbs<br>
&gt;&gt; &gt;&gt; &gt;&gt; Time: 4 November 2013, 6:31:01.83 pm<br>
&gt;&gt; &gt;&gt; &gt;&gt; UUID: 4057d67b-5969-8b41-85d1-43fd39da4bb1<br>
&gt;&gt; &gt;&gt; &gt;&gt; Ancestors: CollectionsTests-cmm.206<br>
&gt;&gt; &gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; &gt;&gt; Move collection tests where they belong.<br>
&gt;&gt; &gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; &gt;&gt; =============== Diff against CollectionsTests-cmm.206<br>
&gt;&gt; &gt;&gt; &gt;&gt; ===============<br>
&gt;&gt; &gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; &gt;&gt; Item was added:<br>
&gt;&gt; &gt;&gt; &gt;&gt; + ----- Method: ByteArrayTest&gt;&gt;testByteArrayLongAt (in category 'as<br>
&gt;&gt; &gt;&gt; &gt;&gt; yet<br>
&gt;&gt; &gt;&gt; &gt;&gt; unclassified') -----<br>
&gt;&gt; &gt;&gt; &gt;&gt; + testByteArrayLongAt<br>
&gt;&gt; &gt;&gt; &gt;&gt; + &nbsp; &nbsp; &nbsp; | ba value |<br>
&gt;&gt; &gt;&gt; &gt;&gt; + &nbsp; &nbsp; &nbsp; ba := ByteArray new: 4.<br>
&gt;&gt; &gt;&gt; &gt;&gt; + &nbsp; &nbsp; &nbsp; value := -1.<br>
&gt;&gt; &gt;&gt; &gt;&gt; + &nbsp; &nbsp; &nbsp; self shouldnt:[ba longAt: 1 put: value bigEndian: true]<br>
&gt;&gt; &gt;&gt; &gt;&gt; raise:<br>
&gt;&gt; &gt;&gt; &gt;&gt; Error.<br>
&gt;&gt; &gt;&gt; &gt;&gt; + &nbsp; &nbsp; &nbsp; self assert: (ba longAt: 1 bigEndian: true) = value.<br>
&gt;&gt; &gt;&gt; &gt;&gt; + &nbsp; &nbsp; &nbsp; self shouldnt:[ba longAt: 1 put: value bigEndian: false]<br>
&gt;&gt; &gt;&gt; &gt;&gt; raise:<br>
&gt;&gt; &gt;&gt; &gt;&gt; Error.<br>
&gt;&gt; &gt;&gt; &gt;&gt; + &nbsp; &nbsp; &nbsp; self assert: (ba longAt: 1 bigEndian: false) = value.!<br>
&gt;&gt; &gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; &gt;&gt; Item was added:<br>
&gt;&gt; &gt;&gt; &gt;&gt; + ----- Method: DictionaryTest&gt;&gt;testIntegrityOfDictionaries (in<br>
&gt;&gt; &gt;&gt; &gt;&gt; category<br>
&gt;&gt; &gt;&gt; &gt;&gt; 'integrity tests') -----<br>
&gt;&gt; &gt;&gt; &gt;&gt; + testIntegrityOfDictionaries<br>
&gt;&gt; &gt;&gt; &gt;&gt; + &nbsp; &nbsp; &nbsp; #(<br>
&gt;&gt; &gt;&gt; &gt;&gt; + &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Dictionary<br>
&gt;&gt; &gt;&gt; &gt;&gt; + &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; IdentityDictionary<br>
&gt;&gt; &gt;&gt; &gt;&gt; + &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SystemDictionary<br>
&gt;&gt; &gt;&gt; &gt;&gt; + &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; LiteralDictionary<br>
&gt;&gt; &gt;&gt; &gt;&gt; + &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PluggableDictionary<br>
&gt;&gt; &gt;&gt; &gt;&gt; + &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; WeakValueDictionary) do: [ :dictionaryClassName |<br>
&gt;&gt; &gt;&gt; &gt;&gt; + &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Smalltalk at: dictionaryClassName ifPresent:<br>
&gt;&gt; &gt;&gt; &gt;&gt; [<br>
&gt;&gt; &gt;&gt; &gt;&gt; :dictionaryClass |<br>
&gt;&gt; &gt;&gt; &gt;&gt; + &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dictionaryClass allInstancesDo: [<br>
&gt;&gt; &gt;&gt; &gt;&gt; :dictionary |<br>
&gt;&gt; &gt;&gt; &gt;&gt; + &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dictionary keysAndValuesDo:<br>
&gt;&gt; &gt;&gt; &gt;&gt; [<br>
&gt;&gt; &gt;&gt; &gt;&gt; :key<br>
&gt;&gt; &gt;&gt; &gt;&gt; :value |<br>
&gt;&gt; &gt;&gt; &gt;&gt; + &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self assert:<br>
&gt;&gt; &gt;&gt; &gt;&gt; (dictionary<br>
&gt;&gt; &gt;&gt; &gt;&gt; at: key) == value ].<br>
&gt;&gt; &gt;&gt; &gt;&gt; + &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dictionary array<br>
&gt;&gt; &gt;&gt; &gt;&gt; doWithIndex: [<br>
&gt;&gt; &gt;&gt; &gt;&gt; :association :index |<br>
&gt;&gt; &gt;&gt; &gt;&gt; + &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; association ifNotNil: [<br>
&gt;&gt; &gt;&gt; &gt;&gt; + &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;self assert:<br>
&gt;&gt; &gt;&gt; &gt;&gt; (dictionary<br>
&gt;&gt; &gt;&gt; &gt;&gt; scanFor: association key) = index ] ] ] ] ]!<br>
&gt;&gt; &gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; &gt;&gt; Item was added:<br>
&gt;&gt; &gt;&gt; &gt;&gt; + ----- Method: DictionaryTest&gt;&gt;testMethodDictionaries (in category<br>
&gt;&gt; &gt;&gt; &gt;&gt; 'integrity tests') -----<br>
&gt;&gt; &gt;&gt; &gt;&gt; + testMethodDictionaries<br>
&gt;&gt; &gt;&gt; &gt;&gt; + &nbsp; &nbsp; &nbsp; MethodDictionary allInstancesDo: [ :dictionary |<br>
&gt;&gt; &gt;&gt; &gt;&gt; + &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dictionary keysAndValuesDo: [ :key :value |<br>
&gt;&gt; &gt;&gt; &gt;&gt; + &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self assert: (dictionary at: key) == value<br>
&gt;&gt; &gt;&gt; &gt;&gt; ].<br>
&gt;&gt; &gt;&gt; &gt;&gt; + &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1 to: dictionary basicSize do: [ :index |<br>
&gt;&gt; &gt;&gt; &gt;&gt; + &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (dictionary basicAt: index)<br>
&gt;&gt; &gt;&gt; &gt;&gt; + &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ifNil: [ self assert: (dictionary<br>
&gt;&gt; &gt;&gt; &gt;&gt; array<br>
&gt;&gt; &gt;&gt; &gt;&gt; at: index) isNil ]<br>
&gt;&gt; &gt;&gt; &gt;&gt; + &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ifNotNil: [ :key |<br>
&gt;&gt; &gt;&gt; &gt;&gt; + &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self assert: (dictionary<br>
&gt;&gt; &gt;&gt; &gt;&gt; scanFor:<br>
&gt;&gt; &gt;&gt; &gt;&gt; key) = index ] ] ]!<br>
&gt;&gt; &gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; &gt;&gt; Item was added:<br>
&gt;&gt; &gt;&gt; &gt;&gt; + ----- Method: HashedCollectionTest&gt;&gt;testCapacity (in category<br>
&gt;&gt; &gt;&gt; &gt;&gt; 'test -<br>
&gt;&gt; &gt;&gt; &gt;&gt; integrity') -----<br>
&gt;&gt; &gt;&gt; &gt;&gt; + testCapacity<br>
&gt;&gt; &gt;&gt; &gt;&gt; +<br>
&gt;&gt; &gt;&gt; &gt;&gt; + &nbsp; &nbsp; &nbsp; | inconsistentCollections |<br>
&gt;&gt; &gt;&gt; &gt;&gt; + &nbsp; &nbsp; &nbsp; inconsistentCollections := HashedCollection allSubInstances<br>
&gt;&gt; &gt;&gt; &gt;&gt; reject: [ :each |<br>
&gt;&gt; &gt;&gt; &gt;&gt; + &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; each class == MethodDictionary "MethodDictionary is<br>
&gt;&gt; &gt;&gt; &gt;&gt; the<br>
&gt;&gt; &gt;&gt; &gt;&gt; only HashedCollection which doesn't have prime array size"<br>
&gt;&gt; &gt;&gt; &gt;&gt; + &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ifTrue: [ each capacity isPowerOfTwo ]<br>
&gt;&gt; &gt;&gt; &gt;&gt; + &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ifFalse: [ each capacity isPrime ] ].<br>
&gt;&gt; &gt;&gt; &gt;&gt; + &nbsp; &nbsp; &nbsp; self assert: inconsistentCollections isEmpty!<br>
&gt;&gt; &gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; &gt;&gt; Item was added:<br>
&gt;&gt; &gt;&gt; &gt;&gt; + ----- Method: ReadWriteStreamTest&gt;&gt;testReadWriteStreamNextNBug (in<br>
&gt;&gt; &gt;&gt; &gt;&gt; category 'tests') -----<br>
&gt;&gt; &gt;&gt; &gt;&gt; + testReadWriteStreamNextNBug<br>
&gt;&gt; &gt;&gt; &gt;&gt; + &nbsp; &nbsp; &nbsp; | aStream |<br>
&gt;&gt; &gt;&gt; &gt;&gt; + &nbsp; &nbsp; &nbsp; aStream := ReadWriteStream on: String new.<br>
&gt;&gt; &gt;&gt; &gt;&gt; + &nbsp; &nbsp; &nbsp; aStream nextPutAll: 'Hello World'.<br>
&gt;&gt; &gt;&gt; &gt;&gt; + &nbsp; &nbsp; &nbsp; self shouldnt:[aStream next: 5] raise: Error.!<br>
&gt;&gt; &gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
<br>
</div></div></blockquote></div><br></div>
</div></blockquote><blockquote type="cite"><div><span></span><br></div></blockquote></body></html>