Skip to content

Commit 6625821

Browse files
committed
chore(parser): improve json test docs
1 parent f1fa09f commit 6625821

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

test/parser.test.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -241,22 +241,17 @@ describe("Parser", () => {
241241

242242
it("should parse json grammar", () => {
243243
// The grammar is defined as a recursive grammar:
244-
// ---------------------------------------------
245-
// | Value = Object | Array | String | Number | True | False | Null |
246-
// | Object = { Members } |
247-
// | Members = Pair (, Pair)* |
248-
// | Pair = String : Value |
249-
// | Array = [ Values ] |
250-
// | Values = Value (, Value)* |
251-
// | String = " Characters " |
252-
// | Characters = Character* |
253-
// | Character = any character except " or \ or control character |
254-
// | Number = -? Digits ( . Digits )? |
255-
// | Digits = [0-9]+ |
256-
// | True = true |
257-
// | False = false |
258-
// | Null = null |
259-
// ---------------------------------------------
244+
// -------------------------------------------------------------
245+
// | Value = Object | Array | String | Number | Boolean | Null |
246+
// | Object = { (Pair (, Pair)*)? } |
247+
// | Pair = String : Value |
248+
// | Array = [ (Value (, Value)*)? ] |
249+
// | String = " Character* " |
250+
// | Character = any character except " |
251+
// | Number = -? Digits ( . Digits )? |
252+
// | Boolean = true | false |
253+
// | Null = null |
254+
// -------------------------------------------------------------
260255
type Value = P.Choice<
261256
[JSonObject, JSonArray, JSonString, JSonNumber, JsonBoolean, JSonNull]
262257
>;
@@ -292,6 +287,7 @@ describe("Parser", () => {
292287
>,
293288
Tuples.Join<"">
294289
>;
290+
295291
type JSonNumber = P.Map<
296292
P.Sequence<
297293
[
@@ -323,6 +319,10 @@ describe("Parser", () => {
323319
type res3 = Json<`{}`>;
324320
// ^?
325321
type test3 = Expect<Equal<res3, {}>>;
322+
// 4 deep nested objects
323+
type res4 = Json<`{"a": {"b": {"c": {"d": 8}}}}`>;
324+
// ^?
325+
type test4 = Expect<Equal<res4, { a: { b: { c: { d: 8 } } } }>>;
326326
});
327327
});
328328
});

0 commit comments

Comments
 (0)