Skip to content

Commit

Permalink
Merge pull request #759 from samchon/features/range
Browse files Browse the repository at this point in the history
Fix #758 - wrong fixed length bug on `random` function
  • Loading branch information
samchon committed Aug 13, 2023
2 parents dce2551 + d672e65 commit 5489d2e
Show file tree
Hide file tree
Showing 149 changed files with 3,923 additions and 191 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "typia",
"version": "4.2.1",
"version": "4.2.2",
"description": "Superfast runtime validators with only one line",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand Down
4 changes: 2 additions & 2 deletions packages/typescript-json/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "typescript-json",
"version": "4.2.1",
"version": "4.2.2",
"description": "Superfast runtime validators with only one line",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand Down Expand Up @@ -68,7 +68,7 @@
},
"homepage": "https://typia.io",
"dependencies": {
"typia": "4.2.1"
"typia": "4.2.2"
},
"peerDependencies": {
"typescript": ">= 4.7.4"
Expand Down
2 changes: 1 addition & 1 deletion src/programmers/helpers/RandomRanger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export namespace RandomRanger {

props.minimum ??= defs.minimum;
props.maximum ??= defs.maximum;
if (props.maximum <= props.minimum)
if (props.maximum < props.minimum)
(props.maximum as number) += defs.gap;

return ts.factory.createCallExpression(
Expand Down
63 changes: 63 additions & 0 deletions test/generated/output/assert/test_assert_TagArray.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ export const test_assert_TagArray = _test_assert(
input.both.every(
(elem: any) =>
"string" === typeof elem && $is_uuid(elem),
) &&
Array.isArray(input.equal) &&
10 <= input.equal.length &&
10 >= input.equal.length &&
input.equal.every(
(elem: any) =>
"number" === typeof elem &&
10 <= elem &&
10 >= elem,
);
return (
Array.isArray(input) &&
Expand Down Expand Up @@ -236,6 +245,60 @@ export const test_assert_TagArray = _test_assert(
path: _path + ".both",
expected: "Array<string>",
value: input.both,
})) &&
((((Array.isArray(input.equal) &&
(10 <= input.equal.length ||
$guard(_exceptionable, {
path: _path + ".equal",
expected: "Array.length (@minItems 10)",
value: input.equal,
})) &&
(10 >= input.equal.length ||
$guard(_exceptionable, {
path: _path + ".equal",
expected: "Array.length (@maxItems 10)",
value: input.equal,
}))) ||
$guard(_exceptionable, {
path: _path + ".equal",
expected: "Array<number>",
value: input.equal,
})) &&
input.equal.every(
(elem: any, _index6: number) =>
("number" === typeof elem &&
(10 <= elem ||
$guard(_exceptionable, {
path:
_path +
".equal[" +
_index6 +
"]",
expected:
"number (@minimum 10)",
value: elem,
})) &&
(10 >= elem ||
$guard(_exceptionable, {
path:
_path +
".equal[" +
_index6 +
"]",
expected:
"number (@maximum 10)",
value: elem,
}))) ||
$guard(_exceptionable, {
path: _path + ".equal[" + _index6 + "]",
expected: "number",
value: elem,
}),
)) ||
$guard(_exceptionable, {
path: _path + ".equal",
expected: "Array<number>",
value: input.equal,
}));
return (
((Array.isArray(input) ||
Expand Down
23 changes: 22 additions & 1 deletion test/generated/output/assert/test_assert_TagLength.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ export const test_assert_TagLength = _test_assert(
7 >= input.maximum.length &&
"string" === typeof input.minimum_and_maximum &&
3 <= input.minimum_and_maximum.length &&
7 >= input.minimum_and_maximum.length;
7 >= input.minimum_and_maximum.length &&
"string" === typeof input.equal &&
10 <= input.equal.length &&
19 >= input.equal.length;
return (
Array.isArray(input) &&
input.every(
Expand Down Expand Up @@ -93,6 +96,24 @@ export const test_assert_TagLength = _test_assert(
path: _path + ".minimum_and_maximum",
expected: "string",
value: input.minimum_and_maximum,
})) &&
(("string" === typeof input.equal &&
(10 <= input.equal.length ||
$guard(_exceptionable, {
path: _path + ".equal",
expected: "string (@minLength 10)",
value: input.equal,
})) &&
(19 >= input.equal.length ||
$guard(_exceptionable, {
path: _path + ".equal",
expected: "string (@maxLength 19)",
value: input.equal,
}))) ||
$guard(_exceptionable, {
path: _path + ".equal",
expected: "string",
value: input.equal,
}));
return (
((Array.isArray(input) ||
Expand Down
23 changes: 22 additions & 1 deletion test/generated/output/assert/test_assert_TagRange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ export const test_assert_TagRange = _test_assert(
7 >= input.greater_less_equal &&
"number" === typeof input.greater_equal_less_equal &&
3 <= input.greater_equal_less_equal &&
7 >= input.greater_equal_less_equal;
7 >= input.greater_equal_less_equal &&
"number" === typeof input.equal &&
10 <= input.equal &&
10 >= input.equal;
return (
Array.isArray(input) &&
input.every(
Expand Down Expand Up @@ -178,6 +181,24 @@ export const test_assert_TagRange = _test_assert(
path: _path + ".greater_equal_less_equal",
expected: "number",
value: input.greater_equal_less_equal,
})) &&
(("number" === typeof input.equal &&
(10 <= input.equal ||
$guard(_exceptionable, {
path: _path + ".equal",
expected: "number (@minimum 10)",
value: input.equal,
})) &&
(10 >= input.equal ||
$guard(_exceptionable, {
path: _path + ".equal",
expected: "number (@maximum 10)",
value: input.equal,
}))) ||
$guard(_exceptionable, {
path: _path + ".equal",
expected: "number",
value: input.equal,
}));
return (
((Array.isArray(input) ||
Expand Down
70 changes: 70 additions & 0 deletions test/generated/output/assertClone/test_assertClone_TagArray.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ export const test_assertClone_TagArray = _test_assertClone(
input.both.every(
(elem: any) =>
"string" === typeof elem && $is_uuid(elem),
) &&
Array.isArray(input.equal) &&
10 <= input.equal.length &&
10 >= input.equal.length &&
input.equal.every(
(elem: any) =>
"number" === typeof elem &&
10 <= elem &&
10 >= elem,
);
return (
Array.isArray(input) &&
Expand Down Expand Up @@ -248,6 +257,64 @@ export const test_assertClone_TagArray = _test_assertClone(
path: _path + ".both",
expected: "Array<string>",
value: input.both,
})) &&
((((Array.isArray(input.equal) &&
(10 <= input.equal.length ||
$guard(_exceptionable, {
path: _path + ".equal",
expected: "Array.length (@minItems 10)",
value: input.equal,
})) &&
(10 >= input.equal.length ||
$guard(_exceptionable, {
path: _path + ".equal",
expected: "Array.length (@maxItems 10)",
value: input.equal,
}))) ||
$guard(_exceptionable, {
path: _path + ".equal",
expected: "Array<number>",
value: input.equal,
})) &&
input.equal.every(
(elem: any, _index6: number) =>
("number" === typeof elem &&
(10 <= elem ||
$guard(_exceptionable, {
path:
_path +
".equal[" +
_index6 +
"]",
expected:
"number (@minimum 10)",
value: elem,
})) &&
(10 >= elem ||
$guard(_exceptionable, {
path:
_path +
".equal[" +
_index6 +
"]",
expected:
"number (@maximum 10)",
value: elem,
}))) ||
$guard(_exceptionable, {
path:
_path +
".equal[" +
_index6 +
"]",
expected: "number",
value: elem,
}),
)) ||
$guard(_exceptionable, {
path: _path + ".equal",
expected: "Array<number>",
value: input.equal,
}));
return (
((Array.isArray(input) ||
Expand Down Expand Up @@ -315,6 +382,9 @@ export const test_assertClone_TagArray = _test_assertClone(
both: Array.isArray(input.both)
? $cp1(input.both)
: (input.both as any),
equal: Array.isArray(input.equal)
? $cp2(input.equal)
: (input.equal as any),
});
return Array.isArray(input) ? $cp0(input) : (input as any);
};
Expand Down
24 changes: 23 additions & 1 deletion test/generated/output/assertClone/test_assertClone_TagLength.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ export const test_assertClone_TagLength = _test_assertClone(
7 >= input.maximum.length &&
"string" === typeof input.minimum_and_maximum &&
3 <= input.minimum_and_maximum.length &&
7 >= input.minimum_and_maximum.length;
7 >= input.minimum_and_maximum.length &&
"string" === typeof input.equal &&
10 <= input.equal.length &&
19 >= input.equal.length;
return (
Array.isArray(input) &&
input.every(
Expand Down Expand Up @@ -94,6 +97,24 @@ export const test_assertClone_TagLength = _test_assertClone(
path: _path + ".minimum_and_maximum",
expected: "string",
value: input.minimum_and_maximum,
})) &&
(("string" === typeof input.equal &&
(10 <= input.equal.length ||
$guard(_exceptionable, {
path: _path + ".equal",
expected: "string (@minLength 10)",
value: input.equal,
})) &&
(19 >= input.equal.length ||
$guard(_exceptionable, {
path: _path + ".equal",
expected: "string (@maxLength 19)",
value: input.equal,
}))) ||
$guard(_exceptionable, {
path: _path + ".equal",
expected: "string",
value: input.equal,
}));
return (
((Array.isArray(input) ||
Expand Down Expand Up @@ -146,6 +167,7 @@ export const test_assertClone_TagLength = _test_assertClone(
minimum: input.minimum as any,
maximum: input.maximum as any,
minimum_and_maximum: input.minimum_and_maximum as any,
equal: input.equal as any,
});
return Array.isArray(input) ? $cp0(input) : (input as any);
};
Expand Down
24 changes: 23 additions & 1 deletion test/generated/output/assertClone/test_assertClone_TagRange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ export const test_assertClone_TagRange = _test_assertClone(
7 >= input.greater_less_equal &&
"number" === typeof input.greater_equal_less_equal &&
3 <= input.greater_equal_less_equal &&
7 >= input.greater_equal_less_equal;
7 >= input.greater_equal_less_equal &&
"number" === typeof input.equal &&
10 <= input.equal &&
10 >= input.equal;
return (
Array.isArray(input) &&
input.every(
Expand Down Expand Up @@ -188,6 +191,24 @@ export const test_assertClone_TagRange = _test_assertClone(
path: _path + ".greater_equal_less_equal",
expected: "number",
value: input.greater_equal_less_equal,
})) &&
(("number" === typeof input.equal &&
(10 <= input.equal ||
$guard(_exceptionable, {
path: _path + ".equal",
expected: "number (@minimum 10)",
value: input.equal,
})) &&
(10 >= input.equal ||
$guard(_exceptionable, {
path: _path + ".equal",
expected: "number (@maximum 10)",
value: input.equal,
}))) ||
$guard(_exceptionable, {
path: _path + ".equal",
expected: "number",
value: input.equal,
}));
return (
((Array.isArray(input) ||
Expand Down Expand Up @@ -245,6 +266,7 @@ export const test_assertClone_TagRange = _test_assertClone(
greater_less_equal: input.greater_less_equal as any,
greater_equal_less_equal:
input.greater_equal_less_equal as any,
equal: input.equal as any,
});
return Array.isArray(input) ? $cp0(input) : (input as any);
};
Expand Down
Loading

0 comments on commit 5489d2e

Please sign in to comment.