Skip to content

merge_sort stability #3399

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

Closed
jesse99 opened this issue Sep 6, 2012 · 2 comments
Closed

merge_sort stability #3399

jesse99 opened this issue Sep 6, 2012 · 2 comments

Comments

@jesse99
Copy link
Contributor

jesse99 commented Sep 6, 2012

Don't see a unit test for that. Here is at least a basic test:

#[test]
fn test_merge_sort_stability()
{
    // not sure why we can't use just &
    pure fn ile(x: &@str, y: &@str) -> bool
    {
        unchecked            // to_lower is not pure...
        {
            let x = x.to_lower();
            let y = y.to_lower();
            x <= y
        }
    }

    let names1 = ~[@"joe bob", @"Joe Bob", @"Jack Brown", @"JOE Bob", @"Sally Mae", @"JOE BOB", @"Alex Andy"];
    let names2 = ~[@"Alex Andy", @"Jack Brown", @"joe bob", @"Joe Bob", @"JOE Bob", @"JOE BOB", @"Sally Mae"];
    let names3 = std::sort::merge_sort(ile, names1);
    assert names3 == names2;
}
@pcwalton
Copy link
Contributor

pcwalton commented Sep 6, 2012

(Regarding the comment: &&static/str should work, if you remove the @s from the arrays.)

@pcwalton
Copy link
Contributor

pcwalton commented Sep 6, 2012

to_lower and to_upper are pure now.

RalfJung pushed a commit to RalfJung/rust that referenced this issue Mar 25, 2024
make CI failures easier to interpret

RUST_BACKTRACE=1 means we show 2 backtraces that are almost always irrelevant: from ui_test and from the miri script. Instead let's set the env var inside the test harness so we see backtraces of Miri ICEing but nothing else.
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

No branches or pull requests

3 participants