|
| 1 | +//===--- SlabSpan.swift ---------------------------------------------------===// |
| 2 | +// |
| 3 | +// This source file is part of the Swift.org open source project |
| 4 | +// |
| 5 | +// Copyright (c) 2025 Apple Inc. and the Swift project authors |
| 6 | +// Licensed under Apache License v2.0 with Runtime Library Exception |
| 7 | +// |
| 8 | +// See https://swift.org/LICENSE.txt for license information |
| 9 | +// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors |
| 10 | +// |
| 11 | +//===----------------------------------------------------------------------===// |
| 12 | + |
| 13 | +// RUN: %target-run-stdlib-swift(-enable-experimental-feature LifetimeDependence -enable-experimental-feature Span -enable-experimental-feature AddressableTypes -enable-experimental-feature ValueGenerics) |
| 14 | + |
| 15 | +// REQUIRES: executable_test |
| 16 | +// REQUIRES: swift_feature_ValueGenerics |
| 17 | +// REQUIRES: swift_feature_AddressableTypes |
| 18 | +// REQUIRES: swift_feature_Span |
| 19 | +// REQUIRES: swift_feature_LifetimeDependence |
| 20 | + |
| 21 | +import StdlibUnittest |
| 22 | + |
| 23 | +var suite = TestSuite("SlabStorageProperty") |
| 24 | +defer { runAllTests() } |
| 25 | + |
| 26 | +suite.test("Slab.storage property") |
| 27 | +.skip(.custom( |
| 28 | + { if #available(SwiftStdlib 6.1, *) { false } else { true } }, |
| 29 | + reason: "Requires Swift 6.1's standard library" |
| 30 | +)) |
| 31 | +.code { |
| 32 | + guard #available(SwiftStdlib 6.1, *) else { return } |
| 33 | + |
| 34 | + var s = Slab<5, Int>(repeating: 0) |
| 35 | + s[3] = .random(in: 0..<1000) |
| 36 | + let storage = s.storage |
| 37 | + expectEqual(storage.count, s.count) |
| 38 | + for i in 0..<s.count { |
| 39 | + expectEqual(storage[i], s[i]) |
| 40 | + } |
| 41 | +} |
0 commit comments