<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
<br>
Ok, I think I&nbsp; now understand why you&nbsp; created&nbsp; #firstExpectedResult&nbsp;
etc.<br>
<br>
However from the example it seems your test is more about <br>
testing #collect: and #squared&nbsp; than about testing #at:&nbsp; .<br>
<br>
#at: and other collection protocols are important 'special' cases whose
specification I think requires special attention. <br>
<br>
I would approach the specification of&nbsp; #at: from the viewpoint that we
are not trying to specify individual methods in isolation, but a
standard set of methods that interact with each other.&nbsp; Thus the
specification of #at: could be partially done in terms of #at:put:,&nbsp;
and vice versa:<br>
<br>
&nbsp;|ob|<br>
&nbsp;ob := Object new.<br>
&nbsp;arr: =&nbsp;&nbsp; #(1 2 3).<br>
&nbsp;arr&nbsp; at: 3 put: ob.<br>
<br>
&nbsp;self assert: (arr at: 3) == ob.<br>
&nbsp;self assert: ((arr at: 2) == ob) not. <br>
<br>
&nbsp;self assertFails:&nbsp; [arr at: 4&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; ] .<br>
&nbsp;self assertFails:&nbsp; [arr at: 0 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; ] .<br>
&nbsp;self assertFails:&nbsp; [arr at: -1 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; ] .<br>
&nbsp;self assertFails:&nbsp; [arr at: 2.5&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; ] .<br>
&nbsp;self assertFails:&nbsp; [arr at: 4&nbsp;&nbsp; put:&nbsp; ob&nbsp;&nbsp; ] .<br>
&nbsp;self assertFails:&nbsp; [arr at: 0&nbsp;&nbsp;&nbsp; put:&nbsp; ob&nbsp; ] .<br>
&nbsp;self assertFails:&nbsp; [arr at: 2.5&nbsp; put:&nbsp; ob ] .<br>
&nbsp;self assertFails:&nbsp; [arr at: -1&nbsp;&nbsp; put:&nbsp; ob&nbsp; ] .<br>
&nbsp; <br>
<br>
The above test-case says something about both #at: and #at:put:. <br>
It doesn't unambiguously specify their&nbsp; complete behavior, but<br>
the standard can now say that IF an implementation fails the test-case<br>
above, it is not standards-compliant.<br>
<br>
Note also the 'suggestive' nature of the test-case above..<br>
It doesn't state every possible case in which #at: or #at:put should<br>
fail or not fail. But it does make it quite clear for a human reader <br>
what their expected behavior is.&nbsp; <br>
<br>
And naturally&nbsp; a test-case like above should be annotated with<br>
natural language instructions for "interpolating" the test-cases. <br>
But I think an executable test-case that is "reasonably representative"<br>
should be part of the spec of each standard method.&nbsp; <br>
<br>
It is possible that vendors already have lots and lots of test-cases <br>
for their base ST-libraries. If possible, these would be a great
starting<br>
point for the Smalltalk standardization effort.<br>
<br>
<br>
-Panu Viljamaa<br>
<br>
<br>
<br>
Andres Valloud wrote:
<blockquote
 cite="mid:491b84df0802031942l36cbcf89q27be5177f133c43c@mail.gmail.com"
 type="cite">Panu,<br>
  <br>
Actually, firstElement and so on were additions to the particular test
case to avoid using e.g. SequenceableCollection&gt;&gt;at: to test that
SequenceableCollection&gt;&gt;at: works.&nbsp; For example,<br>
  <br>
testAt<br>
  <br>
&nbsp; | expectedResults |<br>
&nbsp; expectedResults := #(1 4 9 16 25 36 49 64 81 100 121).<br>
&nbsp; actualResults := (1 to: 11) collect: [:each | each squared].<br>
&nbsp; 1 to: expectedResults size do:<br>
&nbsp;&nbsp;&nbsp; [:eachIndex |<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self assert: (expectedResults at: eachIndex) = (actualResults at:
eachIndex)<br>
&nbsp;&nbsp;&nbsp; ]<br>
  <br>
  <br>
