ladybird/Tests/AK/TestAKBindings.swift
Andrew Kaster 1ea236e454 AK: Skip test for StringView's CxxSequence conformance for now
This should be fixed on swiftlang/swift main later this week.
2024-11-15 10:51:45 -07:00

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)
}
}