Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make String.indexOf actually conform to some specification #11569

Merged
merged 10 commits into from Feb 9, 2024

Conversation

Simn
Copy link
Member

@Simn Simn commented Feb 9, 2024

Coming from #8370, let's see how our targets conform to JS/Java specification. There's a wonky corner case here with the empty search string, where even MDN admits that "Searching for an empty search string produces strange results."

Edit: Results are in:

  • Eval
  • Php
  • Python
  • Neko
  • Lua

Closes #8365
Closes #11567

@skial skial mentioned this pull request Feb 9, 2024
1 task
@Simn
Copy link
Member Author

Simn commented Feb 9, 2024

Js, Hl, Cpp and Jvm pass.

Eval, Php and Python fail with this:

    line: 61, expected -1 but it is 0
    line: 62, expected -1 but it is 1
    line: 63, expected -1 but it is 3
    line: 64, expected -1 but it is 4
    line: 65, expected -1 but it is 5

Neko fails with those plus one more:

    line: 66, expected -1 but it is 6

Lua fails like neko plus one more (which is already tracked in #11567):

    line: 60, expected 6 but it is 0

@Simn
Copy link
Member Author

Simn commented Feb 9, 2024

I have fixed Eval and the implementation on UnicodeString. This is a specification change, but I doubt that anyone relied on this behavior there was a disconnect between UnicodeString and non-UnicodeString already anyway, so it's good to clean that up.

@Simn
Copy link
Member Author

Simn commented Feb 9, 2024

Fixed python and neko as well. I don't have local php and lua installations, but I'll attempt a blind fix on PHP at least.

@Simn
Copy link
Member Author

Simn commented Feb 9, 2024

Documenting this crap is harder than implementing it... I hope I got all the intricacies right now. This whole special situation with "" is very silly.

@Simn Simn merged commit 0e71626 into development Feb 9, 2024
94 checks passed
@Simn Simn deleted the String.indexOf_negative_startIndex branch February 9, 2024 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[lua] empty dog indexOf should be 0 but is 2 Test String.indexOf(s, startIndex) for negative startIndex
1 participant