Skip to content

Commit

Permalink
test: update test snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
sinzii committed Jul 2, 2024
1 parent 23c0268 commit adfda9e
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 107 deletions.
10 changes: 5 additions & 5 deletions shapes/test/__snapshots__/collections.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ snapshot[`\$.set(\$.u8) invalid 123 1`] = `ShapeAssertError: !(value instanceof

snapshot[`\$.set(\$.u8) invalid [ 123 ] 1`] = `ShapeAssertError: !(value instanceof ShapeSet)`;

snapshot[`\$.set(\$.u8) invalid Set(1) { null } 1`] = `ShapeAssertError: !(value instanceof ShapeSet)`;
snapshot[`\$.set(\$.u8) invalid Set { null } 1`] = `ShapeAssertError: !(value instanceof ShapeSet)`;

snapshot[`\$.set(\$.u8) invalid Set(5) { 1, 2, 3, -1, 4 } 1`] = `ShapeAssertError: !(value instanceof ShapeSet)`;
snapshot[`\$.set(\$.u8) invalid Set { 1, 2, 3, -1, 4 } 1`] = `ShapeAssertError: !(value instanceof ShapeSet)`;

snapshot[`\$.set(\$.u8) invalid ShapeSet { "\$value": \$.i8 } 1`] = `ShapeAssertError: #iterator[3] < 0`;

Expand Down Expand Up @@ -83,8 +83,8 @@ snapshot[`\$.map(\$.str, \$.u8) invalid [ 123 ] 1`] = `ShapeAssertError: !(value

snapshot[`\$.map(\$.str, \$.u8) invalid [ [ "a", 1 ] ] 1`] = `ShapeAssertError: !(value instanceof ShapeMap)`;

snapshot[`\$.map(\$.str, \$.u8) invalid Map(1) { "a" => null } 1`] = `ShapeAssertError: !(value instanceof ShapeMap)`;
snapshot[`\$.map(\$.str, \$.u8) invalid Map { "a" => null } 1`] = `ShapeAssertError: !(value instanceof ShapeMap)`;

snapshot[`\$.map(\$.str, \$.u8) invalid Map(4) { "a" => 1, "b" => 2, "c" => -1, "d" => 0 } 1`] = `ShapeAssertError: !(value instanceof ShapeMap)`;
snapshot[`\$.map(\$.str, \$.u8) invalid Map { "a" => 1, "b" => 2, "c" => -1, "d" => 0 } 1`] = `ShapeAssertError: !(value instanceof ShapeMap)`;

snapshot[`\$.map(\$.str, \$.u8) invalid Map(4) { "a" => 1, "b" => 2, null => 3, "d" => 0 } 1`] = `ShapeAssertError: !(value instanceof ShapeMap)`;
snapshot[`\$.map(\$.str, \$.u8) invalid Map { "a" => 1, "b" => 2, null => 3, "d" => 0 } 1`] = `ShapeAssertError: !(value instanceof ShapeMap)`;
28 changes: 7 additions & 21 deletions shapes/test/__snapshots__/deferred.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
export const snapshot = {};

snapshot[`\$0 = \$.option(
\$.object(\$.field("val", \$.u8), \$.field("next", \$.deferred(() => \$0)))
) undefined 1`] = `00`;
snapshot[`\$0 = \$.option(\$.object(\$.field("val", \$.u8), \$.field("next", \$.deferred(() => \$0)))) undefined 1`] = `00`;

snapshot[`\$0 = \$.option(
\$.object(\$.field("val", \$.u8), \$.field("next", \$.deferred(() => \$0)))
) { val: 1, next: undefined } 1`] = `
snapshot[`\$0 = \$.option(\$.object(\$.field("val", \$.u8), \$.field("next", \$.deferred(() => \$0)))) { val: 1, next: undefined } 1`] = `
01
01
00
`;

