async fn foo(n) {
    n
}

#[test]
async fn select_branches() {
    let count = 0;
    let sum = 0;

    let a = foo(42);
    let b = foo(43);

    for _ in 0..4 {
        let value = select {
            value = a => value,
            value = b => value,
        };

        if let () = value {
            break;
        }

        count += 1;
        sum += value;
    }

    assert_eq!(count, 2);
    assert_eq!(sum, 85);
}

#[test]
async fn select_with_defaults() {
    let count = 0;
    let sum = 0;

    let a = foo(42);
    let b = foo(43);

    for _ in 0..4 {
        let value = select {
            value = a => value,
            value = b => value,
            default => 10,
        };

        if let () = value {
            break;
        }

        count += 1;
        sum += value;
    }

    assert_eq!(count, 4);
    assert_eq!(sum, 105);
}
