Tests: Convert Swift tests to use Testing module where possible

The AK tests can't seem to use it because it crashes the frontend :)
This commit is contained in:
Andrew Kaster 2024-08-27 01:57:13 -06:00 committed by Andrew Kaster
commit 782926601d
Notes: github-actions[bot] 2024-08-29 03:28:30 +00:00
5 changed files with 44 additions and 70 deletions

View file

@ -6,42 +6,20 @@
import AK
import Web
import Foundation
import Testing
class StandardError: TextOutputStream {
func write(_ string: Swift.String) {
try! FileHandle.standardError.write(contentsOf: Data(string.utf8))
}
}
@main
@Suite
struct TestLibWebSwiftBindings {
static func testEnumsAreBound() {
var standardError = StandardError()
print("Testing LibWeb enum types...", to: &standardError)
@Test func enumsAreBound() {
#expect(Web.DOM.NodeType.ELEMENT_NODE.rawValue == 1)
print("Web.DOM.NodeType.ELEMENT_NODE == \(Web.DOM.NodeType.ELEMENT_NODE)", to: &standardError)
precondition(Web.DOM.NodeType.ELEMENT_NODE.rawValue == 1)
print("Web.Bindings.NavigationType.Push == \(Web.Bindings.NavigationType.Push)", to: &standardError)
precondition(Web.Bindings.NavigationType.Push.rawValue == 0)
#expect(Web.Bindings.NavigationType.Push.rawValue == 0)
let end = Web.Bindings.idl_enum_to_string(Web.Bindings.ScrollLogicalPosition.End)
let end_view = end.__bytes_as_string_viewUnsafe().bytes();
let end_string = Swift.String(bytes: end_view, encoding: .utf8)!
print("Web.Bindings.idl_enum_to_string(Web.Bindings.ScrollLogicalPosition.End) == \(end_string)", to: &standardError)
precondition(end_string == "end")
print("LibWeb enum types pass", to: &standardError)
}
static func main() {
var standardError = StandardError()
print("Starting test suite...", to: &standardError)
testEnumsAreBound()
print("All tests pass", to: &standardError)
#expect(end_string == "end")
}
}