mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
b645e26e9b
When the TokenStream code was originally written, there was no such concept in the CSS Syntax spec. But since then, it's been officially added, (https://drafts.csswg.org/css-syntax/#css-token-stream) and the parsing algorithms are described in terms of it. This patch brings our implementation in line with the spec. A few deprecated TokenStream methods are left around until their users are also updated to match the newer spec. There are a few differences: - They name things differently. The main confusing one is we had `next_token()` which consumed a token and returned it, but the spec has a `next_token()` which peeks the next token. The spec names are honestly better than what I'd come up with. (`discard_a_token()` is a nice addition too!) - We used to store the index of the token that was just consumed, and they instead store the index of the token that will be consumed next. This is a perfect breeding ground for off-by-one errors, so I've finally added a test suite for TokenStream itself. - We use a transaction system for rewinding, and the spec uses a stack of "marks", which can be manually rewound to. These should be able to coexist as long as we stick with marks in the parser spec algorithms, and stick with transactions elsewhere.
33 lines
943 B
CMake
33 lines
943 B
CMake
set(TEST_SOURCES
|
|
TestCSSIDSpeed.cpp
|
|
TestCSSPixels.cpp
|
|
TestCSSTokenStream.cpp
|
|
TestFetchInfrastructure.cpp
|
|
TestFetchURL.cpp
|
|
TestHTMLTokenizer.cpp
|
|
TestMicrosyntax.cpp
|
|
TestMimeSniff.cpp
|
|
TestNumbers.cpp
|
|
)
|
|
|
|
foreach(source IN LISTS TEST_SOURCES)
|
|
serenity_test("${source}" LibWeb LIBS LibWeb)
|
|
endforeach()
|
|
|
|
target_link_libraries(TestFetchURL PRIVATE LibURL)
|
|
|
|
if (ENABLE_SWIFT)
|
|
find_package(SwiftTesting REQUIRED)
|
|
|
|
add_executable(TestLibWebSwift
|
|
TestLibWebSwiftBindings.swift
|
|
TestHTMLTokenizerSwift.swift
|
|
)
|
|
|
|
# FIXME: Swift doesn't seem to like object libraries for @main
|
|
target_sources(TestLibWebSwift PRIVATE ../Resources/SwiftTestMain.swift)
|
|
|
|
set_target_properties(TestLibWebSwift PROPERTIES SUFFIX .swift-testing)
|
|
target_link_libraries(TestLibWebSwift PRIVATE AK LibWeb SwiftTesting::SwiftTesting)
|
|
add_test(NAME TestLibWebSwift COMMAND TestLibWebSwift)
|
|
endif()
|