<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Jan 1, 2014 at 4:31 PM, Frank Shearar <span dir="ltr">&lt;<a href="mailto:frank.shearar@gmail.com" target="_blank">frank.shearar@gmail.com</a>&gt;</span> wrote:<br>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">
&gt; Item was added:<br>
&gt; + ----- Method: BindingPolicyTest&gt;&gt;testAddHonorsEnvironment (in category &#39;tests&#39;) -----<br>
&gt; + testAddHonorsEnvironment<br>
&gt; +       | binding other |<br>
&gt; +       other := Environment withName: #other.<br>
&gt; +       policy := self bindingPolicyWithNamePolicy: AllNamePolicy new.<br>
&gt; +       binding := #Griffle =&gt; value.<br>
&gt; +       policy binding: binding addedTo: other notify: self.<br>
&gt; +       self assert: notified = nil!<br>
<br>
</div></div>I think I&#39;ve established my reputation as a loud lover of<br>
#assert:equals: :) Just sayin&#39;.<br></blockquote><div><br></div><div>I&#39;m too used to the debugger, I guess. Using #assert:equals: feels like JUnit&#39;s work around for the fact that you get an error message, not a debugger when the test fails. But now that we have automated testing, we need the work around too!</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
What I often do is set these kinds of variables - variables that show<br>
that some side effect took place - to some obviously wrong value. In<br>
this case, you could set notifier := #notCalled in the #setUp.<br></blockquote><div><br></div><div>Ah, nice. I&#39;ll make that tweak.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

I can&#39;t figure out what this test _does_ though: when you say that add<br>
honours Environment, you mean that it only adds the binding if the<br>
addedTo: environment matches the policy&#39;s environment, and we know<br>
this because the notifier isn&#39;t called?</blockquote><div><br></div><div>Yes, exactly. The policy responds to changes in a particular environment, and directs another environment to take action in response. So imports react to events in the &quot;upstream&quot; environment, and tell the local environment to add or remove bindings in to stay in sync. Exports react to changes in *this* environment, and notify the &quot;downstream&quot; environments about them. </div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
&gt; Item was added:<br>
&gt; + ----- Method: BindingPolicyTest&gt;&gt;testRemoveHonorsEnvironment (in category &#39;tests&#39;) -----<br>
&gt; + testRemoveHonorsEnvironment<br>
&gt; +       | binding other |<br>
&gt; +       other := Environment withName: #other.<br>
&gt; +       policy := self bindingPolicyWithNamePolicy: AllNamePolicy new.<br>
&gt; +       binding := #Griffle =&gt; value.<br>
&gt; +       policy binding: binding removedFrom: other notify: self.<br>
&gt; +       self assert: notified = nil!<br>
<br>
</div>Same thing as #testAddHonorsEnvironment?<br></blockquote><div><br></div><div>Yes, but for a binding removed, rather than added.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div class="im">&gt; Item was changed:<br>
&gt;   ----- Method: EnvironmentTest&gt;&gt;testImportAddingPrefixResolvesUndeclared (in category &#39;import tests&#39;) -----<br>
&gt;   testImportAddingPrefixResolvesUndeclared<br>
&gt;         | binding foreign |<br>
&gt;         foreign := Environment withName: #Foreign.<br>
&gt;         foreign exportSelf.<br>
&gt; +       foreign bind: #Griffle to: value.<br>
&gt; +       binding := env undeclare: #XXGriffle.<br>
<br>
</div>I like this. Nice &amp; explicit language.</blockquote><div><br></div><div>I&#39;m hoping to build up a simple protocol for this stuff, so we can&#39;t replace all the dictionary manipulation that&#39;s scattered around the image with more semantically explicit messages. See, for example #declarationOf:.</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> </blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">
&gt; Item was changed:<br>
&gt;   ----- Method: EnvironmentTest&gt;&gt;testImportAliases (in category &#39;import tests&#39;) -----<br>
&gt;   testImportAliases<br>
&gt;         | foreign v2 v3 |<br>
&gt;         foreign := Environment withName: #Foreign.<br>
&gt;         foreign exportSelf.<br>
&gt;         foreign at: #Griffle put: value.<br>
&gt;         foreign at: #Nurp put: (v2 := Object new).<br>
&gt;         foreign at: #Ziffy put: (v3 := Object new).<br>
<br>
</div>Shouldn&#39;t these be #bind:to: now?<br></blockquote><div><br></div><div>Yeah... missed updating them. </div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div class="im"><br>
&gt; +       env from: foreign import: {#Nurp -&gt; #Plonk. #Ziffy -&gt; #Wiffy}.<br>
&gt; -       env from: foreign import: {#Plonk -&gt; #Nurp. #Wiffy -&gt; #Ziffy}.<br>
<br>
</div>I find this hard to understand. So the Array of Associations looks<br>
like it says &quot;when you see Ziffy, interpret that as if you saw Wiffy&quot;,<br>
or &quot;map Ziffy to Wiffy&quot;. Oh. It says &quot;when you import foreign, map<br>
foreign&#39;s Ziffy to env&#39;s (new) Wiffy. OK, that makes sense.</blockquote><div><br></div><div>I think I had it backwards in the previous version, because the lazy lookups make all the name transformations happen the wrong way around. It should match the simple version of the import. So this:</div>
<div><br></div><div>env from: foreign import: #Wiffy</div><div><br></div><div>means pretty much what it says, &quot;import #Wiffy from foreign&quot;. The renaming version is (now) similar:</div><div><br></div><div>env from: foreign import: #Wiffy -&gt; #Ziffy</div>
<div><br></div><div>meaning, &quot;import foreign&#39;s #Wiffy, but rename it to #Ziffy&quot;</div><div><br></div><div>I guess that&#39;s the opposite of what you concluded.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">
&gt;   ----- Method: EnvironmentTest&gt;&gt;testImportWritable (in category &#39;import tests&#39;) -----<br>
&gt;   testImportWritable<br>
&gt;         | foreign binding |<br>
&gt;         foreign := Environment withName: #Foreign.<br>
&gt;         foreign exportSelf.<br>
&gt; +       foreign bind: #Griffle to: &#39;v1&#39;.<br>
&gt; +       env from: foreign import: #Griffle -&gt; #Plonk.<br>
&gt; -       foreign at: #Griffle put: &#39;v1&#39;.<br>
&gt; -       env from: foreign import: #Plonk -&gt; #Griffle.<br>
&gt;         binding := env bindingOf: #Plonk.<br>
&gt;         binding value: &#39;v2&#39;.<br>
&gt; +       self assert: (foreign declarationOf: #Griffle) value = &#39;v2&#39; !<br>
&gt; -       self assert: (foreign bindingOf: #Griffle) value == &#39;v2&#39; !<br>
<br>
</div></blockquote><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I realise this is existing behaviour, but I&#39;m not so keen on<br>
sub-environments being able to tinker with parent environments&#39;<br>
bindings. What&#39;s the use case here? It means an Environment can&#39;t be<br>
used as a sandbox.</blockquote><div><br></div><div>This is really for Globals. It just ensures that all environments that share a global will see the same value, regardless of what it&#39;s called.  </div><div> </div><div>
<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
&gt; Item was added:<br>
&gt; + ----- Method: EnvironmentTest&gt;&gt;testUndeclare (in category &#39;binding tests&#39;) -----<br>
&gt; + testUndeclare<br>
&gt; +       | one two |<br>
&gt; +       one := env undeclare: #Griffle.<br>
&gt; +       two := env bindingOf: #Griffle.<br>
&gt; +       self assert: one == two.<br>
&gt; +       self assert: one class == Global!<br>
<br>
</div>Ah. This shows that you can always add new undeclared stuff to an<br>
environment. The name of the test didn&#39;t tell me that :/. </blockquote><div><br></div><div>Well, it mostly tests that #undeclare: exists and works as expected: it answers the same binding the subsequent calls to #bindingOf will answer. </div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Also, is it<br>
part of the API that one value isNil?</blockquote><div><br></div><div>It should be, yeah. Oversight on my part. </div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im"><br>
</div>Minor nit: one of these tests says &quot;BecomeSomething&quot; and the other<br>
says &quot;BecomesSomething&quot;.</blockquote><div><br></div><div>Will fix. </div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
&gt; Item was changed:<br>
&gt; + ----- Method: MCClassDefinitionTest&gt;&gt;testLoadAndUnload (in category &#39;as yet unclassified&#39;) -----<br>
<br>
</div>So all this noise in the Monticello tests is because there are two<br>
Tests-fbs.280 - one in trunk, and one in the inbox. Fun times. The one<br>
in the inbox changes the MC tests to load definitions into an<br>
Environment that&#39;s then thrown away after the test runs. This avoids<br>
MC mucking around with global state.<br></blockquote><div><br></div><div>Ugh, sorry about that. Didn&#39;t notice the extra changes. </div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

The changes have been sitting in the Inbox for a week, but given<br>
Colin&#39;s big chunk of stuff landing in the Inbox, let&#39;s review it, push<br>
to trunk when ready, and then I&#39;ll update my MC test hacking, and<br>
resubmit.<br></blockquote><div><br></div><div>I&#39;ve been meaning to review that, but I wanted to get these changes done before I forget how they work. :-)</div><div><br></div><div>Colin</div></div></div></div>