v8/test/intl/regress-1347690.js
Frank Tang ce9b1b2ab0 [intl] Remove incorrect optimization for 0 length string
In collator and localeCompare, we have an incorrect optimization
for zero length string that compare the length and ignore the
fact some non zero length string could be considered as equal to
a zero length string because the content are all ignoreable.

Took out this incorrect optimization with test cases.

The regression is introduced in
6fbb8bc806 which first appeared in 97.0.4665.0



Bug: chromium:1347690
Change-Id: Ie70feb9598b1842f8a8744c38f33b3397865abfd
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3832526
Reviewed-by: Shu-yu Guo <syg@chromium.org>
Reviewed-by: Jakob Linke <jgruber@chromium.org>
Commit-Queue: Frank Tang <ftang@chromium.org>
Cr-Commit-Position: refs/heads/main@{#82632}
2022-08-22 18:44:18 +00:00

20 lines
807 B
JavaScript

// Copyright 2022 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Comparison to empty string could return zero for certain Unicode character.
// In all locales, some Unicode characters are ignorable.
// Unicode in C0
assertEquals(0, (new Intl.Collator('en')).compare("","\u0001"));
// SOFT HYPHEN
assertEquals(0, (new Intl.Collator('en')).compare("","\u00AD"));
// ARABIC SIGN SAMVAT
assertEquals(0, (new Intl.Collator('en')).compare("","\u0604"));
assertEquals(0, (new Intl.Collator('en')).compare("","\u0001\u0002\u00AD\u0604"));
// Default Thai collation ignores punctuation.
assertEquals(0, (new Intl.Collator('th')).compare(""," "));
assertEquals(0, (new Intl.Collator('th')).compare("","*"));