typia 13.1.19 → 13.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/executable/FileSystemIdentity.d.ts +23 -0
- package/lib/executable/FileSystemIdentity.js +30 -0
- package/lib/executable/FileSystemIdentity.js.map +1 -1
- package/lib/executable/FileSystemIdentity.mjs +4 -0
- package/lib/executable/FileSystemIdentity.mjs.map +1 -1
- package/lib/executable/TypiaGenerateWizard.js +15 -9
- package/lib/executable/TypiaGenerateWizard.js.map +1 -1
- package/lib/executable/TypiaGenerateWizard.mjs +11 -7
- package/lib/executable/TypiaGenerateWizard.mjs.map +1 -1
- package/lib/internal/_ProtobufReader.d.ts +18 -3
- package/lib/internal/_ProtobufReader.js +39 -11
- package/lib/internal/_ProtobufReader.js.map +1 -1
- package/lib/internal/_ProtobufReader.mjs +37 -10
- package/lib/internal/_ProtobufReader.mjs.map +1 -1
- package/lib/internal/_jsonStringifyArray.d.ts +1 -0
- package/lib/internal/_jsonStringifyArray.js +48 -0
- package/lib/internal/_jsonStringifyArray.js.map +1 -0
- package/lib/internal/_jsonStringifyArray.mjs +40 -0
- package/lib/internal/_jsonStringifyArray.mjs.map +1 -0
- package/lib/internal/_jsonStringifyElement.d.ts +1 -0
- package/lib/internal/_jsonStringifyElement.js +23 -0
- package/lib/internal/_jsonStringifyElement.js.map +1 -0
- package/lib/internal/_jsonStringifyElement.mjs +23 -0
- package/lib/internal/_jsonStringifyElement.mjs.map +1 -0
- package/lib/internal/_jsonStringifyProperty.d.ts +1 -0
- package/lib/internal/_jsonStringifyProperty.js +31 -0
- package/lib/internal/_jsonStringifyProperty.js.map +1 -0
- package/lib/internal/_jsonStringifyProperty.mjs +31 -0
- package/lib/internal/_jsonStringifyProperty.mjs.map +1 -0
- package/lib/internal/_llmApplicationFinalize.js +1 -1
- package/lib/internal/_llmApplicationFinalize.js.map +1 -1
- package/lib/internal/_llmApplicationFinalize.mjs +1 -1
- package/lib/internal/_llmApplicationFinalize.mjs.map +1 -1
- package/lib/internal/_randomFormatByte.js +24 -1
- package/lib/internal/_randomFormatByte.js.map +1 -1
- package/lib/internal/_randomFormatByte.mjs +20 -2
- package/lib/internal/_randomFormatByte.mjs.map +1 -1
- package/lib/internal/_randomFormatDate.d.ts +3 -6
- package/lib/internal/_randomFormatDate.js +2 -10
- package/lib/internal/_randomFormatDate.js.map +1 -1
- package/lib/internal/_randomFormatDate.mjs +2 -6
- package/lib/internal/_randomFormatDate.mjs.map +1 -1
- package/lib/internal/_randomFormatDatetime.d.ts +3 -6
- package/lib/internal/_randomFormatDatetime.js +25 -8
- package/lib/internal/_randomFormatDatetime.js.map +1 -1
- package/lib/internal/_randomFormatDatetime.mjs +17 -7
- package/lib/internal/_randomFormatDatetime.mjs.map +1 -1
- package/lib/internal/_randomFormatDuration.js +23 -15
- package/lib/internal/_randomFormatDuration.js.map +1 -1
- package/lib/internal/_randomFormatDuration.mjs +23 -15
- package/lib/internal/_randomFormatDuration.mjs.map +1 -1
- package/lib/internal/_randomFormatIpv4.js +31 -1
- package/lib/internal/_randomFormatIpv4.js.map +1 -1
- package/lib/internal/_randomFormatIpv4.mjs +23 -2
- package/lib/internal/_randomFormatIpv4.mjs.map +1 -1
- package/lib/internal/_randomFormatIpv6.js +57 -1
- package/lib/internal/_randomFormatIpv6.js.map +1 -1
- package/lib/internal/_randomFormatIpv6.mjs +45 -2
- package/lib/internal/_randomFormatIpv6.mjs.map +1 -1
- package/lib/internal/_randomFormatJsonPointer.js +14 -2
- package/lib/internal/_randomFormatJsonPointer.js.map +1 -1
- package/lib/internal/_randomFormatJsonPointer.mjs +13 -3
- package/lib/internal/_randomFormatJsonPointer.mjs.map +1 -1
- package/lib/internal/_randomFormatRegex.js +14 -1
- package/lib/internal/_randomFormatRegex.js.map +1 -1
- package/lib/internal/_randomFormatRegex.mjs +14 -2
- package/lib/internal/_randomFormatRegex.mjs.map +1 -1
- package/lib/internal/_randomFormatRelativeJsonPointer.js +19 -5
- package/lib/internal/_randomFormatRelativeJsonPointer.js.map +1 -1
- package/lib/internal/_randomFormatRelativeJsonPointer.mjs +21 -6
- package/lib/internal/_randomFormatRelativeJsonPointer.mjs.map +1 -1
- package/lib/internal/_randomFormatTime.js +33 -7
- package/lib/internal/_randomFormatTime.js.map +1 -1
- package/lib/internal/_randomFormatTime.mjs +37 -5
- package/lib/internal/_randomFormatTime.mjs.map +1 -1
- package/lib/internal/_randomPattern.js.map +1 -1
- package/lib/internal/_randomPattern.mjs.map +1 -1
- package/lib/internal/_randomStringLength.d.ts +41 -10
- package/lib/internal/_randomStringLength.js +49 -13
- package/lib/internal/_randomStringLength.js.map +1 -1
- package/lib/internal/_randomStringLength.mjs +48 -13
- package/lib/internal/_randomStringLength.mjs.map +1 -1
- package/lib/internal/private/__notationRename.js.map +1 -1
- package/lib/internal/private/__notationRename.mjs.map +1 -1
- package/lib/internal/private/__randomComposition.d.ts +23 -0
- package/lib/internal/private/__randomComposition.js +48 -0
- package/lib/internal/private/__randomComposition.js.map +1 -0
- package/lib/internal/private/__randomComposition.mjs +54 -0
- package/lib/internal/private/__randomComposition.mjs.map +1 -0
- package/lib/internal/private/__randomEpoch.d.ts +19 -0
- package/lib/internal/private/__randomEpoch.js +31 -0
- package/lib/internal/private/__randomEpoch.js.map +1 -0
- package/lib/internal/private/__randomEpoch.mjs +28 -0
- package/lib/internal/private/__randomEpoch.mjs.map +1 -0
- package/native/cmd/ttsc-typia/build.go +3 -0
- package/native/cmd/ttsc-typia/callable_interface_function_semantics_transform_test.go +331 -0
- package/native/cmd/ttsc-typia/callable_type_literal_boundaries_transform_test.go +1184 -0
- package/native/cmd/ttsc-typia/compare_functional_union_membership_transform_test.go +434 -0
- package/native/cmd/ttsc-typia/compare_template_literal_union_transform_test.go +241 -0
- package/native/cmd/ttsc-typia/default_library_spoof_native_identity_transform_test.go +216 -0
- package/native/cmd/ttsc-typia/json_schema_dynamic_key_determinism_transform_test.go +246 -0
- package/native/cmd/ttsc-typia/json_stringify_contextual_undefined_transform_test.go +556 -0
- package/native/cmd/ttsc-typia/lib_replacement_native_identity_transform_test.go +277 -0
- package/native/cmd/ttsc-typia/native_named_intersection_union_transform_test.go +390 -0
- package/native/cmd/ttsc-typia/node_buffer_native_exports_is_transform_test.go +526 -0
- package/native/cmd/ttsc-typia/package_declaration_native_identity_is_transform_test.go +293 -0
- package/native/cmd/ttsc-typia/protobuf_diagnostic_code_transform_test.go +167 -0
- package/native/cmd/ttsc-typia/symbol_index_domain_transform_test.go +316 -0
- package/native/cmd/ttsc-typia/transform.go +23 -0
- package/native/cmd/ttsc-typia/transform_helpers_test.go +77 -2
- package/native/cmd/ttsc-typia/user_global_native_identity_transform_test.go +484 -0
- package/native/core/factories/ProtobufFactory.go +6 -1
- package/native/core/factories/internal/metadata/MetadataHelper.go +185 -30
- package/native/core/factories/internal/metadata/emplace_metadata_object.go +25 -0
- package/native/core/factories/internal/metadata/iterate_metadata_function.go +1 -1
- package/native/core/factories/internal/metadata/iterate_metadata_intersection.go +103 -23
- package/native/core/factories/internal/metadata/iterate_metadata_map.go +3 -7
- package/native/core/factories/internal/metadata/iterate_metadata_native.go +32 -14
- package/native/core/factories/internal/metadata/iterate_metadata_set.go +3 -7
- package/native/core/programmers/compare/CompareEqualProgrammer.go +27 -13
- package/native/core/programmers/helpers/FunctionProgrammer.go +6 -13
- package/native/core/programmers/helpers/StringifyJoinder.go +129 -50
- package/native/core/programmers/helpers/joiner_branch_coverage_test.go +116 -120
- package/native/core/programmers/iterate/iterate_check_coverage_test.go +76 -158
- package/native/core/programmers/iterate/iterate_utility_coverage_test.go +231 -270
- package/native/core/programmers/iterate/json_schema_object.go +49 -7
- package/native/core/programmers/iterate/json_schema_pattern_property_order_test.go +44 -0
- package/native/core/programmers/iterate/openapi_v3_downgrader.go +34 -1
- package/native/core/programmers/iterate/template_runtime_pattern.go +11 -0
- package/native/core/programmers/json/JsonStringifyProgrammer.go +47 -6
- package/native/core/programmers/llm/LlmApplicationProgrammer.go +9 -1
- package/native/core/programmers/protobuf/ProtobufMessageProgrammer.go +1 -1
- package/native/core/schemas/metadata/MetadataCollection.go +0 -9
- package/native/core/schemas/metadata/MetadataDefaultLibrary.go +81 -0
- package/native/core/schemas/metadata/MetadataObjectType.go +7 -18
- package/native/go.mod +4 -4
- package/native/transform/features/protobuf/ProtobufMessageTransformer.go +1 -1
- package/package.json +3 -7
- package/src/executable/FileSystemIdentity.ts +33 -0
- package/src/executable/TypiaGenerateWizard.ts +18 -12
- package/src/internal/_ProtobufReader.ts +40 -11
- package/src/internal/_jsonStringifyArray.ts +50 -0
- package/src/internal/_jsonStringifyElement.ts +19 -0
- package/src/internal/_jsonStringifyProperty.ts +30 -0
- package/src/internal/_llmApplicationFinalize.ts +6 -1
- package/src/internal/_randomFormatByte.ts +30 -3
- package/src/internal/_randomFormatDate.ts +4 -20
- package/src/internal/_randomFormatDatetime.ts +34 -20
- package/src/internal/_randomFormatDuration.ts +19 -4
- package/src/internal/_randomFormatIpv4.ts +43 -3
- package/src/internal/_randomFormatIpv6.ts +67 -3
- package/src/internal/_randomFormatJsonPointer.ts +23 -3
- package/src/internal/_randomFormatRegex.ts +21 -3
- package/src/internal/_randomFormatRelativeJsonPointer.ts +23 -10
- package/src/internal/_randomFormatTime.ts +45 -12
- package/src/internal/_randomPattern.ts +4 -1
- package/src/internal/_randomStringLength.ts +61 -17
- package/src/internal/private/__notationRename.ts +1 -4
- package/src/internal/private/__randomComposition.ts +50 -0
- package/src/internal/private/__randomEpoch.ts +34 -0
- package/native/adapter/visit.go +0 -173
- package/native/adapter/visit_property_chain_edges_test.go +0 -129
- package/native/core/programmers/helpers/disable_function_programmer_declare.go +0 -10
- package/native/core/programmers/iterate/check_union_array_like.go +0 -422
- package/native/core/programmers/iterate/prune_object_properties.go +0 -105
- package/native/core/programmers/iterate/stringify_dynamic_properties.go +0 -219
- package/native/core/programmers/iterate/stringify_native.go +0 -14
- package/native/core/programmers/iterate/stringify_regular_properties.go +0 -112
- package/native/core/schemas/metadata/MetadataApplication.go +0 -41
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
package helpers
|
|
5
5
|
|
|
6
6
|
import (
|
|
7
|
-
|
|
7
|
+
"testing"
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
shimast "github.com/microsoft/typescript-go/shim/ast"
|
|
10
|
+
nativecontext "github.com/samchon/typia/packages/typia/native/core/context"
|
|
11
|
+
nativemetadata "github.com/samchon/typia/packages/typia/native/core/schemas/metadata"
|
|
12
12
|
)
|
|
13
13
|
|
|
14
14
|
// TestJoinerBranchCoverage exercises joiner helper branches.
|
|
@@ -23,127 +23,123 @@ import (
|
|
|
23
23
|
// 3. Exercise function programmer variable declaration and declaration-disable branches.
|
|
24
24
|
// 4. Verify string joining, internal import fallback, and metadata pattern helpers.
|
|
25
25
|
func TestJoinerBranchCoverage(t *testing.T) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
26
|
+
factory := shimast.NewNodeFactory(shimast.NodeFactoryHooks{})
|
|
27
|
+
input := factory.NewIdentifier("input")
|
|
28
|
+
value := factory.NewIdentifier("value")
|
|
29
|
+
literalKey := helperLiteralKey("known")
|
|
30
|
+
dynamicKey := helperAtomic("string")
|
|
31
|
+
numberKey := helperAtomic("number")
|
|
32
|
+
booleanKey := helperAtomic("boolean")
|
|
33
|
+
templateKey := nativemetadata.MetadataSchema_initialize()
|
|
34
|
+
templateKey.Templates = append(templateKey.Templates, nativemetadata.MetadataTemplate_create(nativemetadata.MetadataTemplate{
|
|
35
|
+
Row: []*nativemetadata.MetadataSchema{literalKey, numberKey},
|
|
36
|
+
}))
|
|
37
|
+
required := helperAtomic("string")
|
|
38
|
+
optional := helperAtomic("string")
|
|
39
|
+
optional.Optional = true
|
|
40
|
+
optional.Required = false
|
|
41
|
+
functional := nativemetadata.MetadataSchema_initialize()
|
|
42
|
+
functional.Functions = append(functional.Functions, nativemetadata.MetadataFunction_create(nativemetadata.MetadataFunction{
|
|
43
|
+
Output: helperAtomic("string"),
|
|
44
|
+
}))
|
|
45
|
+
entries := []IExpressionEntry{
|
|
46
|
+
{Input: input, Key: literalKey, Meta: required, Expression: value},
|
|
47
|
+
{Input: input, Key: dynamicKey, Meta: optional, Expression: value},
|
|
48
|
+
}
|
|
49
|
+
if CloneJoiner.Tuple(CloneJoiner_TupleProps{Elements: []*shimast.Expression{value}, Rest: input}) == nil ||
|
|
50
|
+
CloneJoiner.Array(CloneJoiner_ArrayProps{Input: input, Arrow: value}) == nil ||
|
|
51
|
+
CloneJoiner.Object(CloneJoiner_ObjectProps{Input: input, Entries: entries}) == nil {
|
|
52
|
+
t.Fatal("clone joiner returned nil")
|
|
53
|
+
}
|
|
54
|
+
if NotationJoiner.Object(NotationJoiner_ObjectProps{
|
|
55
|
+
Rename: func(str string) string { return str },
|
|
56
|
+
DynamicRename: func() *shimast.Node { return factory.NewIdentifier("rename") },
|
|
57
|
+
DynamicAssign: func() *shimast.Node { return factory.NewIdentifier("assign") },
|
|
58
|
+
Input: input,
|
|
59
|
+
Entries: entries,
|
|
60
|
+
}) == nil ||
|
|
61
|
+
NotationJoiner.Tuple(NotationJoiner_TupleProps{Elements: []*shimast.Expression{value}, Rest: input}) == nil ||
|
|
62
|
+
NotationJoiner.Array(NotationJoiner_ArrayProps{Input: input, Arrow: value}) == nil {
|
|
63
|
+
t.Fatal("notation joiner returned nil")
|
|
64
|
+
}
|
|
65
|
+
object := nativemetadata.MetadataObjectType_create(nativemetadata.MetadataObjectType{
|
|
66
|
+
Name: "Object",
|
|
67
|
+
Properties: []*nativemetadata.MetadataProperty{
|
|
68
|
+
nativemetadata.MetadataProperty_create(nativemetadata.MetadataProperty{Key: literalKey, Value: required}),
|
|
69
|
+
nativemetadata.MetadataProperty_create(nativemetadata.MetadataProperty{Key: dynamicKey, Value: required}),
|
|
70
|
+
},
|
|
71
|
+
})
|
|
72
|
+
if PruneJoiner.Tuple(PruneJoiner_TupleProps{Elements: []*shimast.ConciseBody{value}, Rest: value}) == nil ||
|
|
73
|
+
PruneJoiner.Array(PruneJoiner_ArrayProps{Input: input, Arrow: value}) == nil ||
|
|
74
|
+
PruneJoiner.Object(PruneJoiner_ObjectProps{Input: input, Entries: entries, Object: object}) == nil {
|
|
75
|
+
t.Fatal("prune joiner returned nil")
|
|
76
|
+
}
|
|
77
|
+
if StringifyJoiner.Tuple(StringifyJoiner_TupleProps{}) == nil ||
|
|
78
|
+
StringifyJoiner.Tuple(StringifyJoiner_TupleProps{
|
|
79
|
+
Elements: []*shimast.Expression{
|
|
80
|
+
factory.NewStringLiteral("a", shimast.TokenFlagsNone),
|
|
81
|
+
factory.NewStringLiteral("b", shimast.TokenFlagsNone),
|
|
82
|
+
},
|
|
83
|
+
}) == nil ||
|
|
84
|
+
StringifyJoiner.Tuple(StringifyJoiner_TupleProps{Elements: []*shimast.Expression{value}, Rest: input}) == nil ||
|
|
85
|
+
StringifyJoiner.Array(StringifyJoiner_ArrayProps{Input: input, Arrow: value}) == nil {
|
|
86
|
+
t.Fatal("stringify tuple or array joiner returned nil")
|
|
87
|
+
}
|
|
88
|
+
stringifyEntries := []IExpressionEntry{
|
|
89
|
+
{Input: input, Key: literalKey, Meta: functional, Expression: value},
|
|
90
|
+
{Input: input, Key: dynamicKey, Meta: optional, Expression: value},
|
|
91
|
+
}
|
|
92
|
+
if StringifyJoiner.Object(StringifyJoiner_ObjectProps{Context: nativecontext.ITypiaContext{}, Entries: stringifyEntries}) == nil {
|
|
93
|
+
t.Fatal("stringify object joiner returned nil")
|
|
94
|
+
}
|
|
95
|
+
if stringifyJoiner_regular_condition(IExpressionEntry{Input: input, Meta: functional}) == nil ||
|
|
96
|
+
stringifyJoiner_regular_arrow() == nil ||
|
|
97
|
+
stringifyJoiner_binding_pattern() == nil ||
|
|
98
|
+
stringifyJoiner_reduce([]*shimast.Node{input, value}, shimast.KindAmpersandAmpersandToken) == nil ||
|
|
99
|
+
stringifyJoiner_internal(nativecontext.ITypiaContext{}, "helper") == nil {
|
|
100
|
+
t.Fatal("stringify helper returned nil")
|
|
101
|
+
}
|
|
102
|
+
if joinStrings([]string{}, ",") != "" || joinStrings([]string{"a", "b"}, ",") != "a,b" {
|
|
103
|
+
t.Fatal("joinStrings returned unexpected output")
|
|
104
|
+
}
|
|
105
|
+
if cloneJoiner_regular_skip([]IExpressionEntry{{Key: literalKey}}) == nil ||
|
|
106
|
+
cloneJoiner_metadata_to_pattern(struct {
|
|
107
|
+
top bool
|
|
108
|
+
metadata *nativemetadata.MetadataSchema
|
|
109
|
+
}{top: true, metadata: booleanKey}) == "" ||
|
|
110
|
+
cloneJoiner_metadata_to_pattern(struct {
|
|
111
|
+
top bool
|
|
112
|
+
metadata *nativemetadata.MetadataSchema
|
|
113
|
+
}{top: true, metadata: templateKey}) == "" ||
|
|
114
|
+
cloneJoiner_template_to_pattern(struct {
|
|
115
|
+
top bool
|
|
116
|
+
template []*nativemetadata.MetadataSchema
|
|
117
|
+
}{top: true, template: []*nativemetadata.MetadataSchema{literalKey, numberKey}}) == "" {
|
|
118
|
+
t.Fatal("clone pattern helper returned empty output")
|
|
119
|
+
}
|
|
120
120
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
}
|
|
129
|
-
if stringifyJoiner_internal(nativecontext.ITypiaContext{Importer: nativecontext.NewImportProgrammer()}, "jsonStringifyTail") == nil {
|
|
130
|
-
t.Fatal("stringify internal importer branch returned nil")
|
|
131
|
-
}
|
|
121
|
+
programmer := NewFunctionProgrammer("joiner")
|
|
122
|
+
if programmer.EmplaceVariable("cached", value) == nil || len(programmer.Declare(false)) == 0 {
|
|
123
|
+
t.Fatal("function programmer variable branch failed")
|
|
124
|
+
}
|
|
125
|
+
if stringifyJoiner_internal(nativecontext.ITypiaContext{Importer: nativecontext.NewImportProgrammer()}, "jsonStringifyTail") == nil {
|
|
126
|
+
t.Fatal("stringify internal importer branch returned nil")
|
|
127
|
+
}
|
|
132
128
|
}
|
|
133
129
|
|
|
134
130
|
func helperLiteralKey(value string) *nativemetadata.MetadataSchema {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
131
|
+
meta := nativemetadata.MetadataSchema_initialize()
|
|
132
|
+
meta.Constants = append(meta.Constants, nativemetadata.MetadataConstant_create(nativemetadata.MetadataConstant{
|
|
133
|
+
Type: "string",
|
|
134
|
+
Values: []*nativemetadata.MetadataConstantValue{
|
|
135
|
+
nativemetadata.MetadataConstantValue_create(nativemetadata.MetadataConstantValue{Value: value}),
|
|
136
|
+
},
|
|
137
|
+
}))
|
|
138
|
+
return meta
|
|
143
139
|
}
|
|
144
140
|
|
|
145
141
|
func helperAtomic(kind string) *nativemetadata.MetadataSchema {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
142
|
+
meta := nativemetadata.MetadataSchema_initialize()
|
|
143
|
+
meta.Atomics = append(meta.Atomics, nativemetadata.MetadataAtomic_create(nativemetadata.MetadataAtomic{Type: kind}))
|
|
144
|
+
return meta
|
|
149
145
|
}
|
|
@@ -4,175 +4,93 @@
|
|
|
4
4
|
package iterate
|
|
5
5
|
|
|
6
6
|
import (
|
|
7
|
-
|
|
7
|
+
"testing"
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
nativehelpers "github.com/samchon/typia/packages/typia/native/core/programmers/helpers"
|
|
14
|
-
nativemetadata "github.com/samchon/typia/packages/typia/native/core/schemas/metadata"
|
|
9
|
+
shimast "github.com/microsoft/typescript-go/shim/ast"
|
|
10
|
+
nativecontext "github.com/samchon/typia/packages/typia/native/core/context"
|
|
11
|
+
nativehelpers "github.com/samchon/typia/packages/typia/native/core/programmers/helpers"
|
|
12
|
+
nativemetadata "github.com/samchon/typia/packages/typia/native/core/schemas/metadata"
|
|
15
13
|
)
|
|
16
14
|
|
|
17
15
|
// TestIterateCheckCoverage exercises dynamic and union check helpers.
|
|
18
16
|
//
|
|
19
17
|
// Dynamic object and array-like union checks are selected only for particular
|
|
20
18
|
// metadata shapes. This test constructs those shapes directly and verifies each
|
|
21
|
-
// helper returns AST nodes for dynamic keys
|
|
19
|
+
// helper returns AST nodes for dynamic keys and dynamic properties.
|
|
22
20
|
//
|
|
23
21
|
// 1. Check dynamic key branches for nullable, optional, atomic, constant, template, and native keys.
|
|
24
22
|
// 2. Check dynamic object property branches with equals, undefined, and superfluous handling.
|
|
25
|
-
// 3. Check tuple and array union disambiguation with a custom accessor.
|
|
26
|
-
// 4. Verify explore-map and return-wrapping helper behavior.
|
|
27
23
|
func TestIterateCheckCoverage(t *testing.T) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
24
|
+
factory := shimast.NewNodeFactory(shimast.NodeFactoryHooks{})
|
|
25
|
+
input := factory.NewIdentifier("input")
|
|
26
|
+
keyMeta := nativemetadata.MetadataSchema_initialize()
|
|
27
|
+
keyMeta.Nullable = true
|
|
28
|
+
keyMeta.Required = false
|
|
29
|
+
keyMeta.Optional = true
|
|
30
|
+
keyMeta.Atomics = append(keyMeta.Atomics,
|
|
31
|
+
nativemetadata.MetadataAtomic_create(nativemetadata.MetadataAtomic{Type: "boolean"}),
|
|
32
|
+
nativemetadata.MetadataAtomic_create(nativemetadata.MetadataAtomic{Type: "number"}),
|
|
33
|
+
nativemetadata.MetadataAtomic_create(nativemetadata.MetadataAtomic{Type: "bigint"}),
|
|
34
|
+
)
|
|
35
|
+
keyMeta.Constants = append(keyMeta.Constants, nativemetadata.MetadataConstant_create(nativemetadata.MetadataConstant{
|
|
36
|
+
Type: "string",
|
|
37
|
+
Values: []*nativemetadata.MetadataConstantValue{
|
|
38
|
+
nativemetadata.MetadataConstantValue_create(nativemetadata.MetadataConstantValue{Value: "fixed"}),
|
|
39
|
+
},
|
|
40
|
+
}))
|
|
41
|
+
keyMeta.Templates = append(keyMeta.Templates, nativemetadata.MetadataTemplate_create(nativemetadata.MetadataTemplate{
|
|
42
|
+
Row: []*nativemetadata.MetadataSchema{iterateLiteral("x"), iterateAtomic("number")},
|
|
43
|
+
}))
|
|
44
|
+
keyMeta.Natives = append(keyMeta.Natives,
|
|
45
|
+
nativemetadata.MetadataNative_create(nativemetadata.MetadataNative{Name: "Boolean"}),
|
|
46
|
+
nativemetadata.MetadataNative_create(nativemetadata.MetadataNative{Name: "BigInt"}),
|
|
47
|
+
nativemetadata.MetadataNative_create(nativemetadata.MetadataNative{Name: "Number"}),
|
|
48
|
+
)
|
|
49
|
+
if Check_dynamic_key(Check_dynamic_keyProps{
|
|
50
|
+
Context: nativecontext.ITypiaContext{},
|
|
51
|
+
Metadata: keyMeta,
|
|
52
|
+
Input: input,
|
|
53
|
+
}) == nil || check_dynamic_key_strict_equal(input, input) == nil ||
|
|
54
|
+
check_dynamic_key_internal(nativecontext.ITypiaContext{}, "helper") == nil {
|
|
55
|
+
t.Fatal("dynamic key helper returned nil")
|
|
56
|
+
}
|
|
57
|
+
if check_dynamic_key_atomist(nativehelpers.ICheckEntry{
|
|
58
|
+
Expression: input,
|
|
59
|
+
Conditions: [][]nativehelpers.ICheckEntry_ICondition{{
|
|
60
|
+
{Expression: input},
|
|
61
|
+
}},
|
|
62
|
+
}) == nil || check_dynamic_key_reduce(nil, shimast.KindBarBarToken) == nil {
|
|
63
|
+
t.Fatal("dynamic key atomist or reducer returned nil")
|
|
64
|
+
}
|
|
70
65
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
66
|
+
regularMeta := iterateAtomic("string")
|
|
67
|
+
optionalMeta := iterateAtomic("string")
|
|
68
|
+
optionalMeta.Required = false
|
|
69
|
+
optionalMeta.Optional = true
|
|
70
|
+
regular := []nativehelpers.IExpressionEntry{
|
|
71
|
+
{Input: input, Key: iterateLiteral("fixed"), Meta: regularMeta, Expression: input},
|
|
72
|
+
{Input: input, Key: iterateLiteral("optional"), Meta: optionalMeta, Expression: input},
|
|
73
|
+
}
|
|
74
|
+
dynamic := []nativehelpers.IExpressionEntry{
|
|
75
|
+
{Input: input, Key: keyMeta, Meta: regularMeta, Expression: input},
|
|
76
|
+
}
|
|
77
|
+
config := Check_object_IConfig{
|
|
78
|
+
Equals: true,
|
|
79
|
+
Undefined: false,
|
|
80
|
+
Positive: factory.NewKeywordExpression(shimast.KindTrueKeyword),
|
|
81
|
+
Superfluous: func(value *shimast.Expression, description *shimast.Expression) *shimast.Node {
|
|
82
|
+
return factory.NewKeywordExpression(shimast.KindFalseKeyword)
|
|
83
|
+
},
|
|
84
|
+
}
|
|
85
|
+
if Check_dynamic_properties(Check_dynamic_propertiesProps{
|
|
86
|
+
Config: config,
|
|
87
|
+
Context: nativecontext.ITypiaContext{},
|
|
88
|
+
Regular: regular,
|
|
89
|
+
Dynamic: dynamic,
|
|
90
|
+
Input: input,
|
|
91
|
+
}) == nil || !check_dynamic_properties_every_required(regular[:1]) ||
|
|
92
|
+
check_dynamic_properties_internal(nativecontext.ITypiaContext{}, "helper") == nil {
|
|
93
|
+
t.Fatal("dynamic properties helper returned unexpected result")
|
|
94
|
+
}
|
|
100
95
|
|
|
101
|
-
stringMeta := iterateAtomic("string")
|
|
102
|
-
array := iterateCheckArray("string[]", stringMeta)
|
|
103
|
-
tuple := iterateCheckTuple("[string]", stringMeta)
|
|
104
|
-
unionConfig := Check_union_array_like_IConfig{
|
|
105
|
-
Checker: func(props Check_union_array_like_CheckerProps) *shimast.Node { return input },
|
|
106
|
-
Decoder: func(props Check_union_array_like_DecoderProps) *shimast.Node { return props.Input },
|
|
107
|
-
Empty: input,
|
|
108
|
-
Success: factory.NewKeywordExpression(shimast.KindTrueKeyword),
|
|
109
|
-
Failure: func(props Check_union_array_like_FailureProps) *shimast.Node {
|
|
110
|
-
if props.Expected == "" {
|
|
111
|
-
t.Fatal("union failure should include expected names")
|
|
112
|
-
}
|
|
113
|
-
return factory.NewReturnStatement(input)
|
|
114
|
-
},
|
|
115
|
-
}
|
|
116
|
-
accessor := Check_union_array_like_IAccessor{
|
|
117
|
-
Transform: func(origin any) any { return origin },
|
|
118
|
-
Element: func(meta any) any {
|
|
119
|
-
if arr, ok := meta.(*nativemetadata.MetadataArray); ok {
|
|
120
|
-
return arr.Type.Value
|
|
121
|
-
}
|
|
122
|
-
return meta
|
|
123
|
-
},
|
|
124
|
-
Name: func(meta any, elem any) string {
|
|
125
|
-
switch typed := meta.(type) {
|
|
126
|
-
case *nativemetadata.MetadataArray:
|
|
127
|
-
return typed.Type.Name
|
|
128
|
-
case *nativemetadata.MetadataTuple:
|
|
129
|
-
return typed.Type.Name
|
|
130
|
-
default:
|
|
131
|
-
return "unknown"
|
|
132
|
-
}
|
|
133
|
-
},
|
|
134
|
-
Front: func(input *shimast.Expression) *shimast.Node {
|
|
135
|
-
return factory.NewElementAccessExpression(input, nil, nativefactories.ExpressionFactory.Number(0), shimast.NodeFlagsNone)
|
|
136
|
-
},
|
|
137
|
-
Array: func(input *shimast.Expression) *shimast.Node { return input },
|
|
138
|
-
Size: func(input *shimast.Expression) *shimast.Node {
|
|
139
|
-
return nativefactories.IdentifierFactory.Access(emit, input, "length")
|
|
140
|
-
},
|
|
141
|
-
}
|
|
142
|
-
if Check_union_array_like(Check_union_array_likeProps{
|
|
143
|
-
Config: unionConfig,
|
|
144
|
-
Accessor: accessor,
|
|
145
|
-
Input: input,
|
|
146
|
-
Definitions: []any{tuple, array},
|
|
147
|
-
Explore: map[string]any{"source": "test"},
|
|
148
|
-
}) == nil || check_union_array_like_array_if(func(init string, from *shimast.Expression, statement *shimast.Node) *shimast.Node {
|
|
149
|
-
return statement
|
|
150
|
-
}, input, input, factory.NewKeywordExpression(shimast.KindTrueKeyword)) == nil ||
|
|
151
|
-
check_union_array_like_return_or_statement(input) == nil {
|
|
152
|
-
t.Fatal("union array-like helper returned nil")
|
|
153
|
-
}
|
|
154
|
-
if check_union_array_like_explore(map[string]any{}, true, ".x").(map[string]any)["postfix"] != ".x" ||
|
|
155
|
-
check_union_array_like_explore_trace(map[string]any{}, true).(map[string]any)["tracable"] != true {
|
|
156
|
-
t.Fatal("union array-like explore helper mismatch")
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
func iterateCheckArray(name string, value *nativemetadata.MetadataSchema) *nativemetadata.MetadataArray {
|
|
161
|
-
return nativemetadata.MetadataArray_create(nativemetadata.MetadataArray{
|
|
162
|
-
Type: nativemetadata.MetadataArrayType_create(nativemetadata.MetadataArrayType{
|
|
163
|
-
Name: name,
|
|
164
|
-
Value: value,
|
|
165
|
-
Nullables: []bool{},
|
|
166
|
-
}),
|
|
167
|
-
})
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
func iterateCheckTuple(name string, value *nativemetadata.MetadataSchema) *nativemetadata.MetadataTuple {
|
|
171
|
-
return nativemetadata.MetadataTuple_create(nativemetadata.MetadataTuple{
|
|
172
|
-
Type: nativemetadata.MetadataTupleType_create(nativemetadata.MetadataTupleType{
|
|
173
|
-
Name: name,
|
|
174
|
-
Elements: []*nativemetadata.MetadataSchema{value},
|
|
175
|
-
Nullables: []bool{},
|
|
176
|
-
}),
|
|
177
|
-
})
|
|
178
96
|
}
|