(expected: any)
| 733 | // Convert test suite expected value to our internal format |
| 734 | // deno-lint-ignore no-explicit-any |
| 735 | function convertExpectedBareItem(expected: any): BareItem { |
| 736 | if (expected === null || expected === undefined) { |
| 737 | throw new Error("Unexpected null/undefined bare item"); |
| 738 | } |
| 739 | if (typeof expected === "boolean") { |
| 740 | return boolean(expected); |
| 741 | } |
| 742 | if (typeof expected === "number") { |
| 743 | if (Number.isInteger(expected)) { |
| 744 | return integer(expected); |
| 745 | } |
| 746 | return decimal(expected); |
| 747 | } |
| 748 | if (typeof expected === "string") { |
| 749 | return string(expected); |
| 750 | } |
| 751 | if (typeof expected === "object" && "__type" in expected) { |
| 752 | switch (expected.__type) { |
| 753 | case "token": |
| 754 | return token(expected.value); |
| 755 | case "binary": |
| 756 | return binary(decodeBase32(expected.value)); |
| 757 | case "date": |
| 758 | return date(new Date(expected.value * 1000)); |
| 759 | case "displaystring": |
| 760 | return displayString(expected.value); |
| 761 | default: |
| 762 | throw new Error(`Unknown __type: ${expected.__type}`); |
| 763 | } |
| 764 | } |
| 765 | throw new Error(`Cannot convert expected value: ${JSON.stringify(expected)}`); |
| 766 | } |
| 767 | |
| 768 | // Convert test suite expected params array to Map |
| 769 | // deno-lint-ignore no-explicit-any |
no test coverage detected