[squeak-dev] Some loop debugging help.
Bob Arning
arning315 at comcast.net
Tue Mar 5 03:30:56 UTC 2013
Are you looking at the right "i" in the debugger? Since you reused the
block argument name, there are two i's showing in the debugger. The
first is 6 because that's how the first loop ended - when i was > 5. The
second i will be the one for the second loop.
Cheers,
Bob
On 3/4/13 9:28 PM, R. Clayton wrote:
> I have an SUnit test:
>
> testTriangle
>
> | b n t |
>
> b := Bag new
> . n := 5
>
> . 1 to: n do: [ :i |
> i timesRepeat: [
> b add: (IntervalTreeInterval from: i to: i + 1)
> ]
> ]
> . t := IntervalTree withIntervals: b
>
> . Transcript show: 'Start testing' ; cr
> . 0 to: n do: [ :i |
> b := t intervalsContaining: i + 0.5
> . Transcript show: i ; cr ; flush
> . self assert: b size = i
> ]
>
> If I run this method with the last statement commented out (that is, without
> the assertion), the transcript shows
>
> Start testing
> 0
> 1
> 2
> 3
> 4
> 5
>
> If I run the test with the last statement enabled (that is, with the
> assertion), the transcript shows
>
> Start testing
> 0
> 1
> 2
>
> and testTriangle fails. However, in the debugger I find that i is 6 and the
> bag b is empty, which is correct because there are no intervals containing 6.5
> (which makes the assertion fail the correct thing to do). My question is: why
> is i = 6? I would have expected the loop to stop after i = 5, as it did when
> there was no assertion.
>
> As a secondary question, why did the transcript stop at 2 for the failing test?
> I'm assuming it's a buffering problem, but I would have expected flush to push
> the buffer contents along.
>
> I'm running
>
> Image
> -----
> /home/rclayton/projects/squeak/interval-tree/Squeak4.3.image
> Squeak4.3
> latest update: #11864
> Current Change Set: Unnamed1
>
> Virtual Machine
> ---------------
> /home/squeak-4.3/Contents/Linux-i686/lib/squeak/4.4.7-2357/squeakvm
> Squeak4.1 of 17 April 2010 [latest update: #9957]
> Unix built on Jan 23 2011 18:17:32 Compiler: 4.3.2
> platform sources revision 2357
> VMMaker versionString 4.4.7
>
> Operating System/Hardware
> -------------------------
> unix linux i686
>
> Operating System Details
> ------------------------
> Debian GNU/Linux 7.0 \n \l
>
> FileDoesNotExistException: '/etc/lsb-release'Linux version 3.2.0-4-686-pae
> (debian-kernel at lists.debian.org) (gcc version 4.6.3 (Debian 4.6.3-14) ) #1
> SMP Debian 3.2.35-2
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20130304/bfd47ec3/attachment-0001.htm
More information about the Squeak-dev
mailing list
|