snapshot[`\$0 = \$.option(
\$.object(\$.field("val", \$.u8), \$.field("next", \$.deferred(() => \$0)))
) { val: 1, next: { val: 2, next: { val: 3, next: undefined } } } 1`] = `
snapshot[`\$0 = \$.option(\$.object(\$.field("val", \$.u8), \$.field("next", \$.deferred(() => \$0)))) { val: 1, next: { val: 2, next: { val: 3, next: undefined } } } 1`] = `
01
01
01
Expand All @@ -24,18 +18,10 @@ snapshot[`\$0 = \$.option(
00
`;

snapshot[`\$0 = \$.option(
\$.object(\$.field("val", \$.u8), \$.field("next", \$.deferred(() => \$0)))
) invalid null 1`] = `ShapeAssertError: value == null`;
snapshot[`\$0 = \$.option(\$.object(\$.field("val", \$.u8), \$.field("next", \$.deferred(() => \$0)))) invalid null 1`] = `ShapeAssertError: value == null`;

snapshot[`\$0 = \$.option(
\$.object(\$.field("val", \$.u8), \$.field("next", \$.deferred(() => \$0)))
) invalid { val: 1, next: null } 1`] = `ShapeAssertError: value.next == null`;
snapshot[`\$0 = \$.option(\$.object(\$.field("val", \$.u8), \$.field("next", \$.deferred(() => \$0)))) invalid { val: 1, next: null } 1`] = `ShapeAssertError: value.next == null`;

snapshot[`\$0 = \$.option(
\$.object(\$.field("val", \$.u8), \$.field("next", \$.deferred(() => \$0)))
) invalid { val: 1, next: { val: -1, next: undefined } } 1`] = `ShapeAssertError: value.next.val < 0`;
snapshot[`\$0 = \$.option(\$.object(\$.field("val", \$.u8), \$.field("next", \$.deferred(() => \$0)))) invalid { val: 1, next: { val: -1, next: undefined } } 1`] = `ShapeAssertError: value.next.val < 0`;

snapshot[`\$0 = \$.option(
\$.object(\$.field("val", \$.u8), \$.field("next", \$.deferred(() => \$0)))
) invalid { val: 1, next: { val: 2, next: { val: 3, next: { val: -1, next: undefined } } } } 1`] = `ShapeAssertError: value.next.next.next.val < 0`;
snapshot[`\$0 = \$.option(\$.object(\$.field("val", \$.u8), \$.field("next", \$.deferred(() => \$0)))) invalid { val: 1, next: { val: 2, next: { val: 3, next: { val: -1, next: undefined } } } } 1`] = `ShapeAssertError: value.next.next.next.val < 0`;
5 changes: 3 additions & 2 deletions shapes/test/__snapshots__/instance.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ export const snapshot = {};
snapshot[`\$myError MyError {
code: 1,
message: "At war with my Arch system config",
payload: { a: "a", b: 2, c: true } } 1`] = `
payload: { a: "a", b: 2, c: true },
} 1`] = `
01
84
41
Expand Down Expand Up @@ -51,7 +52,7 @@ snapshot[`\$myError invalid undefined 1`] = `ShapeAssertError: !(value instanceo

snapshot[`\$myError invalid { code: 123, message: "foo", payload: { a: "abc", b: 2, c: true } } 1`] = `ShapeAssertError: !(value instanceof MyError)`;

snapshot[`\$myError invalid [Error: foo] 1`] = `ShapeAssertError: !(value instanceof MyError)`;
snapshot[`\$myError invalid Error: foo 1`] = `ShapeAssertError: !(value instanceof MyError)`;

snapshot[`\$myError invalid MyError { code: -1, message: "a", payload: { a: "abc", b: 2, c: true } } 1`] = `ShapeAssertError: value#arguments[0] < 0`;

Expand Down
32 changes: 16 additions & 16 deletions shapes/test/__snapshots__/object.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ snapshot[`\$.object(
\$.taggedUnion(
"_tag",
[
Variant { tag: "a", shape: \$.object([]) },
Variant { tag: "b", shape: \$.object(\$.field("x", \$.u8)) }
Variant { tag: "a", shape: \$.object(Array) },
Variant { tag: "b", shape: \$.object(Array) }
]
),
\$.field("bar", \$.u8)
Expand All @@ -86,8 +86,8 @@ snapshot[`\$.object(
\$.taggedUnion(
"_tag",
[
Variant { tag: "a", shape: \$.object([]) },
Variant { tag: "b", shape: \$.object(\$.field("x", \$.u8)) }
Variant { tag: "a", shape: \$.object(Array) },
Variant { tag: "b", shape: \$.object(Array) }
]
),
\$.field("bar", \$.u8)
Expand All @@ -101,8 +101,8 @@ snapshot[`\$.object(
\$.taggedUnion(
"_tag",
[
Variant { tag: "a", shape: \$.object([]) },
Variant { tag: "b", shape: \$.object(\$.field("x", \$.u8)) }
Variant { tag: "a", shape: \$.object(Array) },
Variant { tag: "b", shape: \$.object(Array) }
]
),
\$.field("bar", \$.u8)
Expand All @@ -112,8 +112,8 @@ snapshot[`\$.object(
\$.taggedUnion(
"_tag",
[
Variant { tag: "a", shape: \$.object([]) },
Variant { tag: "b", shape: \$.object(\$.field("x", \$.u8)) }
Variant { tag: "a", shape: \$.object(Array) },
Variant { tag: "b", shape: \$.object(Array) }
]
),
\$.field("bar", \$.u8)
Expand All @@ -123,8 +123,8 @@ snapshot[`\$.object(
\$.taggedUnion(
"_tag",
[
Variant { tag: "a", shape: \$.object([]) },
Variant { tag: "b", shape: \$.object(\$.field("x", \$.u8)) }
Variant { tag: "a", shape: \$.object(Array) },
Variant { tag: "b", shape: \$.object(Array) }
]
),
\$.field("bar", \$.u8)
Expand All @@ -134,8 +134,8 @@ snapshot[`\$.object(
\$.taggedUnion(
"_tag",
[
Variant { tag: "a", shape: \$.object([]) },
Variant { tag: "b", shape: \$.object(\$.field("x", \$.u8)) }
Variant { tag: "a", shape: \$.object(Array) },
Variant { tag: "b", shape: \$.object(Array) }
]
),
\$.field("bar", \$.u8)
Expand All @@ -145,8 +145,8 @@ snapshot[`\$.object(
\$.taggedUnion(
"_tag",
[
Variant { tag: "a", shape: \$.object([]) },
Variant { tag: "b", shape: \$.object(\$.field("x", \$.u8)) }
Variant { tag: "a", shape: \$.object(Array) },
Variant { tag: "b", shape: \$.object(Array) }
]
),
\$.field("bar", \$.u8)
Expand All @@ -156,8 +156,8 @@ snapshot[`\$.object(
\$.taggedUnion(
"_tag",
[
Variant { tag: "a", shape: \$.object([]) },
Variant { tag: "b", shape: \$.object(\$.field("x", \$.u8)) }
Variant { tag: "a", shape: \$.object(Array) },
Variant { tag: "b", shape: \$.object(Array) }
]
),
\$.field("bar", \$.u8)
Expand Down
13 changes: 1 addition & 12 deletions shapes/test/__snapshots__/record.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,7 @@ snapshot[`\$.transform(

snapshot[`\$.transform(
{
"\$base": \$.array(
\$.tuple(
\$.str,
\$.transform(
{
"\$base": \$.array(\$.tuple(\$.str, \$.u8)),
encode: [Function: entries],
decode: [Function: fromEntries]
}
)
)
),
"\$base": \$.array(\$.tuple(\$.str, \$.transform(Array))),
encode: [Function: entries],
decode: [Function: fromEntries]
}
Expand Down
54 changes: 6 additions & 48 deletions shapes/test/__snapshots__/result.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,66 +1,24 @@
export const snapshot = {};

snapshot[`\$.result(
\$.str,
\$.instance(
[class StrErr extends Error],
\$.tuple(\$.str),
[Function (anonymous)]
)
) "ok" 1`] = `
snapshot[`\$.result(\$.str, \$.instance([Class: StrErr], \$.tuple(\$.str), [Function (anonymous)])) "ok" 1`] = `
00
08
6f
6b
`;

snapshot[`\$.result(
\$.str,
\$.instance(
[class StrErr extends Error],
\$.tuple(\$.str),
[Function (anonymous)]
)
) { [StrErr: err] str: "err", message: "StrErr: err" } 1`] = `
snapshot[`\$.result(\$.str, \$.instance([Class: StrErr], \$.tuple(\$.str), [Function (anonymous)])) StrErr: err 1`] = `
01
0c
65
72
72
`;

snapshot[`\$.result(
\$.str,
\$.instance(
[class StrErr extends Error],
\$.tuple(\$.str),
[Function (anonymous)]
)
) invalid null 1`] = `ShapeAssertError: typeof value !== "string"`;
snapshot[`\$.result(\$.str, \$.instance([Class: StrErr], \$.tuple(\$.str), [Function (anonymous)])) invalid null 1`] = `ShapeAssertError: typeof value !== "string"`;

snapshot[`\$.result(
\$.str,
\$.instance(
[class StrErr extends Error],
\$.tuple(\$.str),
[Function (anonymous)]
)
) invalid undefined 1`] = `ShapeAssertError: typeof value !== "string"`;
snapshot[`\$.result(\$.str, \$.instance([Class: StrErr], \$.tuple(\$.str), [Function (anonymous)])) invalid undefined 1`] = `ShapeAssertError: typeof value !== "string"`;

snapshot[`\$.result(
\$.str,
\$.instance(
[class StrErr extends Error],
\$.tuple(\$.str),
[Function (anonymous)]
)
) invalid [Error: foo] 1`] = `ShapeAssertError: !(value instanceof StrErr)`;
snapshot[`\$.result(\$.str, \$.instance([Class: StrErr], \$.tuple(\$.str), [Function (anonymous)])) invalid Error: foo 1`] = `ShapeAssertError: !(value instanceof StrErr)`;

snapshot[`\$.result(
\$.str,
\$.instance(
[class StrErr extends Error],
\$.tuple(\$.str),
[Function (anonymous)]
)
) invalid { [StrErr: null] str: null, message: "StrErr: null" } 1`] = `ShapeAssertError: typeof value#arguments[0] !== "string"`;
snapshot[`\$.result(\$.str, \$.instance([Class: StrErr], \$.tuple(\$.str), [Function (anonymous)])) invalid StrErr: null 1`] = `ShapeAssertError: typeof value#arguments[0] !== "string"`;
8 changes: 5 additions & 3 deletions shapes/test/__snapshots__/tuple.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
export const snapshot = {};

snapshot[`\$.tuple(\$.str, \$.u8, \$.str, \$.u32) [ "HELLO!",
snapshot[`\$.tuple(\$.str, \$.u8, \$.str, \$.u32) [
"HELLO!",
1,
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore "... 346 more characters,
4294967295 ] 1`] = `
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore ...",
4294967295,
] 1`] = `
18
48
45
Expand Down

0 comments on commit adfda9e

Please sign in to comment.