So, instead of that,<br>
  <br>
testAt<br>
  <br>
&nbsp;&nbsp;&nbsp; actualResults := (1 to: 11) collect: [:each | each squared].<br>
&nbsp;&nbsp;&nbsp; self assert: (actualResults at: 1) = self firstExpectedResult.<br>
&nbsp;&nbsp;&nbsp; self assert: (actualResults at: 2) = self secondExpectedResult.<br>
&nbsp;&nbsp;&nbsp; .<br>
&nbsp;&nbsp;&nbsp; .<br>
&nbsp;&nbsp;&nbsp; .<br>
  <br>
  <br>
In the actual SUnit test suite, I think I dared up to fifthElement and
such.<br>
  <br>
Andres.<br>
  <br>
  <div class="gmail_quote">On Feb 2, 2008 8:20 PM, Panu Logic &lt;<a
 moz-do-not-send="true" href="mailto:panulogic@gmail.com">panulogic@gmail.com</a>&gt;
wrote:<br>
  <blockquote class="gmail_quote"
 style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Andres
Valloud wrote:<br>
&gt; At one point I wrote an SUnit ANSI test suite for collections.<br>
&gt; Something I noticed is that it is quite easy to depend on the
feature<br>
&gt; you want to test to write the test in the first place.
&nbsp;Particularly<br>
&gt; when writing tests for things like Array or SortedCollection, the<br>
&gt; dependency on at: and at:put: becomes obvious and the whole
exercise<br>
&gt; appears to become a tautology.<br>
    <br>
Cycles in language-specifications can be avoided by writing the spec in<br>
a &nbsp;language separate from the language being specified. No doubt any<br>
Smalltalk standard will need to rely on natural language. &nbsp;But if parts<br>
of the spec can be written in Smalltalk itself, so much better, because<br>
of the &nbsp;added rigor.<br>
    <br>
But consider English for a second. &nbsp;Its grammar is specified in English<br>
that's augmented with a few words that only make sense in the context of<br>
the grammar ("verb", "noun", "plural" ...) - which are defined in terms<br>
of the basic, everyday English. &nbsp; Similarly what you seem to be<br>
proposing is "augmenting" &nbsp; Collections with constructs whose sole<br>
purpose is to aid in writing the '"standard": &nbsp;#firstElement,<br>
#secondElement, &nbsp;etc.<br>
    <br>
I see no problem with this. &nbsp;It makes sense from the viewpoint that<br>
natural language standards are required to use similar means in their<br>
standards.<br>
    <br>
-Panu Viljamaa<br>
    <div>
    <div class="Wj3C7c"><br>
    <br>
    <br>
    <br>
_______________________________________________<br>
ANSI-Smalltalk mailing list<br>
    <a moz-do-not-send="true"
 href="mailto:ANSI-Smalltalk@lists.openskills.org">ANSI-Smalltalk@lists.openskills.org</a><br>
    <a moz-do-not-send="true"
 href="http://lists.openskills.org/cgi-bin/mailman/listinfo/ansi-smalltalk"
 target="_blank">http://lists.openskills.org/cgi-bin/mailman/listinfo/ansi-smalltalk</a><br>
    </div>
    </div>
  </blockquote>
  </div>
  <br>
  <pre wrap="">
<hr size="4" width="90%">
_______________________________________________
ANSI-Smalltalk mailing list
<a class="moz-txt-link-abbreviated" href="mailto:ANSI-Smalltalk@lists.openskills.org">ANSI-Smalltalk@lists.openskills.org</a>
<a class="moz-txt-link-freetext" href="http://lists.openskills.org/cgi-bin/mailman/listinfo/ansi-smalltalk">http://lists.openskills.org/cgi-bin/mailman/listinfo/ansi-smalltalk</a>
  </pre>
</blockquote>
<br>
</body>
</html>