summaryrefslogtreecommitdiffstats
path: root/tests/ui/self/string-self-append.rs
blob: e63dc0090cb7ffbef36902b7f39acbaaf2fd0095 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
// run-pass
pub fn main() {
    // Make sure we properly handle repeated self-appends.
    let mut a: String = "A".to_string();
    let mut i = 20;
    let mut expected_len = 1;
    while i > 0 {
        println!("{}", a.len());
        assert_eq!(a.len(), expected_len);
        a = format!("{}{}", a, a);
        i -= 1;
        expected_len *= 2;
    }
}