summaryrefslogtreecommitdiffstats
path: root/tests/ui/self/string-self-append.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/self/string-self-append.rs')
-rw-r--r--tests/ui/self/string-self-append.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/ui/self/string-self-append.rs b/tests/ui/self/string-self-append.rs
new file mode 100644
index 000000000..e63dc0090
--- /dev/null
+++ b/tests/ui/self/string-self-append.rs
@@ -0,0 +1,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;
+ }
+}