Something went wrong. Try again.
A URI parser and formatter for Zig, modelled on Python's hyperlink package, with LDAP URLs, file: URIs and sdns:// DNS stamps beside it.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152<!DOCTYPE html><!--SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie <jeff@ocjtech.us>SPDX-License-Identifier: MIT--><html lang="en"> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <title>zig-uri browser tests</title> <style> :root { color-scheme: light dark; } body { margin: 0; padding: 1.5rem; font: 14px/1.5 ui-monospace, "SFMono-Regular", Menlo, monospace; } #summary { font-size: 1.1rem; font-weight: 600; margin-bottom: 1rem; } .pass { color: #2f7a35; } .fail { color: #b02222; font-weight: 600; } .skip { color: #7a7a74; } pre { margin: 0.2rem 0 0.6rem 1.5rem; white-space: pre-wrap; } </style> </head> <body> <!-- The same suite `zig build test-web` runs under node, run instead by the browser's own engine: real ES module resolution, real `WebAssembly.instantiateStreaming`, real `TextEncoder`. The NixOS VM check drives this page headless and reads `#result` back out, so that line is a contract, not decoration. --> <div id="summary">running…</div> <div id="result"></div> <div id="log"></div>
<script type="module"> import { init, hasUnicode } from "./uri.js"; import { suite } from "./tests.js";
/** Deep equality over the plain data these tests compare. */ function same(a, b) { if (Object.is(a, b)) return true; if (typeof a !== "object" || typeof b !== "object" || a === null || b === null) return false; if (Array.isArray(a) !== Array.isArray(b)) return false; const keys = Object.keys(a); if (keys.length !== Object.keys(b).length) return false; return keys.every((key) => same(a[key], b[key])); }
class AssertionError extends Error {}
function fail(message) { throw new AssertionError(message); }
/** Just the corner of `node:assert/strict` that `tests.js` uses. */ const assert = { ok(value, message) { if (!value) fail(message ?? `expected a truthy value, got ${show(value)}`); }, equal(actual, expected, message) { if (!Object.is(actual, expected)) { fail(`${message ? `${message}: ` : ""}${show(actual)} !== ${show(expected)}`); } }, deepEqual(actual, expected, message) { if (!same(actual, expected)) { fail(`${message ? `${message}: ` : ""}${show(actual)} !== ${show(expected)}`); } }, throws(fn, expected, message) { try { fn(); } catch (error) { if (typeof expected === "function" && !(error instanceof expected)) { fail(`${message ?? "wrong error"}: ${error} is not a ${expected.name}`); } return; } fail(message ?? "expected a throw"); }, fail, };
function show(value) { try { return typeof value === "string" ? JSON.stringify(value) : String(JSON.stringify(value) ?? value); } catch { return String(value); } }
const outcomes = [];
/** `node:test`'s signature, minus everything asynchronous. */ function test(name, options, body) { if (typeof options === "function") { body = options; options = {}; } if (options?.skip) { outcomes.push({ name, status: "skip", detail: String(options.skip) }); return; } try { body(); outcomes.push({ name, status: "pass" }); } catch (error) { outcomes.push({ name, status: "fail", detail: error?.stack ?? String(error) }); } }
function report() { const counts = { pass: 0, fail: 0, skip: 0 }; const log = document.getElementById("log"); for (const outcome of outcomes) { counts[outcome.status] += 1; const line = document.createElement("div"); line.className = outcome.status; const mark = { pass: "✔", fail: "✘", skip: "﹣" }[outcome.status]; line.textContent = `${mark} ${outcome.name}`; log.append(line); if (outcome.detail && outcome.status === "fail") { const detail = document.createElement("pre"); detail.className = outcome.status; detail.textContent = outcome.detail; log.append(detail); } }
// The line the VM check greps for. Keep its shape stable. const result = `RESULT pass=${counts.pass} fail=${counts.fail} skip=${counts.skip}`; document.getElementById("result").textContent = result; document.getElementById("summary").textContent = counts.fail === 0 ? `all ${counts.pass} passed` : `${counts.fail} FAILED`; document.getElementById("summary").className = counts.fail === 0 ? "pass" : "fail"; document.title = result; }
try { await init(); document.getElementById("summary").textContent = `uri.wasm loaded, unicode ${hasUnicode() ? "on" : "off"} — running…`; suite({ test, assert }); } catch (error) { outcomes.push({ name: "load uri.wasm", status: "fail", detail: String(error) }); } report(); </script> </body></html>