Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 39 additions & 15 deletions tests/by-util/test_sort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3025,22 +3025,46 @@ fn test_consistent_sorting_with_i18n_collate() {
}

#[test]
fn test_sort_locale_punctuation_weights() {
// Test for issue #12542
let input = "file10\nfile-10\n";
let expected_output = "file-10\nfile10\n";

new_ucmd!()
.env("LC_ALL", "en_US.UTF-8")
.pipe_in(input)
.succeeds()
.stdout_is(expected_output);
fn test_sort_locale_punctuation() {
// Punctuation gets a distinguishing collation weight, so lines differing
// only by punctuation sort in a stable order (issue #12542) and are never
// merged by -u. This holds across the plain, explicit-key and stable paths,
// and in both locales. The wildcard-domain case comes from dehydrated, which
// relied on -u keeping a `*.domain.com` alias distinct from the bare domain.
// (input, expected, [(locale, args)...])
let cases = [
(
"file10\nfile-10\n",
"file-10\nfile10\n",
&[("en_US.UTF-8", &[][..]), ("C", &[][..])][..],
),
(
"EU\nE.U\nE-U\n",
"E-U\nE.U\nEU\n",
&[
("en_US.UTF-8", &["-u"][..]),
("C", &["-u"][..]),
("en_US.UTF-8", &["-u", "-k1,1"][..]),
("en_US.UTF-8", &["-s", "-k1,1"][..]),
][..],
),
(
"domain.com\n*.domain.com\ndomain.com\n",
"*.domain.com\ndomain.com\n",
&[("en_US.UTF-8", &["-u"][..]), ("C", &["-u"][..])][..],
),
];

new_ucmd!()
.env("LC_ALL", "C")
.pipe_in(input)
.succeeds()
.stdout_is(expected_output);
for (input, expected, runs) in cases {
for (locale, args) in runs {
new_ucmd!()
.env("LC_ALL", *locale)
.args(args)
.pipe_in(input)
.succeeds()
.stdout_is(expected);
}
}
}

/* spell-checker: enable */
Loading