Skip to content

Add a test for property access on ~Escapable types #1155

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: jgrynspan/162-redesign-value-capture
Choose a base branch
from
Open
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
20 changes: 20 additions & 0 deletions Tests/TestingTests/MiscellaneousTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -595,3 +595,23 @@ struct MiscellaneousTests {
#expect(duration < .seconds(1))
}
}

#if compiler(>=6.2)
extension Span {
var isNonEmpty: Bool { !isEmpty }
var nonZeroCount: Int? { isEmpty ? nil : count }
}

extension MiscellaneousTests {
@available(macOS 26, iOS 26, watchOS 26, tvOS 26, visionOS 26, *)
@Test("Instance property of nonescapable type")
func propertyAccessOfNonescapable() throws {
let array = [1, 2, 3, 4, 5]
let span = array.span
#expect(!span.isEmpty)
#expect(span.isNonEmpty)
let count = try #require(span.nonZeroCount)
#expect(count == span.count)
}
}
#endif