mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 09:00:22 +00:00
1ea236e454
This should be fixed on swiftlang/swift main later this week.
49 lines
1.5 KiB
Swift
49 lines
1.5 KiB
Swift
/*
|
|
* Copyright (c) 2024, Andrew Kaster <andrew@ladybird.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
import AK
|
|
import Foundation
|
|
|
|
protocol ConformanceMarker {}
|
|
enum CxxSequenceMarker<T: ~Copyable> {}
|
|
extension CxxSequenceMarker: ConformanceMarker where T: CxxSequence {}
|
|
private func isCxxSequenceType<T: ~Copyable>(_ type: borrowing T.Type) -> Bool {
|
|
return CxxSequenceMarker<T>.self is ConformanceMarker.Type
|
|
}
|
|
|
|
class StandardError: TextOutputStream {
|
|
func write(_ string: Swift.String) {
|
|
try! FileHandle.standardError.write(contentsOf: Data(string.utf8))
|
|
}
|
|
}
|
|
|
|
@main
|
|
struct TestAKBindings {
|
|
static func testSequenceTypesAreBound() {
|
|
var standardError = StandardError()
|
|
print("Testing CxxSequence types...", to: &standardError)
|
|
|
|
//precondition(isCxxSequenceType(AK.StringView.self))
|
|
precondition(isCxxSequenceType(AK.Bytes.self))
|
|
precondition(isCxxSequenceType(AK.ReadonlyBytes.self))
|
|
precondition(isCxxSequenceType(AK.Utf16Data.self))
|
|
|
|
precondition(!isCxxSequenceType(AK.Utf16View.self))
|
|
precondition(!isCxxSequenceType(AK.String.self))
|
|
|
|
precondition(!isCxxSequenceType(AK.Error.self))
|
|
|
|
print("CxxSequence types pass", to: &standardError)
|
|
}
|
|
|
|
static func main() {
|
|
var standardError = StandardError()
|
|
print("Starting test suite...", to: &standardError)
|
|
testSequenceTypesAreBound()
|
|
|
|
print("All tests pass", to: &standardError)
|
|
}
|
|
}
|