1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- /*
- * Copyright (c) 2024, Andrew Kaster <andrew@ladybird.org>
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
- import AK
- import Web
- import Foundation
- class StandardError: TextOutputStream {
- func write(_ string: Swift.String) {
- try! FileHandle.standardError.write(contentsOf: Data(string.utf8))
- }
- }
- @main
- struct TestHTMLTokenizerSwift {
- static func testTokenTypes() {
- var standardError = StandardError()
- print("Testing HTMLToken types...", to: &standardError)
- let default_token = HTMLToken()
- default_token.type = .Character(codePoint: "a")
- precondition(default_token.isCharacter())
- print("\(default_token)", to: &standardError)
- print("HTMLToken types pass", to: &standardError)
- }
- static func testParserWhitespace() {
- var standardError = StandardError()
- print("Testing HTMLToken parser whitespace...", to: &standardError)
- for codePoint: Character in ["\t", "\n", "\r", "\u{000C}", " "] {
- let token = HTMLToken(type: .Character(codePoint: codePoint))
- precondition(token.isParserWhitespace())
- }
- for codePoint: Character in ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"] {
- let token = HTMLToken(type: .Character(codePoint: codePoint))
- precondition(!token.isParserWhitespace())
- }
- print("HTMLToken parser whitespace pass", to: &standardError)
- }
- static func main() {
- var standardError = StandardError()
- print("Starting test suite...", to: &standardError)
- testTokenTypes()
- testParserWhitespace()
- print("All tests pass", to: &standardError)
- }
- }
|