(t *testing.T)
| 11 | ) |
| 12 | |
| 13 | func TestGoTransform(t *testing.T) { |
| 14 | root := RunDSL(t, testdata.TestTypesDSL) |
| 15 | var ( |
| 16 | scope = NewNameScope() |
| 17 | |
| 18 | // types to test |
| 19 | simple = root.UserType("Simple") |
| 20 | super = root.UserType("Super") |
| 21 | required = root.UserType("Required") |
| 22 | defaultT = root.UserType("Default") |
| 23 | |
| 24 | simpleMap = root.UserType("SimpleMap") |
| 25 | requiredMap = root.UserType("RequiredMap") |
| 26 | defaultMap = root.UserType("DefaultMap") |
| 27 | nestedMap = root.UserType("NestedMap") |
| 28 | typeMap = root.UserType("TypeMap") |
| 29 | arrayMap = root.UserType("ArrayMap") |
| 30 | |
| 31 | simpleArray = root.UserType("SimpleArray") |
| 32 | requiredArray = root.UserType("RequiredArray") |
| 33 | defaultArray = root.UserType("DefaultArray") |
| 34 | nestedArray = root.UserType("NestedArray") |
| 35 | typeArray = root.UserType("TypeArray") |
| 36 | mapArray = root.UserType("MapArray") |
| 37 | |
| 38 | recursive = root.UserType("Recursive") |
| 39 | recursiveArray = root.UserType("RecursiveArray") |
| 40 | recursiveMap = root.UserType("RecursiveMap") |
| 41 | composite = root.UserType("Composite") |
| 42 | customField = root.UserType("CompositeWithCustomField") |
| 43 | defaults = root.UserType("WithDefaults") |
| 44 | |
| 45 | resultType = root.UserType("ResultType") |
| 46 | rtCol = root.UserType("ResultTypeCollection") |
| 47 | |
| 48 | simpleAlias = root.UserType("SimpleAlias") |
| 49 | nestedMapAlias = root.UserType("NestedMapAlias") |
| 50 | arrayMapAlias = root.UserType("ArrayMapAlias") |
| 51 | stringAlias = root.UserType("StringAlias") |
| 52 | |
| 53 | // primitive tyes |
| 54 | stringT = expr.String |
| 55 | |
| 56 | // attribute contexts used in test cases |
| 57 | defaultCtx = NewAttributeContext(false, false, true, "", scope) |
| 58 | defaultCtxPkg = NewAttributeContext(false, false, true, "mypkg", scope) |
| 59 | pointerCtx = NewAttributeContext(true, false, false, "", scope) |
| 60 | defaultPointerCtx = NewAttributeContext(true, false, true, "", scope) |
| 61 | ) |
| 62 | tc := map[string][]struct { |
| 63 | Name string |
| 64 | Source expr.DataType |
| 65 | Target expr.DataType |
| 66 | SourceCtx *AttributeContext |
| 67 | TargetCtx *AttributeContext |
| 68 | }{ |
| 69 | // source and target type use default |
| 70 | "source-target-type-use-default": { |
nothing calls this directly
no test coverage detected