@darabonba/python-generator 1.2.18 → 2.0.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.
Files changed (138) hide show
  1. package/ChangeLog.md +0 -155
  2. package/lib/builtin.js +818 -0
  3. package/lib/generator.js +2704 -0
  4. package/lib/helper.js +422 -0
  5. package/package.json +6 -5
  6. package/src/lib/helper.js +11 -1
  7. package/src/resolver/base.js +3 -1
  8. package/src/resolver/client.js +7 -4
  9. package/src/resolver/model.js +5 -3
  10. package/tests/expected/alias/setup.py +79 -0
  11. package/tests/expected/alias/tea_python_tests/__init__.py +1 -0
  12. package/tests/expected/alias/tea_python_tests/client.py +35 -0
  13. package/tests/expected/annotation/tea_python_tests/__init__.py +1 -0
  14. package/tests/expected/annotation/tea_python_tests/client.py +93 -0
  15. package/tests/expected/annotation/tea_python_tests/models.py +37 -0
  16. package/tests/expected/api/tea_python_tests/__init__.py +1 -0
  17. package/tests/expected/api/tea_python_tests/client.py +106 -0
  18. package/tests/expected/builtin/tea_python_tests/client.py +685 -0
  19. package/tests/expected/comment/tea_python_tests/__init__.py +1 -0
  20. package/tests/expected/comment/tea_python_tests/client.py +288 -0
  21. package/tests/expected/comment/tea_python_tests/models.py +195 -0
  22. package/tests/expected/complex/tea_python_tests/__init__.py +1 -0
  23. package/tests/expected/complex/tea_python_tests/client.py +1168 -0
  24. package/tests/expected/complex/tea_python_tests/exceptions.py +39 -0
  25. package/tests/expected/complex/tea_python_tests/models.py +570 -0
  26. package/tests/expected/const/tea_python_tests/__init__.py +1 -0
  27. package/tests/expected/const/tea_python_tests/client.py +14 -0
  28. package/tests/expected/empty/setup.py +74 -0
  29. package/tests/expected/empty/tea_python_tests/__init__.py +1 -0
  30. package/tests/expected/empty/tea_python_tests/client.py +10 -0
  31. package/tests/expected/exec/tea_python_tests/__init__.py +1 -0
  32. package/tests/expected/exec/tea_python_tests/exec_client.py +21 -0
  33. package/tests/expected/function/tea_python_tests/__init__.py +1 -0
  34. package/tests/expected/function/tea_python_tests/client.py +64 -0
  35. package/tests/expected/import/setup.py +78 -0
  36. package/tests/expected/import/tea_python_tests/__init__.py +1 -0
  37. package/tests/expected/import/tea_python_tests/client.py +29 -0
  38. package/tests/expected/map/tea_python_tests/__init__.py +1 -0
  39. package/tests/expected/map/tea_python_tests/client.py +39 -0
  40. package/tests/expected/model/tea_python_tests/__init__.py +1 -0
  41. package/tests/expected/model/tea_python_tests/client.py +10 -0
  42. package/tests/expected/model/tea_python_tests/exceptions.py +28 -0
  43. package/tests/expected/model/tea_python_tests/models.py +780 -0
  44. package/tests/expected/multi/tea_python_tests/api.py +95 -0
  45. package/tests/expected/multi/tea_python_tests/client.py +40 -0
  46. package/tests/expected/multi/tea_python_tests/lib/util.py +19 -0
  47. package/tests/expected/multi/tea_python_tests/model/user.py +23 -0
  48. package/tests/expected/multi/tea_python_tests/model/user_exceptions.py +83 -0
  49. package/tests/expected/multi/tea_python_tests/model/user_models.py +145 -0
  50. package/tests/expected/python2/function/tea_python_tests/client.py +3 -1
  51. package/tests/expected/python2/model/tea_python_tests/models.py +57 -30
  52. package/tests/expected/python3/function/tea_python_tests/client.py +3 -1
  53. package/tests/expected/python3/model/tea_python_tests/models.py +57 -29
  54. package/tests/expected/statements/tea_python_tests/__init__.py +1 -0
  55. package/tests/expected/statements/tea_python_tests/client.py +86 -0
  56. package/tests/expected/super/tea_python_tests/__init__.py +1 -0
  57. package/tests/expected/super/tea_python_tests/client.py +16 -0
  58. package/tests/expected/typedef/setup.py +77 -0
  59. package/tests/expected/typedef/tea_python_tests/__init__.py +1 -0
  60. package/tests/expected/typedef/tea_python_tests/client.py +74 -0
  61. package/tests/expected/typedef/tea_python_tests/models.py +42 -0
  62. package/tests/fixtures/alias/Darafile +11 -0
  63. package/tests/fixtures/alias/libraries/Alias/Darafile +11 -0
  64. package/tests/fixtures/alias/libraries/Alias-Symbol/Darafile +11 -0
  65. package/tests/fixtures/builtin/Darafile +6 -0
  66. package/tests/fixtures/builtin/main.dara +333 -0
  67. package/tests/fixtures/complex/libraries/import.dara +18 -11
  68. package/tests/fixtures/complex/main.dara +451 -103
  69. package/tests/fixtures/function/main.dara +2 -0
  70. package/tests/fixtures/import/libraries/Darafile +1 -1
  71. package/tests/fixtures/import/pack/Darafile +3 -0
  72. package/tests/fixtures/map/libraries/Darafile +3 -0
  73. package/tests/fixtures/map/libraries/import.dara +4 -0
  74. package/tests/fixtures/map/main.dara +17 -2
  75. package/tests/fixtures/model/.libraries.json +3 -0
  76. package/tests/fixtures/model/Darafile +5 -2
  77. package/tests/fixtures/model/libraries/Darafile +20 -0
  78. package/tests/fixtures/model/libraries/import.dara +27 -0
  79. package/tests/fixtures/model/main.dara +57 -37
  80. package/tests/fixtures/multi/.libraries.json +3 -0
  81. package/tests/fixtures/multi/Darafile +12 -0
  82. package/tests/fixtures/multi/api.dara +20 -0
  83. package/tests/fixtures/multi/lib/util.dara +5 -0
  84. package/tests/fixtures/multi/libraries/darabonba_Util_0.2.11/Teafile +62 -0
  85. package/tests/fixtures/multi/libraries/darabonba_Util_0.2.11/main.tea +244 -0
  86. package/tests/fixtures/multi/main.dara +32 -0
  87. package/tests/fixtures/multi/model/user.dara +33 -0
  88. package/tests/{python3.tests.js → main.tests.js} +107 -65
  89. package/tests/output/alias/setup.py +79 -0
  90. package/tests/output/alias/tea_python_tests/client.py +35 -0
  91. package/tests/output/annotation/setup.py +77 -0
  92. package/tests/output/annotation/tea_python_tests/client.py +93 -0
  93. package/tests/output/annotation/tea_python_tests/models.py +37 -0
  94. package/tests/output/api/setup.py +77 -0
  95. package/tests/output/api/tea_python_tests/client.py +106 -0
  96. package/tests/output/builtin/setup.py +77 -0
  97. package/tests/output/builtin/tea_python_tests/client.py +685 -0
  98. package/tests/output/comment/setup.py +77 -0
  99. package/tests/output/comment/tea_python_tests/client.py +288 -0
  100. package/tests/output/comment/tea_python_tests/models.py +195 -0
  101. package/tests/output/complex/setup.py +77 -0
  102. package/tests/output/complex/tea_python_tests/client.py +1168 -0
  103. package/tests/output/complex/tea_python_tests/exceptions.py +39 -0
  104. package/tests/output/complex/tea_python_tests/models.py +570 -0
  105. package/tests/output/const/setup.py +77 -0
  106. package/tests/output/const/tea_python_tests/client.py +14 -0
  107. package/tests/output/empty/setup.py +77 -0
  108. package/tests/output/empty/tea_python_tests/client.py +10 -0
  109. package/tests/output/exec/setup.py +77 -0
  110. package/tests/output/exec/tea_python_tests/exec_client.py +21 -0
  111. package/tests/output/function/setup.py +77 -0
  112. package/tests/output/function/tea_python_tests/client.py +64 -0
  113. package/tests/output/import/setup.py +78 -0
  114. package/tests/output/import/tea_python_tests/client.py +29 -0
  115. package/tests/output/map/setup.py +77 -0
  116. package/tests/output/map/tea_python_tests/client.py +39 -0
  117. package/tests/output/model/setup.py +77 -0
  118. package/tests/output/model/tea_python_tests/client.py +10 -0
  119. package/tests/output/model/tea_python_tests/exceptions.py +28 -0
  120. package/tests/output/model/tea_python_tests/models.py +780 -0
  121. package/tests/output/multi/setup.py +77 -0
  122. package/tests/output/multi/tea_python_tests/api.py +95 -0
  123. package/tests/output/multi/tea_python_tests/client.py +40 -0
  124. package/tests/output/multi/tea_python_tests/lib/util.py +19 -0
  125. package/tests/output/multi/tea_python_tests/model/user.py +23 -0
  126. package/tests/output/multi/tea_python_tests/model/user_exceptions.py +83 -0
  127. package/tests/output/multi/tea_python_tests/model/user_models.py +145 -0
  128. package/tests/output/statements/setup.py +77 -0
  129. package/tests/output/statements/tea_python_tests/client.py +86 -0
  130. package/tests/output/super/setup.py +77 -0
  131. package/tests/output/super/tea_python_tests/client.py +16 -0
  132. package/tests/output/typedef/setup.py +78 -0
  133. package/tests/output/typedef/tea_python_tests/client.py +74 -0
  134. package/tests/output/typedef/tea_python_tests/models.py +42 -0
  135. package/tests/common.tests.js +0 -244
  136. package/tests/lib.tests.js +0 -269
  137. package/tests/python2.tests.js +0 -283
  138. package/tests/resolver.tests.js +0 -434
