|
| 1 | +// RUN: %target-run-stdlib-swift |
| 2 | +// REQUIRES: executable_test |
| 3 | + |
| 4 | +import StdlibUnittest |
| 5 | + |
| 6 | +var SortABITestSuite = TestSuite("SortABI") |
| 7 | + |
| 8 | +SortABITestSuite.test("_merge-ABI") { |
| 9 | + let result = withUnsafeTemporaryAllocation(of: Int.self, capacity: 10) { |
| 10 | + buffer -> Bool in |
| 11 | + _ = buffer.initialize(from: 0..<10) |
| 12 | + return withUnsafeTemporaryAllocation(of: Int.self, capacity: 10) { |
| 13 | + _merge( |
| 14 | + low: buffer.baseAddress! + 5, |
| 15 | + mid: buffer.baseAddress! + 8, |
| 16 | + high: buffer.baseAddress! + 9, |
| 17 | + buffer: $0.baseAddress!, |
| 18 | + by: < |
| 19 | + ) |
| 20 | + } |
| 21 | + } |
| 22 | + // The return value is legacy ABI. It was originally added as a |
| 23 | + // workaround for a compiler bug (now fixed). See SR-14750 (rdar://45044610). |
| 24 | + // `_merge` always returns `true` |
| 25 | + expectEqual(result, true) |
| 26 | +} |
| 27 | + |
| 28 | +SortABITestSuite.test("_mergeRuns-ABI") { |
| 29 | + let result = withUnsafeTemporaryAllocation(of: Int.self, capacity: 10) { |
| 30 | + temp -> Bool in |
| 31 | + _ = temp.initialize(from: 0..<10) |
| 32 | + var buffer = temp |
| 33 | + var runs = [5..<8, 8..<9] |
| 34 | + return withUnsafeTemporaryAllocation(of: Int.self, capacity: 10) { |
| 35 | + buffer._mergeRuns(&runs, at: 1, buffer: $0.baseAddress!, by: <) |
| 36 | + } |
| 37 | + } |
| 38 | + // The return value is legacy ABI. It was originally added as a |
| 39 | + // workaround for a compiler bug (now fixed). See SR-14750 (rdar://45044610). |
| 40 | + // `_mergeRuns` always returns `true` |
| 41 | + expectEqual(result, true) |
| 42 | +} |
| 43 | + |
| 44 | +SortABITestSuite.test("_mergeTopRuns-ABI") { |
| 45 | + let result = withUnsafeTemporaryAllocation(of: Int.self, capacity: 10) { |
| 46 | + temp -> Bool in |
| 47 | + _ = temp.initialize(from: 0..<10) |
| 48 | + var buffer = temp |
| 49 | + var runs = [5..<8, 8..<9] |
| 50 | + return withUnsafeTemporaryAllocation(of: Int.self, capacity: 10) { |
| 51 | + buffer._mergeTopRuns(&runs, buffer: $0.baseAddress!, by: <) |
| 52 | + } |
| 53 | + } |
| 54 | + // The return value is legacy ABI. It was originally added as a |
| 55 | + // workaround for a compiler bug (now fixed). See SR-14750 (rdar://45044610). |
| 56 | + // `_mergeTopRuns` always returns `true` |
| 57 | + expectEqual(result, true) |
| 58 | +} |
| 59 | + |
| 60 | +SortABITestSuite.test("_finalizeRuns-ABI") { |
| 61 | + let result = withUnsafeTemporaryAllocation(of: Int.self, capacity: 10) { |
| 62 | + temp -> Bool in |
| 63 | + _ = temp.initialize(from: 0..<10) |
| 64 | + var buffer = temp |
| 65 | + var runs = [5..<8, 8..<9] |
| 66 | + return withUnsafeTemporaryAllocation(of: Int.self, capacity: 10) { |
| 67 | + buffer._finalizeRuns(&runs, buffer: $0.baseAddress!, by: <) |
| 68 | + } |
| 69 | + } |
| 70 | + // The return value is legacy ABI. It was originally added as a |
| 71 | + // workaround for a compiler bug (now fixed). See SR-14750 (rdar://45044610). |
| 72 | + // `_finalizeRuns` always returns `true` |
| 73 | + expectEqual(result, true) |
| 74 | +} |
| 75 | + |
| 76 | +runAllTests() |
0 commit comments