#+test package main import ts "treesitter" import "core:strings" import "core:testing" // The treesitter registry is thread-safe and self-initializing (grammar() lazily // binds it to the heap), and parsers are caller-owned. Each test opens its own // parser(s) via ts.open_parser, passes them to minify_*, and frees the returned // string — so the multi-threaded test runner needs no shared state or locking. @(private = "file") open_parsers :: proc(t: ^testing.T) -> (html_parser, css_parser: ts.Parser) { hg, hok := ts.grammar("html") cg, cok := ts.grammar("css") testing.expect(t, hok, "html grammar should load") testing.expect(t, cok, "css grammar should load") return ts.open_parser(hg), ts.open_parser(cg) } @(private = "file") expect_css :: proc(t: ^testing.T, parser: ts.Parser, input, want: string) { got, ok := minify_css(parser, input) testing.expect(t, ok) defer delete(got) testing.expect_value(t, got, want) } // --- minify_html: inline
hi