Hi,
I have a piece of code that builds a morph in a parallel process, and I would like to test that it builds the right thing. The building of the morph can take long. My current solution is to add a delay, but this is ugly and unreliable: "setup and trigger the morph building" (Delay forMilliseconds: 1000) wait. "assert that the morph is correct" The question is if there is a better way. Cheers, Doru -- www.tudorgirba.com "We are all great at making mistakes." |
Hi,
Your problem is Morph operation taking place only in the UI thread, therefore blocking the user, is it that? Hilaire On 30/05/2012 07:43, Tudor Girba wrote: > Hi, > > I have a piece of code that builds a morph in a parallel process, and I would like to test that it builds the right thing. > > The building of the morph can take long. My current solution is to add a delay, but this is ugly and unreliable: > > "setup and trigger the morph building" > (Delay forMilliseconds: 1000) wait. > "assert that the morph is correct" > > The question is if there is a better way. > > Cheers, > Doru > > > -- > www.tudorgirba.com > > "We are all great at making mistakes." > > > > > > > > > -- Dr. Geo -- http://www.drgeo.eu |
In reply to this post by Tudor Girba-2
I still remember that code a bit..
so, you need a place where you can hook in and validate the morph. Piece of cake: in your watcher object, delegate the event "building done" to some other object.. that "other object" in default case will use #addDeferredUIMessage... and add this morph to scene. And in case of test, you free to do anything else then.. On 30 May 2012 07:43, Tudor Girba <[hidden email]> wrote: > Hi, > > I have a piece of code that builds a morph in a parallel process, and I would like to test that it builds the right thing. > > The building of the morph can take long. My current solution is to add a delay, but this is ugly and unreliable: > > "setup and trigger the morph building" > (Delay forMilliseconds: 1000) wait. > "assert that the morph is correct" > > The question is if there is a better way. > > Cheers, > Doru > > > -- > www.tudorgirba.com > > "We are all great at making mistakes." > > > > > > > > -- Best regards, Igor Stasenko. |
Hi Igor,
I am not sure I understand. This would still not test the final logic, would it? Cheers, Doru On 30 May 2012, at 14:15, Igor Stasenko wrote: > I still remember that code a bit.. > so, you need a place where you can hook in and validate the morph. > Piece of cake: in your watcher object, delegate the event "building > done" to some other object.. > that "other object" in default case will use #addDeferredUIMessage... > and add this morph to scene. > And in case of test, you free to do anything else then.. > > > On 30 May 2012 07:43, Tudor Girba <[hidden email]> wrote: >> Hi, >> >> I have a piece of code that builds a morph in a parallel process, and I would like to test that it builds the right thing. >> >> The building of the morph can take long. My current solution is to add a delay, but this is ugly and unreliable: >> >> "setup and trigger the morph building" >> (Delay forMilliseconds: 1000) wait. >> "assert that the morph is correct" >> >> The question is if there is a better way. >> >> Cheers, >> Doru >> >> >> -- >> www.tudorgirba.com >> >> "We are all great at making mistakes." >> >> >> >> >> >> >> >> > > > > -- > Best regards, > Igor Stasenko. > -- www.tudorgirba.com "Some battles are better lost than fought." |
Administrator
|
In reply to this post by Tudor Girba-2
I think more details about the code in the "setup and trigger" step would help... where exactly does the fork happen? Is the Morph added to the world?
Cheers,
Sean |
In reply to this post by Tudor Girba-2
On 2 June 2012 22:58, Tudor Girba <[hidden email]> wrote:
> Hi Igor, > > I am not sure I understand. This would still not test the final logic, would it? > ok.. here the abstract code snippet. w := Watcher new. w delegate: myDelegate. w buildThatMorph. now as result.. you delegate receives a message #morphAreBuilt: with morph as argument. so, you can choose either to add it to world, or you can choose to test its contents without adding anywhere, depending who is a delegate. > Cheers, > Doru > > > On 30 May 2012, at 14:15, Igor Stasenko wrote: > >> I still remember that code a bit.. >> so, you need a place where you can hook in and validate the morph. >> Piece of cake: in your watcher object, delegate the event "building >> done" to some other object.. >> that "other object" in default case will use #addDeferredUIMessage... >> and add this morph to scene. >> And in case of test, you free to do anything else then.. >> >> >> On 30 May 2012 07:43, Tudor Girba <[hidden email]> wrote: >>> Hi, >>> >>> I have a piece of code that builds a morph in a parallel process, and I would like to test that it builds the right thing. >>> >>> The building of the morph can take long. My current solution is to add a delay, but this is ugly and unreliable: >>> >>> "setup and trigger the morph building" >>> (Delay forMilliseconds: 1000) wait. >>> "assert that the morph is correct" >>> >>> The question is if there is a better way. >>> >>> Cheers, >>> Doru >>> >>> >>> -- >>> www.tudorgirba.com >>> >>> "We are all great at making mistakes." >>> >>> >>> >>> >>> >>> >>> >>> >> >> >> >> -- >> Best regards, >> Igor Stasenko. >> > > -- > www.tudorgirba.com > > "Some battles are better lost than fought." > > > > -- Best regards, Igor Stasenko. |
or .. even simpler
watcher buildDatMorphAndPassItToTHisBlock: [:morph | world adddeferreduimessage: [.,...] or.. mytest analyze: morph ] what confuses you? On 3 June 2012 01:20, Igor Stasenko <[hidden email]> wrote: > On 2 June 2012 22:58, Tudor Girba <[hidden email]> wrote: >> Hi Igor, >> >> I am not sure I understand. This would still not test the final logic, would it? >> > ok.. here the abstract code snippet. > > w := Watcher new. > > w delegate: myDelegate. > > w buildThatMorph. > > now as result.. > you delegate receives a message #morphAreBuilt: with morph as argument. > > so, you can choose either to add it to world, > or you can choose to test its contents without adding anywhere, > depending who is a delegate. > > >> Cheers, >> Doru >> >> >> On 30 May 2012, at 14:15, Igor Stasenko wrote: >> >>> I still remember that code a bit.. >>> so, you need a place where you can hook in and validate the morph. >>> Piece of cake: in your watcher object, delegate the event "building >>> done" to some other object.. >>> that "other object" in default case will use #addDeferredUIMessage... >>> and add this morph to scene. >>> And in case of test, you free to do anything else then.. >>> >>> >>> On 30 May 2012 07:43, Tudor Girba <[hidden email]> wrote: >>>> Hi, >>>> >>>> I have a piece of code that builds a morph in a parallel process, and I would like to test that it builds the right thing. >>>> >>>> The building of the morph can take long. My current solution is to add a delay, but this is ugly and unreliable: >>>> >>>> "setup and trigger the morph building" >>>> (Delay forMilliseconds: 1000) wait. >>>> "assert that the morph is correct" >>>> >>>> The question is if there is a better way. >>>> >>>> Cheers, >>>> Doru >>>> >>>> >>>> -- >>>> www.tudorgirba.com >>>> >>>> "We are all great at making mistakes." >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>> >>> >>> >>> -- >>> Best regards, >>> Igor Stasenko. >>> >> >> -- >> www.tudorgirba.com >> >> "Some battles are better lost than fought." >> >> >> >> > > > > -- > Best regards, > Igor Stasenko. -- Best regards, Igor Stasenko. |
Free forum by Nabble | Edit this page |