Hi, In a fresh pharo 6 image, I add a class with an instance variable x and implement accessors. Then I write a test method for the accessors of x MyClassTest>>testReadWriteX self assert (MyClass new x: 0) x equals: 0 I run the test and obviously it is green BUT I remove the instance variable x. Obviously, the accessors are broken and the test should be red when I execute it again but it is not!!! I can even change the class again (to recompile it I thought) or even load the code in a new image and the tests are still green. I can also invoque the broken methods in a playground or in an inspector : MyClass new x: 0; increment; x then printIt. and astonishingly 1 is printed. The only way to detect the error is to recompile the method but this does not happen (maybe it should) when instance variables are modified or removed in the class (even when you use the refactoring tool!) I think this is annoying because one can no more really trust his tests. Cheers Abdelghani |
Hi abdel
I created a class with x and two accessors and I created the same test than you. They were green. Then I removed the instance variable x and I run the tests and they were greeeeeeeeennnnnnnnnnn (agrhhhhhhhh) I checked the accessors and the methods where showing that the instance variable is missing. So to me this is indeed a bug. I have no idea why the test should run. Stef On Sun, Nov 26, 2017 at 9:08 PM, abdelghani ALIDRA via Pharo-users <[hidden email]> wrote: > > > ---------- Forwarded message ---------- > From: abdelghani ALIDRA <[hidden email]> > To: "[hidden email]" <[hidden email]> > Cc: > Bcc: > Date: Sun, 26 Nov 2017 20:08:29 +0000 (UTC) > Subject: Removing instance variables doesn't recompile the methods > > Hi, > > In a fresh pharo 6 image, I add a class with an instance variable x and implement accessors. > Then I write a test method for the accessors of x > MyClassTest>>testReadWriteX > self assert (MyClass new x: 0) x equals: 0 > > I run the test and obviously it is green > > BUT > > I remove the instance variable x. Obviously, the accessors are broken and the test should be red when I execute it again but it is not!!! > > I can even change the class again (to recompile it I thought) or even load the code in a new image and the tests are still green. > I can also invoque the broken methods in a playground or in an inspector : MyClass new x: 0; increment; x then printIt. and astonishingly 1 is printed. > The only way to detect the error is to recompile the method but this does not happen (maybe it should) when instance variables are modified or removed in the class (even when you use the refactoring tool!) > > I think this is annoying because one can no more really trust his tests. > > Cheers > Abdelghani > > > |
https://pharo.fogbugz.com/f/cases/20765/removing-an-instance-variable-does-not-really-remove-it
On Sun, Nov 26, 2017 at 9:50 PM, Stephane Ducasse <[hidden email]> wrote: > Hi abdel > > I created a class with x and two accessors and I created the same test > than you. They were green. > Then I removed the instance variable x > and I run the tests and they were greeeeeeeeennnnnnnnnnn (agrhhhhhhhh) > > I checked the accessors and the methods where showing that the > instance variable is missing. > > So to me this is indeed a bug. I have no idea why the test should run. > > Stef > > On Sun, Nov 26, 2017 at 9:08 PM, abdelghani ALIDRA via Pharo-users > <[hidden email]> wrote: >> >> >> ---------- Forwarded message ---------- >> From: abdelghani ALIDRA <[hidden email]> >> To: "[hidden email]" <[hidden email]> >> Cc: >> Bcc: >> Date: Sun, 26 Nov 2017 20:08:29 +0000 (UTC) >> Subject: Removing instance variables doesn't recompile the methods >> >> Hi, >> >> In a fresh pharo 6 image, I add a class with an instance variable x and implement accessors. >> Then I write a test method for the accessors of x >> MyClassTest>>testReadWriteX >> self assert (MyClass new x: 0) x equals: 0 >> >> I run the test and obviously it is green >> >> BUT >> >> I remove the instance variable x. Obviously, the accessors are broken and the test should be red when I execute it again but it is not!!! >> >> I can even change the class again (to recompile it I thought) or even load the code in a new image and the tests are still green. >> I can also invoque the broken methods in a playground or in an inspector : MyClass new x: 0; increment; x then printIt. and astonishingly 1 is printed. >> The only way to detect the error is to recompile the method but this does not happen (maybe it should) when instance variables are modified or removed in the class (even when you use the refactoring tool!) >> >> I think this is annoying because one can no more really trust his tests. >> >> Cheers >> Abdelghani >> >> >> |
In reply to this post by Pharo Smalltalk Users mailing list
Thanks for reporting Abdelghani.
Now it would be doubly useful if you could isolate which build introduced the problem. PharoLauncher can be used to help bisect working/non-working images. cheers -ben On 27 November 2017 at 04:08, abdelghani ALIDRA via Pharo-users <[hidden email]> wrote:
|
As far as I know this has been a _feature_ for a very long time. Automatic recompiling methods is not the best idea, because: 1) you compile a method with temp var "hello" that uses inst var "world" 2) you add a inst var "hello" 3) you remove "world" 4) trying to recompile the method will fail, because suddenly there's a clash between temp var "hello" and inst var "hello" Don't forget that the methods are compiled, not interpreted. So this behavior is expected. Peter On Mon, Nov 27, 2017 at 6:03 AM, Ben Coman <[hidden email]> wrote:
|
In reply to this post by Pharo Smalltalk Users mailing list
Hi Ben,
I will try to see. I dont have my PC right now Abdelghani -------------------------------------------- En date de : Lun 27.11.17, Ben Coman <[hidden email]> a écrit : Objet: Re: [Pharo-users] Removing instance variables doesn't recompile the methods À: "abdelghani ALIDRA" <[hidden email]>, "Any question about pharo is welcome" <[hidden email]> Date: Lundi 27 novembre 2017, 6h03 Thanks for reporting Abdelghani.Now it would be doubly useful if you could isolate which build introduced the problem.PharoLauncher can be used to help bisect working/non-working images. cheers -ben On 27 November 2017 at 04:08, abdelghani ALIDRA via Pharo-users <[hidden email]> wrote: ---------- Forwarded message ---------- From: abdelghani ALIDRA <[hidden email]> To: "[hidden email]" <[hidden email]> Cc: Bcc: Date: Sun, 26 Nov 2017 20:08:29 +0000 (UTC) Subject: Removing instance variables doesn't recompile the methods Hi, In a fresh pharo 6 image, I add a class with an instance variable x and implement accessors. Then I write a test method for the accessors of x MyClassTest>>testReadWriteX self assert (MyClass new x: 0) x equals: 0 I run the test and obviously it is green BUT I remove the instance variable x. Obviously, the accessors are broken and the test should be red when I execute it again but it is not!!! I can even change the class again (to recompile it I thought) or even load the code in a new image and the tests are still green. I can also invoque the broken methods in a playground or in an inspector : MyClass new x: 0; increment; x then printIt. and astonishingly 1 is printed. The only way to detect the error is to recompile the method but this does not happen (maybe it should) when instance variables are modified or removed in the class (even when you use the refactoring tool!) I think this is annoying because one can no more really trust his tests. Cheers Abdelghani |
In reply to this post by Pharo Smalltalk Users mailing list
Hi Peter,
Yes. More basically : 1) you compile a method with parameter anObject 2) you add an instance anObject 3) you try to modify/compile the method and you have a message error. Maybe there should be a kind of warning message Abdelghani -------------------------------------------- En date de : Lun 27.11.17, Peter Uhnák <[hidden email]> a écrit : Objet: Re: [Pharo-users] Removing instance variables doesn't recompile the methods À: "Any question about pharo is welcome" <[hidden email]> Cc: "abdelghani ALIDRA" <[hidden email]> Date: Lundi 27 novembre 2017, 10h21 As far as I know this has been a _feature_ for a very long time.Automatic recompiling methods is not the best idea, because: 1) you compile a method with temp var "hello" that uses inst var "world"2) you add a inst var "hello"3) you remove "world"4) trying to recompile the method will fail, because suddenly there's a clash between temp var "hello" and inst var "hello" Don't forget that the methods are compiled, not interpreted. So this behavior is expected. Peter On Mon, Nov 27, 2017 at 6:03 AM, Ben Coman <[hidden email]> wrote: Thanks for reporting Abdelghani.Now it would be doubly useful if you could isolate which build introduced the problem.PharoLauncher can be used to help bisect working/non-working images. cheers -ben On 27 November 2017 at 04:08, abdelghani ALIDRA via Pharo-users <[hidden email]> wrote: ---------- Forwarded message ---------- From: abdelghani ALIDRA <[hidden email]> To: "[hidden email]. org" <[hidden email]> Cc: Bcc: Date: Sun, 26 Nov 2017 20:08:29 +0000 (UTC) Subject: Removing instance variables doesn't recompile the methods Hi, In a fresh pharo 6 image, I add a class with an instance variable x and implement accessors. Then I write a test method for the accessors of x MyClassTest>>testReadWriteX self assert (MyClass new x: 0) x equals: 0 I run the test and obviously it is green BUT I remove the instance variable x. Obviously, the accessors are broken and the test should be red when I execute it again but it is not!!! I can even change the class again (to recompile it I thought) or even load the code in a new image and the tests are still green. I can also invoque the broken methods in a playground or in an inspector : MyClass new x: 0; increment; x then printIt. and astonishingly 1 is printed. The only way to detect the error is to recompile the method but this does not happen (maybe it should) when instance variables are modified or removed in the class (even when you use the refactoring tool!) I think this is annoying because one can no more really trust his tests. Cheers Abdelghani |
Free forum by Nabble | Edit this page |