mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 23:23:28 +00:00
Initial commit
Signed-off-by: Francis Bouvier <francis.bouvier@gmail.com>
This commit is contained in:
46
src/run_tests.zig
Normal file
46
src/run_tests.zig
Normal file
@@ -0,0 +1,46 @@
|
||||
const std = @import("std");
|
||||
|
||||
const jsruntime = @import("jsruntime");
|
||||
|
||||
const DOM = @import("dom.zig");
|
||||
const document = @import("dom/document.zig");
|
||||
const element = @import("dom/element.zig");
|
||||
|
||||
const html = @import("html.zig").html;
|
||||
|
||||
var doc: DOM.HTMLDocument = undefined;
|
||||
|
||||
fn testsExecFn(
|
||||
_: std.mem.Allocator,
|
||||
js_env: *jsruntime.Env,
|
||||
comptime apis: []jsruntime.API,
|
||||
) !void {
|
||||
|
||||
// start JS env
|
||||
js_env.start();
|
||||
defer js_env.stop();
|
||||
|
||||
// add document object
|
||||
try js_env.addObject(apis, doc, "document");
|
||||
|
||||
// run tests
|
||||
try document.testExecFn(js_env, apis);
|
||||
}
|
||||
|
||||
test {
|
||||
// generate APIs
|
||||
const apis = jsruntime.compile(DOM.Interfaces);
|
||||
|
||||
// document
|
||||
doc = DOM.HTMLDocument.init();
|
||||
defer doc.deinit();
|
||||
try doc.parse(html);
|
||||
|
||||
// create JS vm
|
||||
const vm = jsruntime.VM.init();
|
||||
defer vm.deinit();
|
||||
|
||||
var alloc = jsruntime.bench_allocator(std.testing.allocator);
|
||||
|
||||
try jsruntime.loadEnv(alloc.allocator(), false, testsExecFn, apis);
|
||||
}
|
||||
Reference in New Issue
Block a user