1- import { simple } from "acorn-walk" ;
21import assert from "assert" ;
32import * as fs from "fs" ;
43import * as path from "path" ;
5- import { parseCell , walk } from "@observablehq/parser" ;
4+ import { parseCell } from "@observablehq/parser" ;
65
76( async ( ) => {
87 for ( const file of fs . readdirSync ( path . join ( "test" , "input" ) ) ) {
@@ -53,23 +52,7 @@ import {parseCell, walk} from "@observablehq/parser";
5352 }
5453 }
5554
56- // Treat BigInt as Number for test purposes.
57- if ( cell . body ) {
58- simple (
59- cell . body ,
60- {
61- Literal ( node ) {
62- if ( node . bigint ) {
63- node . value = Number ( node . value ) ;
64- }
65- }
66- } ,
67- walk
68- ) ;
69- }
70-
71- // Convert to a suitable JSON representation.
72- const actual = JSON . stringify ( normalizeFeatures ( cell ) , null , 2 ) ;
55+ const actual = JSON . stringify ( cell , stringify , 2 ) ;
7356
7457 let expected ;
7558 try {
@@ -89,12 +72,9 @@ import {parseCell, walk} from "@observablehq/parser";
8972 }
9073} ) ( ) ;
9174
92- function normalizeFeatures ( node ) {
93- return {
94- ...node ,
95- databaseClients : node . databaseClients && [ ...node . databaseClients ] ,
96- fileAttachments : node . fileAttachments && [ ...node . fileAttachments ] ,
97- secrets : node . secrets && [ ...node . secrets ] ,
98- tag : node . tag && normalizeFeatures ( node . tag )
99- } ;
75+ // Convert to a serializable representation.
76+ function stringify ( key , value ) {
77+ return typeof value === "bigint" ? value . toString ( )
78+ : value instanceof Map ? [ ...value ]
79+ : value ;
10080}
0 commit comments