The Trunk: CollectionsTests-eem.287.mcz

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

The Trunk: CollectionsTests-eem.287.mcz

commits-2
Eliot Miranda uploaded a new version of CollectionsTests to project The Trunk:
http://source.squeak.org/trunk/CollectionsTests-eem.287.mcz

==================== Summary ====================

Name: CollectionsTests-eem.287
Author: eem
Time: 22 December 2017, 2:14:32.454096 am
UUID: 4ae7ecb8-a1b6-474b-a90a-b35d04536b8a
Ancestors: CollectionsTests-eem.286

Fix ByteArrayTest>>testFallbackReplaceFromToWith

=============== Diff against CollectionsTests-eem.286 ===============

Item was changed:
  ----- Method: ByteArrayTest>>testFallbackReplaceFromToWith (in category 'testing') -----
  testFallbackReplaceFromToWith
  | teststring ba sz cm |
+ teststring := 'Test string' asByteArray.
+ sz := teststring byteSize.
- teststring := 'Test string'.
- sz := 'Test string' byteSize.
  ba := ByteArray new: sz.
  cm := SequenceableCollection compiledMethodAt: #replaceFrom:to:with:startingAt:.
  self shouldnt: [cm valueWithReceiver: ba arguments: {1. sz. teststring. 1}]
  raise: Exception
  description: 'Primitive 105 should be optional for ByteArray'
  !


Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: CollectionsTests-eem.287.mcz

Eliot Miranda-2
Hi Tim,

    I changed this test to make it pass; the error raised was because teststring was a string and so the SequenceableCollection fallback failed trying to copy characters into the ByteArray.  But I wonder whether your intent was to say that the SequenceableCollection fallback should work the same as the primitive which does allow copying of characters into a ByteArray.  If so I don't think the problem should be solved in SequenceableCollection's fallback.  Instead, the ByteArray primitive failure code (ByteArray>>#replaceFrom:to:with:startingAt: itself) is the place to implement coercion.

Arguably the primitive is at fault not checking for type compatibility but I get that it's convenient to have a genetic byte mover.  But we use the primitive in most of the integer arrays and so can arbitrarily store characters in them.  In which case the primitive failure code should look like

    ^super replaceFrom: startIndex to: stopIndex with: aCollection coercionMessage startingAt: repStart

where coercionMessage is asByteString asByteArray, asWideString etc as appropriate.  What do you think?

_,,,^..^,,,_ (phone)

> On Dec 22, 2017, at 2:14 AM, [hidden email] wrote:
>
> Eliot Miranda uploaded a new version of CollectionsTests to project The Trunk:
> http://source.squeak.org/trunk/CollectionsTests-eem.287.mcz
>
> ==================== Summary ====================
>
> Name: CollectionsTests-eem.287
> Author: eem
> Time: 22 December 2017, 2:14:32.454096 am
> UUID: 4ae7ecb8-a1b6-474b-a90a-b35d04536b8a
> Ancestors: CollectionsTests-eem.286
>
> Fix ByteArrayTest>>testFallbackReplaceFromToWith
>
> =============== Diff against CollectionsTests-eem.286 ===============
>
> Item was changed:
>  ----- Method: ByteArrayTest>>testFallbackReplaceFromToWith (in category 'testing') -----
>  testFallbackReplaceFromToWith
>      | teststring ba sz cm |
> +    teststring := 'Test string' asByteArray.
> +    sz := teststring byteSize.
> -    teststring := 'Test string'.
> -    sz := 'Test string' byteSize.
>      ba := ByteArray new: sz.
>      cm := SequenceableCollection compiledMethodAt: #replaceFrom:to:with:startingAt:.
>      self shouldnt: [cm valueWithReceiver: ba arguments: {1. sz. teststring. 1}]
>          raise: Exception
>          description: 'Primitive 105 should be optional for ByteArray'
>  !
>
>