MooseFileStructureImporterTest>>testFiles failure

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

MooseFileStructureImporterTest>>testFiles failure

Fabrizio Perin
Hi,
the problem with this test failure is related with the implementation of lineCount method. Basically the old implementation start to count to 1 and then it adds 1 for each cr found in the string. 

OLD IMPLEMENTATION

lineCount
"Answer the number of lines represented by the receiver, where every cr adds one line.  5/10/96 sw"

| cr count |
cr := Character cr.
count := 1  min: self size.
1 to: self size do:
[:i | (self at: i) = cr ifTrue: [count := count + 1]].
^ count

So for the definition of this file:

file := self createFile: (self foldersString , 'fileWith9Chars4Lines2EmptyLines').
stream := file writeStream.
stream
nextPutAll: '123456';
cr;
cr;
nextPutAll: '789';
cr. 

In the 1.0 lineCount return 4 -> 1 + 3 cr.

The new lineCount method counts the lines considering only the number of cr, lf or crlf that it find in the string. So the same file definition in the 1.1 return 3 -> 3 cr.

To make this test green the most logic thing it will be to add a cr in the definition of the string in such a way to fit the definition of the new method lineCount.

file := self createFile: (self foldersString , 'fileWith9Chars4Lines2EmptyLines').
stream := file writeStream.
stream
nextPutAll: '123456'; cr;
cr;
cr;
nextPutAll: '789'; cr.

If you agree i will proceed with the modification. (of course this will break the test in the 1.0)

Cheers,

Fabrizio




_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Reply | Threaded
Open this post in threaded view
|

Re: MooseFileStructureImporterTest>>testFiles failure

Alexandre Bergel-4
This is a bit strange. count should be initialized with 0.
I am ok for your modification.

Alexandre


On 7 Jun 2010, at 09:22, Fabrizio Perin wrote:

> Hi,
> the problem with this test failure is related with the implementation of lineCount method. Basically the old implementation start to count to 1 and then it adds 1 for each cr found in the string.
>
> OLD IMPLEMENTATION
>
> lineCount
> "Answer the number of lines represented by the receiver, where every cr adds one line.  5/10/96 sw"
>
> | cr count |
> cr := Character cr.
> count := 1  min: self size.
> 1 to: self size do:
> [:i | (self at: i) = cr ifTrue: [count := count + 1]].
> ^ count
>
> So for the definition of this file:
>
> file := self createFile: (self foldersString , 'fileWith9Chars4Lines2EmptyLines').
> stream := file writeStream.
> stream
> nextPutAll: '123456';
> cr;
> cr;
> nextPutAll: '789';
> cr.
>
> In the 1.0 lineCount return 4 -> 1 + 3 cr.
>
> The new lineCount method counts the lines considering only the number of cr, lf or crlf that it find in the string. So the same file definition in the 1.1 return 3 -> 3 cr.
>
> To make this test green the most logic thing it will be to add a cr in the definition of the string in such a way to fit the definition of the new method lineCount.
>
> file := self createFile: (self foldersString , 'fileWith9Chars4Lines2EmptyLines').
> stream := file writeStream.
> stream
> nextPutAll: '123456'; cr;
> cr;
> cr;
> nextPutAll: '789'; cr.
>
> If you agree i will proceed with the modification. (of course this will break the test in the 1.0)
>
> Cheers,
>
> Fabrizio
>
>
>
> _______________________________________________
> Moose-dev mailing list
> [hidden email]
> https://www.iam.unibe.ch/mailman/listinfo/moose-dev


_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Reply | Threaded
Open this post in threaded view
|

Re: MooseFileStructureImporterTest>>testFiles failure

Tudor Girba
Yes, it should start with 0, but the modification should be in the  
test, because that is the wrong one.

Cheers,
Doru


On 7 Jun 2010, at 15:32, Alexandre Bergel wrote:

> This is a bit strange. count should be initialized with 0.
> I am ok for your modification.
>
> Alexandre
>
>
> On 7 Jun 2010, at 09:22, Fabrizio Perin wrote:
>
>> Hi,
>> the problem with this test failure is related with the  
>> implementation of lineCount method. Basically the old  
>> implementation start to count to 1 and then it adds 1 for each cr  
>> found in the string.
>>
>> OLD IMPLEMENTATION
>>
>> lineCount
>> "Answer the number of lines represented by the receiver, where  
>> every cr adds one line.  5/10/96 sw"
>>
>> | cr count |
>> cr := Character cr.
>> count := 1  min: self size.
>> 1 to: self size do:
>> [:i | (self at: i) = cr ifTrue: [count := count + 1]].
>> ^ count
>>
>> So for the definition of this file:
>>
>> file := self createFile: (self foldersString ,  
>> 'fileWith9Chars4Lines2EmptyLines').
>> stream := file writeStream.
>> stream
>> nextPutAll: '123456';
>> cr;
>> cr;
>> nextPutAll: '789';
>> cr.
>>
>> In the 1.0 lineCount return 4 -> 1 + 3 cr.
>>
>> The new lineCount method counts the lines considering only the  
>> number of cr, lf or crlf that it find in the string. So the same  
>> file definition in the 1.1 return 3 -> 3 cr.
>>
>> To make this test green the most logic thing it will be to add a cr  
>> in the definition of the string in such a way to fit the definition  
>> of the new method lineCount.
>>
>> file := self createFile: (self foldersString ,  
>> 'fileWith9Chars4Lines2EmptyLines').
>> stream := file writeStream.
>> stream
>> nextPutAll: '123456'; cr;
>> cr;
>> cr;
>> nextPutAll: '789'; cr.
>>
>> If you agree i will proceed with the modification. (of course this  
>> will break the test in the 1.0)
>>
>> Cheers,
>>
>> Fabrizio
>>
>>
>>
>> _______________________________________________
>> Moose-dev mailing list
>> [hidden email]
>> https://www.iam.unibe.ch/mailman/listinfo/moose-dev
>
>
> _______________________________________________
> Moose-dev mailing list
> [hidden email]
> https://www.iam.unibe.ch/mailman/listinfo/moose-dev

--
www.tudorgirba.com

"Reasonable is what we are accustomed with."

_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev