Skip to content

Test that string comparison is per-code-unit#4457

Merged
Ms2ger merged 2 commits intotc39:mainfrom
andreubotella:code-unit-string-comparison-tests
Apr 18, 2025
Merged

Test that string comparison is per-code-unit#4457
Ms2ger merged 2 commits intotc39:mainfrom
andreubotella:code-unit-string-comparison-tests

Conversation

@andreubotella
Copy link
Copy Markdown
Member

The Ecma-262 specification describes string comparison as comparing lexicographically a string's code units. This is different from comparing by code points (see the readme to the compare strings by codepoint proposal).

However, the existing string comparison tests describe the spec's behavior as comparing by code points (which is wrong), and do not include any tests covering lone surrogates or characters greater than U+FFFF, which is when the difference appears. This patch fixes those descriptions, and adds some such missing tests.

The Ecma-262 specification describes string comparison as comparing
lexicographically a string's code units. This is different from
comparing by code points (see the readme to the [compare strings by
codepoint proposal](https://github.com/tc39/proposal-compare-strings-by-codepoint)).

However, the existing string comparison tests describe the spec's
behavior as comparing by code points (which is wrong), and do not
include any tests covering lone surrogates or characters greater than
U+FFFF, which is when the difference appears. This patch fixes those
descriptions, and adds some such missing tests.
@andreubotella andreubotella requested a review from a team as a code owner April 18, 2025 04:09
Copy link
Copy Markdown
Contributor

@Ms2ger Ms2ger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those files could use a 21st century rewrite...

@Ms2ger Ms2ger merged commit c5257e6 into tc39:main Apr 18, 2025
11 checks passed
@andreubotella andreubotella deleted the code-unit-string-comparison-tests branch May 3, 2025 15:51
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.

2 participants