[squeak-dev] TestRunner not assigning strings/remembering old values of temp vars.

Nicolas Cellier nicolas.cellier.aka.nice at gmail.com
Sun Jul 25 08:19:16 UTC 2010


2010/7/25 Rob Withers <reefedjib at yahoo.com>:
>
>
> --------------------------------------------------
> From: "Nicolas Cellier" <nicolas.cellier.aka.nice at gmail.com>
> Sent: Sunday, July 25, 2010 4:09 AM
> To: "The general-purpose Squeak developers list"
> <squeak-dev at lists.squeakfoundation.org>
> Subject: Re: [squeak-dev] TestRunner not assigning strings/remembering old
> values of temp vars.
>
>> There is no immutable support in Squeak.
>> Smalltalk custom is to avoid overwriting literals like String Array...
>> ...Same for instances of other classes like Point Rectangle which are
>> likely to be shared by several objects.
>> Most algorithms will rather modify and answer a copy.
>> This default behaviour has a cost (creates lots of objects) but is
>> fool proof (no danger to overwrite a shared information).
>>
>> For DES, I don't know, maybe it's just an optimization you must be aware
>> of.
>> In that case, you are responsible for creating the copy by yourself
>> when required.
>
>
> You mean before calling encryptBlock:/decryptBlock: with string data, we
> should copy the string data.  That's unfortunate.  It works fine with
> ByteArrays.
>

No, if you use a literal ByteArray with #[   ] notations, you'll get
same symptoms as with a String literal.

Nicolas

> Thanks for the info!
> Rob
>
>>
>> Nicolas
>>
>> 2010/7/25 Rob Withers <reefedjib at yahoo.com>:
>>>
>>> Thanks, that makes sense.  Isn't that a bug since Strings are mutable?
>>>
>>> --------------------------------------------------
>>> From: "Nicolas Cellier" <nicolas.cellier.aka.nice at gmail.com>
>>> Sent: Sunday, July 25, 2010 3:51 AM
>>> To: "The general-purpose Squeak developers list"
>>> <squeak-dev at lists.squeakfoundation.org>
>>> Subject: Re: [squeak-dev] TestRunner not assigning strings/remembering
>>> old
>>> values of temp vars.
>>>
>>>> Of course, 'squeaker' is a literal stored in the CompiledMethod.
>>>> If you write over it, then you break the literal for next method
>>>> execution.
>>>>
>>>> Each time you evaluate in a workspace, you create a new CompiledMethod
>>>> and a new literal.
>>>> When you compile in a class, that's different because you compiled
>>>> only once and execute many.
>>>>
>>>> Nicolas
>>>>
>>>> 2010/7/25 Rob Withers <reefedjib at yahoo.com>:
>>>>>
>>>>> I am testing the CryptoDESTest.  I am getting some strange behavior.
>>>>> When
>>>>> I
>>>>> run the following code in a Workspace, repeatably, I get the same
>>>>> results:
>>>>>
>>>>> code:
>>>>>
>>>>>      | plain key d |
>>>>>      plain := 'squeaker'.
>>>>>      key := 'hacking!'.
>>>>>      Transcript cr; show: 'plain: ', plain printString.
>>>>>      d := DES key: key.
>>>>>      d encryptBlock: plain.
>>>>>      Transcript cr; show: 'plain: ', plain printString.
>>>>>      self assert: plain asByteArray = #[64 222 70 13 59 145 76 186].
>>>>>      plain destroy.
>>>>>
>>>>> output:
>>>>>
>>>>> plain: 'squeaker'
>>>>> plain: '@ÞF
>>>>> ;‘Lº'
>>>>> plain: 'squeaker'
>>>>> plain: '@ÞF
>>>>> ;‘Lº'
>>>>> plain: 'squeaker'
>>>>> plain: '@ÞF
>>>>> ;‘Lº'
>>>>>
>>>>> However, when I run this as a test method:
>>>>>
>>>>> testDES3
>>>>>      | plain key d |
>>>>>      plain := 'squeaker'.
>>>>>      key := 'hacking!'.
>>>>>      Transcript cr; show: 'plain: ', plain printString.
>>>>>      d := DES key: key.
>>>>>      d encryptBlock: plain.
>>>>>      Transcript cr; show: 'plain: ', plain printString.
>>>>>      self assert: plain asByteArray = #[64 222 70 13 59 145 76 186].
>>>>>             plain destroy.
>>>>>
>>>>> I get the following output and the test fails:
>>>>>
>>>>> plain: 'squeaker'
>>>>> plain: '@ÞF
>>>>> ;‘Lº'
>>>>> plain: '        '
>>>>> plain: '£ƒ¼ïùmÞ$'
>>>>> plain: '£ƒ¼ïùmÞ$'
>>>>> plain: '§,}ºé¨öú'
>>>>> plain: '§,}ºé¨öú'
>>>>> plain: '3qX¦wRË|'
>>>>> plain: '3qX¦wRË|'
>>>>> plain: 'Ê0ê^ó{ì '
>>>>> plain: 'Ê0ê^ó{ì '
>>>>> plain: 'çî³›,ίw'
>>>>>
>>>>> Why is test runner remembering the old value and not setting it with:
>>>>> plain
>>>>> := 'squeaker'.?
>>>>>
>>>>> TIA,
>>>>> Rob
>>>>>
>>>>>
>>>>
>>>
>>>
>>
>
>



More information about the Squeak-dev mailing list