HaxeFoundation / haxe

Haxe - The Cross-Platform Toolkit
https://haxe.org
6.14k stars 656 forks source link

Make String.indexOf actually conform to some specification #11569

Closed Simn closed 7 months ago

Simn commented 7 months ago

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:

Closes #8365 Closes #11567

Simn commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

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.