still failing test

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

still failing test

Roelof
Hello,

I trying to make the make you own method work.

So I first I added this :

testShout
   self assert: ('Don''t panic' shout = 'DON""T PANIC!')

After that I added this as described in the book.
shout
   ^  self asUppercase. "!"

But still the testrunner gives that there is a failing test on testShout.

Roelof


Reply | Threaded
Open this post in threaded view
|

Re: still failing test

Sergi Reyner
2014-03-30 18:55 GMT+01:00 Roelof Wobben <[hidden email]>:
testShout
  self assert: ('Don''t panic' shout = 'DON""T PANIC!')
 
You properly doubled the single quote inside the first string. However, you used two double quotes inside the second string; replace them with two single quotes.

You also have an exclamation sign in the second string which is not in the first one. Remove it and the test will pass. Note that the exclamation mark in the following method is inside a comment:


After that I added this as described in the book.
shout
  ^  self asUppercase. "!"
 
This is fine. The ending period is not needed, though. Periods work as statement separators in Smalltalk, not terminators as semicolons in C, for example.


If you really want to have an exclamation mark added to the string, you should implement shout as this:

shout
    ^ self asUppercase , '!'


Cheers,
Sergi
Reply | Threaded
Open this post in threaded view
|

Re: still failing test

Ben Coman
In reply to this post by Roelof
Roelof Wobben wrote:

> Hello,
>
> I trying to make the make you own method work.
>
> So I first I added this :
>
> testShout
>   self assert: ('Don''t panic' shout = 'DON""T PANIC!')
>
> After that I added this as described in the book.
> shout
>   ^  self asUppercase. "!"
>
> But still the testrunner gives that there is a failing test on testShout.
>
> Roelof
>
>
>
Rather than just feed you a fish, a little teaching how to fish :)
I would highlight and Inspect each side of the equals sign - so you can
look at each string next to the other.  Two things to think about:
* commas versus periods
* different types of quote marks
I'll follow up with the answer in the next post.
cheers -ben

Reply | Threaded
Open this post in threaded view
|

Re: still failing test

Roelof
Ben Coman schreef op 30-3-2014 20:12:

> Roelof Wobben wrote:
>> Hello,
>>
>> I trying to make the make you own method work.
>>
>> So I first I added this :
>>
>> testShout
>>   self assert: ('Don''t panic' shout = 'DON""T PANIC!')
>>
>> After that I added this as described in the book.
>> shout
>>   ^  self asUppercase. "!"
>>
>> But still the testrunner gives that there is a failing test on
>> testShout.
>>
>> Roelof
>>
>>
>>
> Rather than just feed you a fish, a little teaching how to fish :)
> I would highlight and Inspect each side of the equals sign - so you
> can look at each string next to the other.  Two things to think about:
> * commas versus periods
> * different types of quote marks
> I'll follow up with the answer in the next post.
> cheers -ben
>
>

Oke, I do not see it
I have now this : self assert: ('Dont panic!' shout = 'DONT PANIC!')
and for me it looks the same and still the test is failing.

and the other part has changed to  ^ self asUppercase, '!'

Roelof




Reply | Threaded
Open this post in threaded view
|

Re: still failing test

Ben Coman
Roelof Wobben wrote:

> Ben Coman schreef op 30-3-2014 20:12:
>> Roelof Wobben wrote:
>>> Hello,
>>>
>>> I trying to make the make you own method work.
>>>
>>> So I first I added this :
>>>
>>> testShout
>>>   self assert: ('Don''t panic' shout = 'DON""T PANIC!')
>>>
>>> After that I added this as described in the book.
>>> shout
>>>   ^  self asUppercase. "!"
>>>
>>> But still the testrunner gives that there is a failing test on
>>> testShout.
>>>
>>> Roelof
>>>
>>>
>>>
>> Rather than just feed you a fish, a little teaching how to fish :)
>> I would highlight and Inspect each side of the equals sign - so you
>> can look at each string next to the other.  Two things to think about:
>> * commas versus periods
>> * different types of quote marks
>> I'll follow up with the answer in the next post.
>> cheers -ben
>>
>>
>
> Oke, I do not see it
> I have now this : self assert: ('Dont panic!' shout = 'DONT PANIC!')
> and for me it looks the same and still the test is failing.
>
> and the other part has changed to  ^ self asUppercase, '!'
>
> Roelof
>
This must be a little frustrating for you :)  but like a lot of things
its a matter a "getting your eye in".
I hope you persist. You are almost there.  You've made an additional
change to the left hand side. I think if you again Inspect both sides of
equals sign and compare the results it should become clear.

Now as an additional learning task, the other way to "fish" is to use
the debugger.  Highlight...
    'Dont panic!' shout
and from the context menu choose to Debug. Then step Into the #shout
method.  Once the debugger has moved into the #shout method, highlight
and Inspect the following...
    self
    self asUppercase
    self asUppercase, '!'