@@ -2,104 +2,256 @@ import Source;
2
2
 
3
3
  extends Source;
4
4
 
5
- const version = '2019-01-08';
6
-
5
+ type @protocol = string
6
+ type @pathname = string
7
+ type @Strs = [ string ]
8
+ type @compleList = [[string]]
9
+ type @endpointMap = map[string]string
7
10
  type @configs = [ Source.Config ];
8
11
 
9
- init(config: Source.Config){
10
- super(config);
11
- @configs[0] = config;
12
+ init(sourceConfig: Source.Config){
13
+ super(sourceConfig);
14
+ @configs[0] = sourceConfig;
15
+ var test : Source = new Source(sourceConfig);
16
+ }
17
+
18
+ exception Err1 = {
19
+ data: map[string]string
20
+ }
21
+
22
+ exception Err2 = {
23
+ accessErrMessage: string
12
24
  }
13
25
 
26
+
14
27
  model ComplexRequest = {
15
28
  accessKey: string,
16
29
  body: readable(name='Body', example='Body', description='Body'),
17
30
  strs: [ string ](name='Strs', example='Strs', description='Strs'),
31
+ mapList: [ map[string]any ](name='mapList', example='mapList', description='mapList', deprecated=false),
18
32
  header: {
19
- content: string(name='Content', example='Content', signed='true', description='Body')
33
+ content: string(name='Content', example='Content
34
+
35
+ test example
36
+ test example11', signed='true', description='The ID of the security group to which you want to assign the instance. Instances in the same security group can communicate with each other. The maximum number of instances that a security group can contain depends on the type of the security group. For more information, see the "Security group limits" section in [Limits](https://help.aliyun.com/document_detail/25412.html#SecurityGroupQuota).
37
+
38
+ >Notice: The network type of the new instance must be the same as that of the security group specified by the `SecurityGroupId` parameter. For example, if the specified security group is of the VPC type, the new instance is also of the VPC type and you must specify `VSwitchId`.
39
+
40
+ If you do not use `LaunchTemplateId` or `LaunchTemplateName` to specify a launch template, you must specify SecurityGroupId. Take note of the following items:
41
+
42
+ * You can set `SecurityGroupId` to specify a single security group or set `SecurityGroupIds.N` to specify one or more security groups. However, you cannot specify both `SecurityGroupId` and `SecurityGroupIds.N`.
43
+ * If `NetworkInterface.N.InstanceType` is set to `Primary`, you cannot specify `SecurityGroupId` or `SecurityGroupIds.N` but can specify `NetworkInterface.N.SecurityGroupId` or `NetworkInterface.N.SecurityGroupIds.N`.', nullable=true, checkBlank=true, sensitive=false)
20
44
  }(description='header', name='header'),
21
- Num: number,
22
45
  configs: {
23
46
  key: string,
24
47
  value: [ string ],
25
48
  extra: map[string] string
26
49
  },
27
- part?: [
28
- {
29
- partNumber?: string(description='PartNumber', name='PartNumber')
30
- }
31
- ](description='Part', name='Part'),
32
- complexList: [[[
33
- {
34
- name?: string(name='Name'),
35
- code?: int32(name='Code'),
36
- }
37
- ]]](name='complexList'),
38
- complexList1: [[map[string]string]],
39
- complexList2: [[[
40
- {
41
- any?: any(name='Name'),
42
- }
43
- ]]](name='ComplexList2'),
50
+ num: number(name='num', nullable=false, checkBlank=false, sensitive=true),
51
+ i64: int64,
52
+ f64: double,
53
+ b: boolean,
54
+ f32: float,
55
+ f64List: [ double ],
56
+ floatList: [ float ],
57
+ booleantList: [ boolean ],
58
+ i32: int32,
59
+ stringList: [ string ],
60
+ intList: [ integer ],
61
+ int32List: [ int32 ],
62
+ int16List: [ int16 ],
63
+ int64List: [ int64 ],
64
+ longList: [ long ],
65
+ uint64List: [ uint64 ],
66
+ uint32List: [ uint32 ],
67
+ uint16List: [ uint16 ],
68
+ u64: uint64,
69
+ u32: uint32,
70
+ u16: uint16,
71
+ obj: object,
72
+ any: any,
73
+ byt: bytes,
74
+ req: $Request,
75
+ resp: $Response,
76
+ map: map[string]string,
77
+ numMap: map[string]number,
78
+ modelMap: map[string]Source.Request,
79
+ request: Source.Request,
80
+ client: Source,
81
+ instance: Source.Request.instance,
44
82
  from: string(name='from', description='test keywords'),
45
83
  self: string(name='self', description='test keywords'),
46
84
  print: string(name='print', description='test keywords'),
47
85
  exec: string(name='exec', description='test keywords'),
86
+ str: string(name='srt', description='test keywords'),
87
+ part?: [
88
+ {
89
+ partNumber?: string(description='PartNumber', name='PartNumber')
90
+ }
91
+ ](description='Part', name='Part', deprecated=true),
48
92
  }
49
93
 
50
- async function hello(request: object, strs: [ string ]): [ string ] {
51
- return array1();
94
+ model Response {
95
+ instance: ComplexRequest.part,
52
96
  }
53
97
 
54
- static async function print(reqeust: $Request, reqs: [ ComplexRequest ], response: $Response, val: map[string]string): Source.Request {
55
- return {};
98
+ async function hello(request: object, strs: [ string ], complexList: [[string]]): [ string ] {
99
+ var a : [[string]] = null;
100
+ return array1();
56
101
  }
57
102
 
58
- api complex1(request: ComplexRequest, client: Source): Source.RuntimeObject {
59
- var x = false;
60
- var y = true;
61
- var z = false;
62
- if (x && y || !z) {
63
- x = y;
64
- }
65
- // to map test.
66
- var req = new Source.Request{};
67
- var m = callToMap(req);
68
-
103
+ static async function print(reqeust: $Request, reqs: [ ComplexRequest ], response: $Response, val: map[string]string): Source.Request;
104
+
105
+ static function intToInt32(a: int32):void;
106
+ api Complex1(request: ComplexRequest, sourceClient: Source): Source.RuntimeObject {
69
107
  var name = 'complex';
70
- var mapVal = {test="ok"};
71
- var version = `/${__module.version}${@pathname}`;
108
+ var read : readable = null;
109
+ var byt : bytes = null;
72
110
  var moduleModelMapVal: map[string] Source.RuntimeObject = {};
73
111
  var moduleMapVal: map[string] Source = {};
74
112
  var modelMapVal: map[string] ComplexRequest = {};
75
113
  var subModelMapVal: map[string] ComplexRequest.header = {};
114
+ var reqMap : map[string]ComplexRequest = null;
115
+ var mapString = {
116
+ str = request.accessKey,
117
+ };
118
+ var inte : integer = 1;
119
+ var a : integer = 1;
120
+ var b : int32 = null;
121
+ b = a;
122
+ var c : int32 = a;
123
+ intToInt32(a);
124
+ var mapVal = {
125
+ read = read,
126
+ test = '{"test":"ok"}',
127
+ b = request.b,
128
+ num = request.num,
129
+ u16 = request.u16,
130
+ u32 = request.u32,
131
+ u64 = request.u64,
132
+ u16List = request.uint16List,
133
+ u32List = request.uint32List,
134
+ u64List = request.uint64List,
135
+ i64List = request.int64List,
136
+ i16List = request.int16List,
137
+ i32List = request.int32List,
138
+ intList = request.intList,
139
+ stringList = request.stringList,
140
+ i32 = request.i32,
141
+ booleantList = request.booleantList,
142
+ floatList = request.floatList,
143
+ float64List = request.f64List,
144
+ f32 = request.f32,
145
+ f64 = request.f64,
146
+ i64 = request.i64,
147
+ };
148
+ var abool = true;
149
+ var req = new ComplexRequest{
150
+ b = false,
151
+ num = 10,
152
+ i32 = a,
153
+ intList = [10,11],
154
+ int16List = [10, 11],
155
+ int32List = [10, 11],
156
+ int64List = [10, 11],
157
+ longList = [10L, 11L],
158
+ floatList = [ 0.1f, 0.2f ],
159
+ stringList = ['10','11'],
160
+ booleantList = [ true, false ],
161
+ };
162
+ var longList : [long] = [
163
+ 432435L
164
+ ];
165
+ var anyList : [any] = [
166
+ 432435L,
167
+ "str",
168
+ true,
169
+ 10,
170
+ 0.1f
171
+ ];
172
+ var floatMap : map[string]float = {
173
+ key1 = 0.1f,
174
+ key2 = 0.2
175
+ };
176
+ var doubleMap : map[string]double = {
177
+ key1 = 0.1d,
178
+ key2 = 0.2d
179
+ };
180
+ var intMap : map[string]integer = {
181
+ key1 = 1,
182
+ key2 = 2
183
+ };
184
+ var longMap : map[string]long = {
185
+ key1 = 1,
186
+ key2 = 2
187
+ };
188
+ var int16Map : map[string]int16 = {
189
+ key1 = 1,
190
+ key2 = 2
191
+ };
192
+ var int32Map : map[string]int32 = {
193
+ key1 = 1,
194
+ key2 = 2
195
+ };
196
+ var int64Map : map[string]int64 = {
197
+ key1 = 1,
198
+ key2 = 2
199
+ };
200
+ var anyMap : map[string]any = {
201
+ key1 = 0.1,
202
+ key2 = 1,
203
+ key3 = 'test',
204
+ key4 = true,
205
+ key5 = ['test', 1, true, ['test']],
206
+ key6 = [
207
+ {
208
+ a = "test",
209
+ b = 1,
210
+ c = true,
211
+ d = ['test'],
212
+ }
213
+ ],
214
+ };
215
+
216
+ for (var itemTmp : anyList) {
217
+ $Logger.info(`${itemTmp}`);
218
+ }
219
+
220
+ for (var item : ["1","2"]) {
221
+ var anyMap : map[string]string = {};
222
+ anyMap[item] = 'test';
223
+ break;
224
+ }
225
+ @Strs = request.strs;
226
+ @protocol = 'test';
227
+ @endpointMap[@protocol];
228
+ @endpointMap['test'] = 'ok';
229
+ request.strs = @Strs;
76
230
  __request.protocol = @protocol;
77
- __request.port = 80;
231
+ __request.port = request.num;
78
232
  __request.method = 'GET';
79
233
  __request.pathname = `/${@pathname}`;
80
- __request.query = Source.query({
234
+ __request.query = {
81
235
  date = '2019',
82
- ...request.header,
83
- ...mapVal
84
- });
85
- __request.body = Source.body();
86
- request.from = 'test';
87
- var from = new ComplexRequest{
88
- from = 'test',
236
+ name = __request.method,
237
+ };
238
+ var tmp = {
239
+ ...__request.query,
240
+ ...__request.headers,
241
+ ...__request,
89
242
  };
90
- Complex3(from);
91
243
  } returns {
92
- if (true && true) {
244
+ if (true && true){
93
245
  return null;
94
- } else if (true || false) {
246
+ } else if(Source.judgeStr("test") || false){
95
247
  return new Source.RuntimeObject{};
96
248
  }
97
- client.print(request, '1');
98
- client.printAsync(request, '1');
99
- hello(request, ["1","2"]);
100
- hello(null, null);
101
- Complex3(null);
249
+ sourceClient.printData(request, '1');
250
+ hello(request, ["1","2"], null);
251
+ hello(null, null, null);
102
252
  return {};
253
+ Complex3(null, 'test');
254
+ return null;
103
255
  } runtime {
104
256
  timeouted = 'retry'
105
257
  }
@@ -107,32 +259,44 @@ api complex1(request: ComplexRequest, client: Source): Source.RuntimeObject {
107
259
  api Complex2(request: ComplexRequest, str: [ string ], val: map[string]string): object {
108
260
  var name = 'complex';
109
261
  var config = new Source.Config{};
110
- var client = new Source(config);
262
+ var sourceClient = new Source(config);
263
+ var configArray : [Source.Config] = [config];
264
+ sourceClient.printData(request, '1');
111
265
  __request.protocol = 'HTTP';
112
266
  __request.port = 80;
113
267
  __request.method = 'GET';
114
268
  __request.pathname = '/';
115
- __request.query = Source.query({
269
+ __request.query = {
116
270
  date = '2019',
117
- version = __module.version,
118
271
  protocol = __request.protocol,
272
+ };
273
+ }
119
274
 
120
- });
121
- __request.body = Source.body();
275
+ api ComplexMap(): map[string]any {
276
+ } runtime {
277
+
122
278
  }
123
279
 
124
- api Complex3(request: ComplexRequest): ComplexRequest {
125
- var name = 'complex';
126
- __request.protocol = TemplateString();
280
+ api Complex3(request: ComplexRequest, name: string): ComplexRequest {
281
+ name = 'complex';
282
+ __request.protocol = templateString();
127
283
  __request.port = 80;
128
284
  __request.method = 'GET';
129
285
  __request.pathname = '/';
130
- __request.query = Source.query({
286
+ __request.body = 'body';
287
+ __request.query = {
131
288
  date = '2019',
132
- });
133
- __request.body = Source.body();
134
- __request.headers.host = 'hello';
289
+ };
290
+ var tmp : ComplexRequest = null;
291
+ tmp = returnModel();
292
+ name = @protocol;
135
293
  } returns {
294
+ var x = false;
295
+ var y = true;
296
+ var z = false;
297
+ if (x && y || !z) {
298
+ x = y;
299
+ }
136
300
  var resp = __response;
137
301
  var req = new Source.Request{
138
302
  accesskey = request.accessKey,
@@ -141,17 +305,80 @@ api Complex3(request: ComplexRequest): ComplexRequest {
141
305
  array0(request);
142
306
  req.accesskey = 'accesskey';
143
307
  req.accesskey = request.accessKey;
144
- Source.parse(ComplexRequest);
308
+ printNull();
309
+ throwsFunc();
310
+ __response.statusCode;
145
311
  Source.array(request, '1');
146
- Source.asyncFunc();
147
312
  return {
148
313
  ...__request.query
149
314
  };
150
315
  }
151
316
 
317
+ static function assignWithArray() throws: void {
318
+ var list : [ string ] = null;
319
+ list = [ "test" ];
320
+
321
+ var str : string = null;
322
+ str = throwsFunc();
323
+ }
324
+
325
+ function mapAcess(): any {
326
+ var tmp : map[string]any = {
327
+ protocol = @endpointMap[@protocol]
328
+ };
329
+ return;
330
+ }
331
+
332
+
333
+ async function exprFunc(): [ string ] {
334
+ if (!true) {
335
+
336
+ }
337
+ var num = 10;
338
+ var req = new ComplexRequest{};
339
+ var mapVal : map[string]any = {
340
+ num = 10,
341
+ client = Source,
342
+ strs = array1(),
343
+ str = `string${num}`,
344
+ str1 = `string${req.accessKey}`,
345
+ };
346
+ return null;
347
+ }
348
+
349
+ static async function printNull(): void {
350
+ try {
351
+ var str = templateString();
352
+ } catch(e) {
353
+
354
+ } finally {
355
+ var final = 'ok';
356
+ }
357
+ }
358
+
359
+ static async function testTryWithComplexReturnType(): Source.Request {
360
+ try {
361
+ var str = templateString();
362
+ } catch(e) {
363
+
364
+ } finally {
365
+ var final = 'ok';
366
+ }
367
+ return null;
368
+ }
369
+
370
+ static async function testTryWithComplexReturnTypeWithOutCat(): Source.Request {
371
+ try {
372
+ var str = templateString();
373
+ } catch(e) {
374
+ var sim = 'a';
375
+ } finally {
376
+ var final = 'ok';
377
+ }
378
+ return null;
379
+ }
380
+
152
381
  static function array0(req: object): [ any ] {
153
- var temp = new Source.Config{};
154
- var anyArr : [Source.Config] = [temp];
155
382
  return [];
156
383
  }
157
384
 
@@ -159,29 +386,93 @@ static function array1(): [ string ] {
159
386
  return ["1"];
160
387
  }
161
388
 
162
- static function array2(): [[ any ]] {
163
- var temp = new Source.Config{};
164
- var anyArr : [Source.Config] = [temp];
165
- return [[anyArr]];
389
+ async function templateString(): string {
390
+ return `/${@protocol}`;
166
391
  }
167
392
 
168
- async function TemplateString(): string {
393
+ function intOp(a: integer): void {
394
+ var b = a;
395
+ var tmp: map[string]integer = {
396
+ first = a
397
+ };
398
+ b++;
399
+ ++b;
400
+ b--;
401
+ --b;
402
+ tmp.a++;
403
+ ++tmp.a;
404
+ tmp.a--;
405
+ --tmp.a;
406
+ }
407
+
408
+ function throwsFunc() throws: string {
169
409
  return `/${@protocol}`;
170
410
  }
171
411
 
172
- async function emptyModel(): void {
173
- new ComplexRequest;
174
- new ComplexRequest.header;
175
- var status = '';
176
- try {
177
- status = 'failed';
178
- } catch(e) {
179
- status = 'catch exception';
180
- } finally {
181
- status = 'ok';
412
+ function throwsFunc1() throws: string {
413
+ return '';
414
+ }
415
+
416
+ function throwsFunc2() throws: void {
417
+ throw {
418
+ code = '',
419
+ };
420
+ }
421
+
422
+ function throwsFunc3() throws: string {
423
+ throw {
424
+ code = '',
425
+ };
426
+ }
427
+
428
+ function getInt(num: int32): int32 {
429
+ return num;
430
+ }
431
+
432
+ function returnFunc(): string {
433
+ var index: int32 = 0;
434
+ var i = getInt(index);
435
+ return null;
436
+ }
437
+
438
+ function returnFunc1(cfg: Source.Config): Source {
439
+ var config = new Source.Config{};
440
+ return new Source(config);
441
+ }
442
+
443
+ function returnFunc2(): map[string]any {
444
+ var tmp = {
445
+ subMap = 'ok',
446
+ };
447
+ var mapVal = {
448
+ test = tmp,
449
+ };
450
+ if (Source.judgeStr("test")) {
451
+ return mapVal['test'];
452
+ } else {
453
+ var body : readable = null;
454
+ return {
455
+ body = body,
456
+ ...tmp
457
+ };
182
458
  }
183
459
  }
184
460
 
461
+ function returnModel(): ComplexRequest {
462
+ return new ComplexRequest{};
463
+ }
464
+
465
+ function emptyFunc(): void;
466
+
467
+ api noReturn(): void {
468
+ }
469
+
470
+ function Error(e: $Error): $Error {
471
+ var tmp : $Error = null;
472
+ var c : class = null;
473
+ return e;
474
+ }
475
+
185
476
  static function arrayAccess(): string {
186
477
  var configs = ['a', 'b', 'c'];
187
478
  var config = configs[0];
@@ -196,14 +487,17 @@ static function arrayAccess2(): string {
196
487
  return config;
197
488
  }
198
489
 
199
- static function arrayAccess3(request: ComplexRequest, index: number): string {
490
+ static function arrayAccess3(request: ComplexRequest): string {
491
+ var req = new Source.Request{};
492
+ arrayAccess4([req]);
200
493
  var configVal = request.configs.value[0];
201
- var val = request.configs.value[index];
202
- var i0 = 0;
203
- val = request.configs.value[i0];
204
494
  return configVal;
205
495
  }
206
496
 
497
+ static function arrayAccess4(requests: [ Source.Request ]): string {
498
+ return '';
499
+ }
500
+
207
501
  static function arrayAssign(config: string): [ string ] {
208
502
  var configs = ['a', 'b', 'c'];
209
503
  configs[3] = config;
@@ -220,8 +514,6 @@ static function arrayAssign2(config: string): [ string ] {
220
514
 
221
515
  static function arrayAssign3(request: ComplexRequest, config: string): void {
222
516
  request.configs.value[0] = config;
223
- var i0 = 0;
224
- request.configs.value[i0] = config;
225
517
  }
226
518
 
227
519
  static function mapAccess(request: ComplexRequest): string {
@@ -229,11 +521,8 @@ static function mapAccess(request: ComplexRequest): string {
229
521
  return configInfo;
230
522
  }
231
523
 
232
- static function mapAccess2(request: Source.Request, key: string): string {
524
+ static function mapAccess2(request: Source.Request): string {
233
525
  var configInfo = request.configs.extra['name'];
234
- var configValue = request.configs.extra[key];
235
- var i0 = key;
236
- configValue = request.configs.extra[i0];
237
526
  return configInfo;
238
527
  }
239
528
 
@@ -246,12 +535,35 @@ static function mapAccess3(): string {
246
535
  return data.configs['value'];
247
536
  }
248
537
 
538
+ static function mapAccess4(request: ComplexRequest): string {
539
+ var key : string = 'name';
540
+ var model = request.modelMap[key];
541
+ var configInfo = request.configs.extra[key];
542
+ return configInfo;
543
+ }
544
+
249
545
  static function mapAssign(request: ComplexRequest, name: string): void {
250
546
  request.configs.extra['name'] = name;
251
- var i0 = 'name';
252
- request.configs.extra[i0] = name;
547
+ var key : string = 'name';
548
+ name = key;
549
+ request.configs.extra[key] = name;
550
+ name = request.configs.extra['name'];
551
+ request.map[key] = name;
552
+ request.numMap[key] = 1;
553
+ }
554
+
555
+ static function arrayimport2(request: [ Source.Request ]): string {
556
+ return '';
253
557
  }
254
558
 
559
+ static async function defaultReturn(): void {
560
+ if (true) {
561
+
562
+ } else {
563
+
564
+ }
565
+ }
566
+
255
567
  static function strFmt(): void {
256
568
  var s = 'strtest';
257
569
  var s1 = ` % 1${s}`;
@@ -268,6 +580,42 @@ static function strFmt(): void {
268
580
  var fs3 = `${} ${s}`;
269
581
  }
270
582
 
271
- static function callToMap(m:map[string]any): map[string]any{
272
- return m;
583
+ async function multiTryCatch(a: number): void {
584
+ try {
585
+ if(a > 0) {
586
+ throw new Err1 {
587
+ name = "str",
588
+ code = "str",
589
+ data = {
590
+ key1 = "str",
591
+ }
592
+ };
593
+ } else if(a == 0) {
594
+ throw new Err2 {
595
+ name = "str",
596
+ code = "str",
597
+ accessErrMessage = "str2",
598
+ };
599
+ } else if(a == -10) {
600
+ throw new Source.Err3 {
601
+ name = "str",
602
+ code = "str",
603
+ };
604
+ } else {
605
+ throw new $Error{
606
+ name = "str",
607
+ code = "str",
608
+ }
609
+ }
610
+ } catch(err: Err1) {
611
+ $Logger.log(err.name);
612
+ } catch(err: Err2) {
613
+ $Logger.log(err.name);
614
+ } catch(err: Source.Err3) {
615
+ $Logger.log(err.name);
616
+ } catch(err) {
617
+ $Logger.log(err.name);
618
+ } finally {
619
+ var final = 'ok';
620
+ }
273
621
  }
@@ -10,6 +10,8 @@ static function helloMap(): map[string]string {
10
10
  return {
11
11
  key = 'value',
12
12
  key-1 = 'value-1',
13
+ 'key-2' = 'value-2',
14
+ '""' = 'value-3',
13
15
  ...m,
14
16
  };
15
17
  }
@@ -30,7 +30,7 @@
30
30
  "clientName": "source_client"
31
31
  },
32
32
  "releases": {
33
- "python": "alibabacloud_import:0.0.1",
33
+ "python": "alibabacloud_import:0.0.1rc1",
34
34
  "python2": "alibabacloud_import_py2:0.0.1"
35
35
  }
36
36
  }