<div dir="ltr"><div dir="ltr">I've just realised that the code snippet I quoted in my previous message is missing the final part. Here it is in full:<div><br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">(UISupervisor animatedUIOf: Processor activeProcess)<br> ifNotNil: [ :ui | ui doOneCycleNowOn: ui mainCanvas ]<br>  ifNil: [ | updated d |<br>    updated := false.<br>    d := Delay forMilliseconds: 10.<br>    UISupervisor whenUIinSafeState: [ UISupervisor whenUIinSafeState: [updated := true ]].<br>    [updated] whileFalse: [<br>      d wait ]].</blockquote><div><br></div><div>To clarify comment/question (3) in my previous message, If I remove one of <b>whenUIinSafeState:</b> leaving the snippet as this:</div><div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">(UISupervisor animatedUIOf: Processor activeProcess)<br> ifNotNil: [ :ui | ui doOneCycleNowOn: ui mainCanvas ]<br>  ifNil: [ | updated d |<br>    updated := false.<br>    d := Delay forMilliseconds: 10.<br>    UISupervisor whenUIinSafeState: [updated := true ].<br>    [updated] whileFalse: [<br>      d wait ]].</blockquote><div>The LayoutMorph tests still pass.</div></div></div></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Sat, 21 Dec 2024 at 22:32, Ezequiel Birman <<a href="mailto:ebirman77@gmail.com">ebirman77@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Hi! I am revisiting the <i>Spacewar!</i> exercise from The Cuis Smalltalk Book, and I am testing things that deal with morph collisions.</div><div><span><br></span></div><div><span>The </span><b>LayoutMorphTest</b> tests in BaseImageTests insert clever code before the assertions, to ensure things happen orderly:</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">(UISupervisor animatedUIOf: Processor activeProcess)<br>  ifNotNil: [ :ui | ui doOneCycleNowOn: ui mainCanvas ]<br>  ifNil: [ | updated d |<br>    updated := false.<br>    d := Delay forMilliseconds: 10.<br>    UISupervisor whenUIinSafeState: [ UISupervisor whenUIinSafeState: [ updated := true ]].</blockquote><div><br></div><div>Since I don't need (or I can't see the need) for my tests to display morphs on the screen, and since <b>Morph>>collides:</b> relies on the morphs having a display bound, in my tests it was enough to insert</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">space privateDisplayBounds: space fullBoundsInOwner</blockquote><div>before the assertions, where <i>space</i> owns the colliding morphs in the test; and since I don't display things on screen, test runs feel snappier.</div><div><br></div><div>1) The thing I'm doing with <b>privateDisplayBounds:</b> will it come back to bite me?</div><div>2) Is it better, for some definition of better, for morphic tests to display morphs on screen while they run?</div><div>3) I don't understand the need for the nesting in <b>UISupervisor whenUIinSafeState: [ UISupervisor whenUIinSafeState: [ updated := true ]]</b>, I removed the outer level and the LayoutMorph tests still pass. Maybe by chance? Things are hard to debug when they behave differently when debugging.</div><div>4) Can you imagine another way of writing these kinds of tests?</div><div><br></div><div>I attached a couple of simple examples so you don't have to type them.</div><div><br></div><div>-- </div><div>Eze</div></div>
</blockquote></div></div>