The precise answer is my next post.
cheers -ben

Reply | Threaded
Open this post in threaded view
|

Re: still failing test - spoiler/answer

Ben Coman
Ben Coman wrote:

> Roelof Wobben wrote:
>> Ben Coman schreef op 30-3-2014 20:12:
>>> Roelof Wobben wrote:
>>>> Hello,
>>>>
>>>> I trying to make the make you own method work.
>>>>
>>>> So I first I added this :
>>>>
>>>> testShout
>>>>   self assert: ('Don''t panic' shout = 'DON""T PANIC!')
>>>>
>>>> After that I added this as described in the book.
>>>> shout
>>>>   ^  self asUppercase. "!"
>>>>
>>>> But still the testrunner gives that there is a failing test on
>>>> testShout.
>>>>
>>>> Roelof
>>>>
>>>>
>>>>
>>> Rather than just feed you a fish, a little teaching how to fish :)
>>> I would highlight and Inspect each side of the equals sign - so you
>>> can look at each string next to the other.  Two things to think about:
>>> * commas versus periods
>>> * different types of quote marks
>>> I'll follow up with the answer in the next post.
>>> cheers -ben
>>>
>>>
>>
>> Oke, I do not see it
>> I have now this : self assert: ('Dont panic!' shout = 'DONT PANIC!')
>> and for me it looks the same and still the test is failing.
>>
>> and the other part has changed to  ^ self asUppercase, '!'
>>
>> Roelof
>>
> This must be a little frustrating for you :)  but like a lot of things
> its a matter a "getting your eye in".
> I hope you persist. You are almost there.  You've made an additional
> change to the left hand side. I think if you again Inspect both sides
> of equals sign and compare the results it should become clear.
>
> Now as an additional learning task, the other way to "fish" is to use
> the debugger.  Highlight...
>    'Dont panic!' shout
> and from the context menu choose to Debug. Then step Into the #shout
> method.  Once the debugger has moved into the #shout method, highlight
> and Inspect the following...
>    self
>    self asUppercase
>    self asUppercase, '!'
>
> The precise answer is my next post.
> cheers -ben
>
>
You added an exclamation mark to the left hand side of the comparison
that was not there before, so presuably the left hand side ends up as
'DONT PANIC!!' since the #shout method also appends an exclamation mark
using the comma operator.
cheers -ben

Reply | Threaded
Open this post in threaded view
|

Re: still failing test - spoiler/answer

Roelof
Ben Coman schreef op 31-3-2014 2:44:

> Ben Coman wrote:
>> Roelof Wobben wrote:
>>> Ben Coman schreef op 30-3-2014 20:12:
>>>> Roelof Wobben wrote:
>>>>> Hello,
>>>>>
>>>>> I trying to make the make you own method work.
>>>>>
>>>>> So I first I added this :
>>>>>
>>>>> testShout
>>>>>   self assert: ('Don''t panic' shout = 'DON""T PANIC!')
>>>>>
>>>>> After that I added this as described in the book.
>>>>> shout
>>>>>   ^  self asUppercase. "!"
>>>>>
>>>>> But still the testrunner gives that there is a failing test on
>>>>> testShout.
>>>>>
>>>>> Roelof
>>>>>
>>>>>
>>>>>
>>>> Rather than just feed you a fish, a little teaching how to fish :)
>>>> I would highlight and Inspect each side of the equals sign - so you
>>>> can look at each string next to the other.  Two things to think about:
>>>> * commas versus periods
>>>> * different types of quote marks
>>>> I'll follow up with the answer in the next post.
>>>> cheers -ben
>>>>
>>>>
>>>
>>> Oke, I do not see it
>>> I have now this : self assert: ('Dont panic!' shout = 'DONT PANIC!')
>>> and for me it looks the same and still the test is failing.
>>>
>>> and the other part has changed to  ^ self asUppercase, '!'
>>>
>>> Roelof
>>>
>> This must be a little frustrating for you :)  but like a lot of
>> things its a matter a "getting your eye in".
>> I hope you persist. You are almost there.  You've made an additional
>> change to the left hand side. I think if you again Inspect both sides
>> of equals sign and compare the results it should become clear.
>>
>> Now as an additional learning task, the other way to "fish" is to use
>> the debugger.  Highlight...
>>    'Dont panic!' shout
>> and from the context menu choose to Debug. Then step Into the #shout
>> method.  Once the debugger has moved into the #shout method,
>> highlight and Inspect the following...
>>    self
>>    self asUppercase
>>    self asUppercase, '!'
>>
>> The precise answer is my next post.
>> cheers -ben
>>
>>
> You added an exclamation mark to the left hand side of the comparison
> that was not there before, so presuably the left hand side ends up as
> 'DONT PANIC!!' since the #shout method also appends an exclamation
> mark using the comma operator.
> cheers -ben
>
>

Thanks for learning me how to fish.
You are right. I learn more this way then simply say where I went wrong.

Roelof