<div dir="ltr"><div>    | ba value |<br>    ba := ByteArray new: 4.<br>    value := -1.<br>    ba longAt: 1 put: value bigEndian: true.<br>    self assert: (ba longAt: 1 bigEndian: true) = (ba longAt: 1 bigEndian: false).<br>
<br>Thanks Bob, that makes sense<br>but intention can&#39;t be revealed without this context, so the code is not good enough.<br><br></div>At least, it should be named something like testThatByteArrayLongAtDoesPreserveSign.<br>
<br><br><br></div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/11/5 Bob Arning <span dir="ltr">&lt;<a href="mailto:arning315@comcast.net" target="_blank">arning315@comcast.net</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

  
    
  
  <div text="#000000" bgcolor="#FFFFFF">
    <font face="Georgia">Just a guess, but I think the test was written
      to show that a particular bug had been fixed. Endian wasn&#39;t an
      issue here - negative numbers were.<br>
      <br>
<a href="http://lists.squeakfoundation.org/pipermail/squeak-dev/2003-August/063928.html" target="_blank">http://lists.squeakfoundation.org/pipermail/squeak-dev/2003-August/063928.html</a><br>
      <br>
      Cheers,<br>
      Bob<br>
      <br>
    </font><div><div class="h5">
    <div>On 11/5/13 3:24 AM, Frank Shearar
      wrote:<br>
    </div>
    <blockquote type="cite">
      <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&#39;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" target="_blank">nicolas.cellier.aka.nice@gmail.com</a>&gt;
        wrote:<br>
        <br>
      </div>
      <blockquote type="cite">
        <div>
          <div dir="ltr">Beside the form, isn&#39;t -1 a palindrome? (if you
            reverse bit/bytes you still get -1, so it&#39;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>
                    | ba value |<br>
                <div>    ba := ByteArray new: 4.<br>
                </div>
                    value := -1.<br>
                    ba longAt: 1 put: value bigEndian: true.<br>
                <div>    self assert: (ba longAt: 1
                  bigEndian: true) = value.<br>
                </div>
                    ba longAt: 1 put: value bigEndian: false.<br>
                <div>    self assert: (ba longAt: 1
                  bigEndian: false) = value.<br>
                  <br>
                </div>
                I mean, it&#39;d get the job done. Any better ideas?<br>
                <br>
                frank<br>
                <br>
                On 4 November 2013 21:51, Nicolas Cellier<br>
                <div>
                  <div>&lt;<a href="mailto:nicolas.cellier.aka.nice@gmail.com" target="_blank">nicolas.cellier.aka.nice@gmail.com</a>&gt;
                    wrote:<br>
                    &gt; It does not cost to ask ;)<br>
                    &gt; If you&#39;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" target="_blank">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" target="_blank">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" target="_blank">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&#39;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" target="_blank">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&#39;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;   so should:raise: is
                    usefull, but shouldnt:raise: is generally<br>
                    &gt;&gt; &gt;&gt; &gt; useless<br>
                    &gt;&gt; &gt;&gt; &gt;   (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" target="_blank">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 &#39;as<br>
                    &gt;&gt; &gt;&gt; &gt;&gt; yet<br>
                    &gt;&gt; &gt;&gt; &gt;&gt; unclassified&#39;) -----<br>
                    &gt;&gt; &gt;&gt; &gt;&gt; + testByteArrayLongAt<br>
                    &gt;&gt; &gt;&gt; &gt;&gt; +       | ba value |<br>
                    &gt;&gt; &gt;&gt; &gt;&gt; +       ba := ByteArray
                    new: 4.<br>
                    &gt;&gt; &gt;&gt; &gt;&gt; +       value := -1.<br>
                    &gt;&gt; &gt;&gt; &gt;&gt; +       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; +       self assert: (ba
                    longAt: 1 bigEndian: true) = value.<br>
                    &gt;&gt; &gt;&gt; &gt;&gt; +       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; +       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; &#39;integrity tests&#39;) -----<br>
                    &gt;&gt; &gt;&gt; &gt;&gt; +
                    testIntegrityOfDictionaries<br>
                    &gt;&gt; &gt;&gt; &gt;&gt; +       #(<br>
                    &gt;&gt; &gt;&gt; &gt;&gt; +              
                    Dictionary<br>
                    &gt;&gt; &gt;&gt; &gt;&gt; +              
                    IdentityDictionary<br>
                    &gt;&gt; &gt;&gt; &gt;&gt; +              
                    SystemDictionary<br>
                    &gt;&gt; &gt;&gt; &gt;&gt; +              
                    LiteralDictionary<br>
                    &gt;&gt; &gt;&gt; &gt;&gt; +              
                    PluggableDictionary<br>
                    &gt;&gt; &gt;&gt; &gt;&gt; +              
                    WeakValueDictionary) do: [ :dictionaryClassName |<br>
                    &gt;&gt; &gt;&gt; &gt;&gt; +                      
                    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; +                        
                          dictionaryClass allInstancesDo: [<br>
                    &gt;&gt; &gt;&gt; &gt;&gt; :dictionary |<br>
                    &gt;&gt; &gt;&gt; &gt;&gt; +                        
                                  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; +                        
                                          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; +                        
                                  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; +                        
                                  association ifNotNil: [<br>
                    &gt;&gt; &gt;&gt; &gt;&gt; +                        
                                         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; &#39;integrity tests&#39;) -----<br>
                    &gt;&gt; &gt;&gt; &gt;&gt; + testMethodDictionaries<br>
                    &gt;&gt; &gt;&gt; &gt;&gt; +       MethodDictionary
                    allInstancesDo: [ :dictionary |<br>
                    &gt;&gt; &gt;&gt; &gt;&gt; +              
                    dictionary keysAndValuesDo: [ :key :value |<br>
                    &gt;&gt; &gt;&gt; &gt;&gt; +                      
                    self assert: (dictionary at: key) == value<br>
                    &gt;&gt; &gt;&gt; &gt;&gt; ].<br>
                    &gt;&gt; &gt;&gt; &gt;&gt; +               1 to:
                    dictionary basicSize do: [ :index |<br>
                    &gt;&gt; &gt;&gt; &gt;&gt; +                      
                    (dictionary basicAt: index)<br>
                    &gt;&gt; &gt;&gt; &gt;&gt; +                        
                          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; +                        
                          ifNotNil: [ :key |<br>
                    &gt;&gt; &gt;&gt; &gt;&gt; +                        
                                  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; &#39;test -<br>
                    &gt;&gt; &gt;&gt; &gt;&gt; integrity&#39;) -----<br>
                    &gt;&gt; &gt;&gt; &gt;&gt; + testCapacity<br>
                    &gt;&gt; &gt;&gt; &gt;&gt; +<br>
                    &gt;&gt; &gt;&gt; &gt;&gt; +       |
                    inconsistentCollections |<br>
                    &gt;&gt; &gt;&gt; &gt;&gt; +      
                    inconsistentCollections := HashedCollection
                    allSubInstances<br>
                    &gt;&gt; &gt;&gt; &gt;&gt; reject: [ :each |<br>
                    &gt;&gt; &gt;&gt; &gt;&gt; +               each
                    class == MethodDictionary &quot;MethodDictionary is<br>
                    &gt;&gt; &gt;&gt; &gt;&gt; the<br>
                    &gt;&gt; &gt;&gt; &gt;&gt; only HashedCollection
                    which doesn&#39;t have prime array size&quot;<br>
                    &gt;&gt; &gt;&gt; &gt;&gt; +                      
                    ifTrue: [ each capacity isPowerOfTwo ]<br>
                    &gt;&gt; &gt;&gt; &gt;&gt; +                      
                    ifFalse: [ each capacity isPrime ] ].<br>
                    &gt;&gt; &gt;&gt; &gt;&gt; +       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 &#39;tests&#39;) -----<br>
                    &gt;&gt; &gt;&gt; &gt;&gt; +
                    testReadWriteStreamNextNBug<br>
                    &gt;&gt; &gt;&gt; &gt;&gt; +       | aStream |<br>
                    &gt;&gt; &gt;&gt; &gt;&gt; +       aStream :=
                    ReadWriteStream on: String new.<br>
                    &gt;&gt; &gt;&gt; &gt;&gt; +       aStream
                    nextPutAll: &#39;Hello World&#39;.<br>
                    &gt;&gt; &gt;&gt; &gt;&gt; +       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>
      <br>
      <fieldset></fieldset>
      <br>
      <pre></pre>
    </blockquote>
    <br>
  </div></div></div>

<br><br>
<br></blockquote></div><br></div>