Skip to content

Empty subcollection tests fail on latest Pharo and Squeak versions #147

Closed

Description

@marschall

Our tests for #beginsWithSubCollection: and #endsWithSubCollection: with empty arguments fail on the latest Pharo and Squeak versions. It looks like they changed the behavior of #beginsWith: and #endsWith:

The current expectation seems to be based on ANSI #indexOfSubCollection:startingAt: which states

Answer 0 if no such subsequence is found in the receiver, or if targetSequence is empty.

An illustrative example

#(1 2 3) beginsWithSubCollection: #(1). "true"
#(1 2 3) beginsWithSubCollection: #(). "false in Pharo 10 and Squeak
5, true in Pharo 11 and Squeak 6 "

#(1 2 3) endsWithSubCollection: #(3). "true"
#(1 2 3) endsWithSubCollection: #(). "false in Pharo 10 and Squeak 5,
true in Pharo 11 and Squeak 6 "

There are several possible solutions, the ones with the least chance of blast damage seem to be:

  • remove the empty argument tests, we don't seem to have any senders with empty arguments
  • introduce #greaseBeginsWithSubCollection: and #greaseEndsWithSubCollection;

See http://lists.squeakfoundation.org/pipermail/seaside-dev/2022-September/007363.html

Activity

  1. JupiterJones commented on Sep 2, 2022

    @JupiterJones

    This bug in Pharo (and squeak, I think) was fixed back in May. Still, there will be versions out there with the bug still present.

    See beginsWith: and endsWith: should return true on empty string

  2. added a commit that references this issue on Sep 14, 2022
    26791fb
  3. jbrichau commented on Sep 16, 2022

    @jbrichau
    Member

    Removing the tests fixes the tests but Grease for GemStone actually adds endsWithSubCollection and beginsWithSubCollection to GLASS/GsDevKit and implements the behaviour of Pharo 10:

    With Grease being part of GLASS, there can be projects depending on these 'old' semantics if we would change this to be in line with Pharo 11. Question is: should we change the existing implementation in the GemStone package or, as removing the test would imply, leave out the compatibility from Grease since Seaside does not actually rely on this compatibility?

    Maybe @dalehenrich has a thought?

  4. dalehenrich commented on Sep 16, 2022

    @dalehenrich
    Member

    @jbrichau if I read this correctly, you seem to be planning on introducing grease variants of those two methods and you will stop using beginsWithSubCollection: and endsWithSubCollection: in Seaside ... so that seems to be the most reasonable way of introducing new behavior and I'm inclined to leave the current GemStone implementation as is and then users will have the ability to pick and choose the implementation that they prefer ...

  5. jbrichau commented on Feb 5, 2023

    @jbrichau
    Member

    To give all users of Grease the chance to convert and adapt to the new behavior, new methods are introduced and the old ones keep their current behavior. See #157

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions