From 8ea45e27306d0369f2b2d624a174bd95e7f17395 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Mon, 20 Mar 2023 21:20:42 +0900 Subject: feat(nuldoc): add small test to xml.ts --- nuldoc-src/xml.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'nuldoc-src/xml.ts') diff --git a/nuldoc-src/xml.ts b/nuldoc-src/xml.ts index 13ec5d6..87c2b71 100644 --- a/nuldoc-src/xml.ts +++ b/nuldoc-src/xml.ts @@ -2,7 +2,10 @@ import { Element, Node, Text } from "./dom.ts"; import { XmlParseError } from "./errors.ts"; export async function parseXmlFile(filePath: string): Promise { - const source = await Deno.readTextFile(filePath); + return parseXmlString(await Deno.readTextFile(filePath)); +} + +export function parseXmlString(source: string): Element { return parse({ source: source, index: 0 }); } @@ -200,7 +203,7 @@ function expect(p: Parser, expected: string) { } if (actual !== expected) { throw new XmlParseError( - `[parse.expect] expected ${expected}, but actually got ${actual}`, + `[parse.expect] expected ${expected}, but actually got ${actual} (pos: ${p.index})`, ); } } -- cgit v1.2.3-70-g09d2