-
-
Notifications
You must be signed in to change notification settings - Fork 169
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #235 from samchon/v3.3
Fix #234 - invalid `TypeGuardError.path` bug
- Loading branch information
Showing
12 changed files
with
142 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
test/features/application/test_application_dynamic_array.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import TSON from "../../../src"; | ||
import { DynamicArray } from "../../structures/DynamicArray"; | ||
import { _test_application } from "./_test_application"; | ||
|
||
export const test_application_dynamic_array = _test_application( | ||
"dynamic array", | ||
TSON.application<[DynamicArray]>(), | ||
{ | ||
schemas: [ | ||
{ | ||
$ref: "#/components/schemas/DynamicArray", | ||
}, | ||
], | ||
components: { | ||
schemas: { | ||
DynamicArray: { | ||
type: "object", | ||
properties: {}, | ||
patternProperties: { | ||
"(.*)": { | ||
type: "array", | ||
items: { | ||
type: "string", | ||
nullable: false, | ||
}, | ||
nullable: false, | ||
}, | ||
}, | ||
nullable: false, | ||
jsDocTags: [], | ||
}, | ||
}, | ||
}, | ||
purpose: "swagger", | ||
prefix: "#/components/schemas", | ||
}, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import TSON from "../../../src"; | ||
import { DynamicArray } from "../../structures/DynamicArray"; | ||
import { _test_assert } from "./_test_assert"; | ||
|
||
export const test_assert_dynamic_array = _test_assert( | ||
"dynamic array", | ||
DynamicArray.generate, | ||
(input) => TSON.assertType(input), | ||
[ | ||
(input) => { | ||
input["something"] = [0] as any; | ||
return `$input.something[0]`; | ||
}, | ||
], | ||
); |
10 changes: 10 additions & 0 deletions
10
test/features/assert_equals/test_assert_equals_dynamic_array.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import TSON from "../../../src"; | ||
import { DynamicArray } from "../../structures/DynamicArray"; | ||
import { _test_assert_equals } from "./_test_assert_equals"; | ||
|
||
export const test_assert_equals_dynamic_array = _test_assert_equals( | ||
"dynamic array", | ||
DynamicArray.generate, | ||
(input) => TSON.assertEquals(input), | ||
false, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import TSON from "../../../src"; | ||
import { DynamicArray } from "../../structures/DynamicArray"; | ||
import { _test_equals } from "./_test_equals"; | ||
|
||
export const test_equals_dynamic_array = _test_equals( | ||
"dynamic array", | ||
DynamicArray.generate, | ||
(input) => TSON.equals(input), | ||
0, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import TSON from "../../../src"; | ||
import { DynamicArray } from "../../structures/DynamicArray"; | ||
import { _test_is } from "./_test_is"; | ||
|
||
export const test_is_dynamic_array = _test_is( | ||
"dynamic array", | ||
DynamicArray.generate, | ||
(input) => TSON.is(input), | ||
[(input) => (input["something"] = [0] as any)], | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import TSON from "../../../src"; | ||
import { DynamicArray } from "../../structures/DynamicArray"; | ||
import { _test_stringify } from "./_test_stringify"; | ||
|
||
export const test_stringify_dynamic_array = _test_stringify( | ||
"dynamic array", | ||
DynamicArray.generate(), | ||
(input) => TSON.stringify(input), | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import TSON from "../../../src"; | ||
import { DynamicArray } from "../../structures/DynamicArray"; | ||
import { _test_validate } from "./_test_validate"; | ||
|
||
export const test_validate_dynamic_array = _test_validate( | ||
"dynamic array", | ||
DynamicArray.generate, | ||
(input) => TSON.validate(input), | ||
[ | ||
(input) => { | ||
input["something"] = [0] as any; | ||
input["another"] = [false] as any; | ||
return [`$input.something[0]`, `$input.another[0]`]; | ||
}, | ||
], | ||
); |
10 changes: 10 additions & 0 deletions
10
test/features/validate_equals/test_validate_equals_dynamic_array.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import TSON from "../../../src"; | ||
import { DynamicArray } from "../../structures/DynamicArray"; | ||
import { _test_validate_equals } from "./_test_validate_equals"; | ||
|
||
export const test_validate_equals_dynamic_array = _test_validate_equals( | ||
"dynamic array", | ||
DynamicArray.generate, | ||
(input) => TSON.validateEquals(input), | ||
false, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { RandomGenerator } from "../internal/RandomGenerator"; | ||
|
||
export interface DynamicArray { | ||
[key: string]: string[]; | ||
} | ||
export namespace DynamicArray { | ||
export function generate(): DynamicArray { | ||
const output: DynamicArray = {}; | ||
for (let i: number = 0; i < 10; ++i) { | ||
const key: string = RandomGenerator.string(); | ||
output[key] = RandomGenerator.array(RandomGenerator.string); | ||
} | ||
return output; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters