deno.land / std@0.224.0 / jsonc / testdata / test262 / test.ts

View Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
import { walk } from "../../../fs/mod.ts";import { fromFileUrl } from "../../../path/mod.ts";
// helper used for testingconst sta = await Deno.readTextFile(new URL("./sta.js", import.meta.url));const assert = await Deno.readTextFile(new URL("./assert.js", import.meta.url));const propertyHelper = await Deno.readTextFile( new URL("./propertyHelper.js", import.meta.url),);const jsoncModule = new URL("../../parse.ts", import.meta.url);for await ( const dirEntry of walk(fromFileUrl(new URL("./JSON/", import.meta.url)))) { if (!dirEntry.isFile) { continue; } // Register a test case for each file. Deno.test({ name: `[jsonc] parse test262:${dirEntry.name}`, async fn() { // Run the test case to make sure there are no errors. // Check if the JSONC module passes the test case for JSON.parse. const testcode = ` import * as JSONC from "${jsoncModule}"; const JSON = JSONC; ${sta} ${assert} ${propertyHelper} ${await Deno.readTextFile(dirEntry.path)} `; await import(`data:text/javascript,${encodeURIComponent(testcode)}`); }, });}
std

Version Info

Tagged at
6 months ago