-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test cases for structs with optional fields
- Loading branch information
Showing
4 changed files
with
151 additions
and
3 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
127 changes: 127 additions & 0 deletions
127
testdata/jennies/rawtypes/struct_with_optional_fields.txtar
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,127 @@ | ||
# Basic struct with scalar fields, all required. | ||
-- ir.json -- | ||
{ | ||
"Package": "struct_optional_fields", | ||
"Definitions": [ | ||
{ | ||
"Name": "SomeStruct", | ||
"Type": { | ||
"Kind": "struct", | ||
"Struct": { | ||
"Fields": [ | ||
{ | ||
"Name": "FieldRef", | ||
"Required": false, | ||
"Type": { | ||
"Kind": "ref", | ||
"Ref": {"ReferredType": "SomeOtherStruct"} | ||
} | ||
}, | ||
{ | ||
"Name": "FieldString", | ||
"Required": false, | ||
"Type": { | ||
"Kind": "scalar", | ||
"Scalar": {"ScalarKind": "string"} | ||
} | ||
}, | ||
{ | ||
"Name": "FieldAnonymousEnum", | ||
"Required": false, | ||
"Type": { | ||
"Kind": "enum", | ||
"Enum": { | ||
"Values": [ | ||
{ | ||
"Name": "GreaterThan", | ||
"Type": { | ||
"Kind": "scalar", | ||
"Scalar": {"ScalarKind": "string"} | ||
}, | ||
"Value": ">" | ||
}, | ||
{ | ||
"Name": "LessThan", | ||
"Type": { | ||
"Kind": "scalar", | ||
"Scalar": {"ScalarKind": "string"} | ||
}, | ||
"Value": "<" | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
{ | ||
"Name": "FieldArrayOfStrings", | ||
"Required": false, | ||
"Type": { | ||
"Kind": "array", | ||
"Array": { | ||
"ValueType": { | ||
"Kind": "scalar", | ||
"Scalar": {"ScalarKind": "string"} | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
"Name": "FieldAnonymousStruct", | ||
"Required": false, | ||
"Type": { | ||
"Kind": "struct", | ||
"Struct": { | ||
"Fields": [ | ||
{ | ||
"Name": "FieldAny", | ||
"Required": true, | ||
"Type": { | ||
"Kind": "scalar", | ||
"Scalar": {"ScalarKind": "any"} | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
|
||
{ | ||
"Name": "SomeOtherStruct", | ||
"Type": { | ||
"Kind": "struct", | ||
"Struct": { | ||
"Fields": [ | ||
{ | ||
"Name": "FieldAny", | ||
"Required": true, | ||
"Type": { | ||
"Kind": "scalar", | ||
"Scalar": {"ScalarKind": "any"} | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} | ||
] | ||
} | ||
-- out/jennies/TypescriptRawTypes -- | ||
== types/struct_optional_fields/types_gen.ts | ||
export interface SomeStruct { | ||
fieldRef?: SomeOtherStruct; | ||
fieldString?: string; | ||
fieldAnonymousEnum?: ">" | "<"; | ||
fieldArrayOfStrings?: string[]; | ||
fieldAnonymousStruct?: { | ||
fieldAny: any; | ||
}; | ||
} | ||
|
||
export interface SomeOtherStruct { | ||
fieldAny: 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