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
16 changes: 10 additions & 6 deletions test/stdlib/NewStringAppending.swift
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,18 @@ print("\(repr(s))")
// CHECK-LABEL: (expecting third reallocation)
print("(expecting third reallocation)")

// CHECK-NEXT: String(Native(owner: @[[storage3:[x0-9a-f]+]], count: 72, capacity: 135))
// CHECK-NOT: @[[storage2]],
// FIXME: Now that test behavior depends on result of malloc_size, we should
// rewrite this test for larger allocations. For now, disable the hard-coded
// checks.

// xCHECK-NEXT: String(Native(owner: @[[storage3:[x0-9a-f]+]], count: 72, capacity: 135))
// xCHECK-NOT: @[[storage2]],
s += "1234567890123456"
print("\(repr(s))")

var s1 = s

// CHECK-NEXT: String(Native(owner: @[[storage3]], count: 72, capacity: 135))
// xCHECK-NEXT: String(Native(owner: @[[storage3]], count: 72, capacity: 135))
print("\(repr(s1))")

/// The use of later buffer capacity by another string forces
Expand All @@ -133,19 +137,19 @@ print("\(repr(s1))")
// CHECK-LABEL: (expect copy to trigger reallocation without growth)
print("(expect copy to trigger reallocation without growth)")

// CHECK-NEXT: String(Native(owner: @[[storage4:[x0-9a-f]+]], count: 73, capacity: 87)) = "{{.*}}X"
// CHECK-NEXT: String(Native(owner: @[[storage4:[x0-9a-f]+]], count: 73, capacity: 87)) = "{{.*}}X"
// CHECK-NOT: @[[storage3]],
s1 += "X"
print("\(repr(s1))")

/// The original copy is left unchanged

// CHECK-NEXT: String(Native(owner: @[[storage3]], count: 72, capacity: 135))
// xCHECK-NEXT: String(Native(owner: @[[storage3]], count: 72, capacity: 135))
print("\(repr(s))")

/// Appending to an empty string re-uses the RHS

// CHECK-NEXT: @[[storage3]],
// xCHECK-NEXT: @[[storage3]],
var s2 = String()
s2 += s
print("\(repr(s2))")