sal-tools-analyze 0.0.1
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.
- data/AUTHORS +1 -0
- data/README +20 -0
- data/lib/sal/class.rb +43 -0
- data/lib/sal/code.rb +236 -0
- data/lib/sal/command.rb +35 -0
- data/lib/sal/external.rb +37 -0
- data/lib/sal/externalfunction.rb +46 -0
- data/lib/sal/format.rb +43 -0
- data/lib/sal/function.rb +26 -0
- data/lib/sal/item.rb +214 -0
- data/lib/sal/library.rb +25 -0
- data/lib/sal/version.rb +161 -0
- data/sal-tools-analyze.gemspec +16 -0
- data/test/data/test.21.text.sql.app +458 -0
- data/test/data/test.40.indented.app +219 -0
- data/test/data/test.40.normal.app +0 -0
- data/test/data/test.40.text.app +218 -0
- data/test/data/test.40.text.classes.app +350 -0
- data/test/data/test.40.text.multiline.app +228 -0
- data/test/data/test.41.indented.app +218 -0
- data/test/data/test.41.normal.app +0 -0
- data/test/data/test.41.text.app +218 -0
- data/test/data/test.41.text.externalfunctions.app +352 -0
- data/test/test.rb +16 -0
- data/test/test_class.rb +34 -0
- data/test/test_code.rb +180 -0
- data/test/test_command.rb +16 -0
- data/test/test_external.rb +37 -0
- data/test/test_externalfunction.rb +76 -0
- data/test/test_format.rb +58 -0
- data/test/test_function.rb +22 -0
- data/test/test_item.rb +123 -0
- data/test/test_library.rb +38 -0
- data/test/test_version.rb +80 -0
- metadata +128 -0
@@ -0,0 +1,352 @@
|
|
1
|
+
.head 0 + Application Description: Gupta SQLWindows Standard Application Template
|
2
|
+
|
3
|
+
v2.0
|
4
|
+
v2.1 - external function mit kommentar
|
5
|
+
.head 1 - Outline Version - 4.0.35
|
6
|
+
.head 1 + Design-time Settings
|
7
|
+
.data VIEWINFO
|
8
|
+
0000: 6F00000001000000 FFFF01000D004347 5458566965775374 6174650400010000
|
9
|
+
0020: 0000000000A50000 002C000000020000 0003000000FFFFFF FFFFFFFFFFFCFFFF
|
10
|
+
0040: FFE9FFFFFFFFFFFF FF000000007C0200 004D010000010000 0001000000010000
|
11
|
+
0060: 000F4170706C6963 6174696F6E497465 6D00000000
|
12
|
+
.enddata
|
13
|
+
.head 2 - Outline Window State: Normal
|
14
|
+
.head 2 + Outline Window Location and Size
|
15
|
+
.data VIEWINFO
|
16
|
+
0000: 6600040003002D00 0000000000000000 0000B71E5D0E0500 1D00FFFF4D61696E
|
17
|
+
0020: 0000000000000000 0000000000000000 0000003B00010000 00000000000000E9
|
18
|
+
0040: 1E800A00008600FF FF496E7465726E61 6C2046756E637469 6F6E730000000000
|
19
|
+
0060: 0000000000000000 0000000000003200 0100000000000000 0000E91E800A0000
|
20
|
+
0080: DF00FFFF56617269 61626C6573000000 0000000000000000 0000000000000000
|
21
|
+
00A0: 3000010000000000 00000000F51E100D 0000F400FFFF436C 6173736573000000
|
22
|
+
00C0: 0000000000000000 0000000000000000
|
23
|
+
.enddata
|
24
|
+
.data VIEWSIZE
|
25
|
+
0000: D000
|
26
|
+
.enddata
|
27
|
+
.head 3 - Left: -0.013"
|
28
|
+
.head 3 - Top: 0.0"
|
29
|
+
.head 3 - Width: 8.013"
|
30
|
+
.head 3 - Height: 4.969"
|
31
|
+
.head 2 + Options Box Location
|
32
|
+
.data VIEWINFO
|
33
|
+
0000: D4180909B80B1A00
|
34
|
+
.enddata
|
35
|
+
.data VIEWSIZE
|
36
|
+
0000: 0800
|
37
|
+
.enddata
|
38
|
+
.head 3 - Visible? Yes
|
39
|
+
.head 3 - Left: 4.15"
|
40
|
+
.head 3 - Top: 1.885"
|
41
|
+
.head 3 - Width: 3.8"
|
42
|
+
.head 3 - Height: 2.073"
|
43
|
+
.head 2 + Class Editor Location
|
44
|
+
.head 3 - Visible? No
|
45
|
+
.head 3 - Left: 0.575"
|
46
|
+
.head 3 - Top: 0.094"
|
47
|
+
.head 3 - Width: 5.063"
|
48
|
+
.head 3 - Height: 2.719"
|
49
|
+
.head 2 + Tool Palette Location
|
50
|
+
.head 3 - Visible? No
|
51
|
+
.head 3 - Left: 6.388"
|
52
|
+
.head 3 - Top: 0.729"
|
53
|
+
.head 2 - Fully Qualified External References? Yes
|
54
|
+
.head 2 - Reject Multiple Window Instances? No
|
55
|
+
.head 2 - Enable Runtime Checks Of External References? Yes
|
56
|
+
.head 2 - Use Release 4.0 Scope Rules? No
|
57
|
+
.head 2 - Edit Fields Read Only On Disable? No
|
58
|
+
.head 1 - Libraries
|
59
|
+
.head 1 + Global Declarations
|
60
|
+
.head 2 + Window Defaults
|
61
|
+
.head 3 + Tool Bar
|
62
|
+
.head 4 - Display Style? Etched
|
63
|
+
.head 4 - Font Name: MS Sans Serif
|
64
|
+
.head 4 - Font Size: 8
|
65
|
+
.head 4 - Font Enhancement: System Default
|
66
|
+
.head 4 - Text Color: System Default
|
67
|
+
.head 4 - Background Color: System Default
|
68
|
+
.head 3 + Form Window
|
69
|
+
.head 4 - Display Style? Etched
|
70
|
+
.head 4 - Font Name: MS Sans Serif
|
71
|
+
.head 4 - Font Size: 8
|
72
|
+
.head 4 - Font Enhancement: System Default
|
73
|
+
.head 4 - Text Color: System Default
|
74
|
+
.head 4 - Background Color: System Default
|
75
|
+
.head 3 + Dialog Box
|
76
|
+
.head 4 - Display Style? Etched
|
77
|
+
.head 4 - Font Name: MS Sans Serif
|
78
|
+
.head 4 - Font Size: 8
|
79
|
+
.head 4 - Font Enhancement: System Default
|
80
|
+
.head 4 - Text Color: System Default
|
81
|
+
.head 4 - Background Color: System Default
|
82
|
+
.head 3 + Top Level Table Window
|
83
|
+
.head 4 - Font Name: MS Sans Serif
|
84
|
+
.head 4 - Font Size: 8
|
85
|
+
.head 4 - Font Enhancement: System Default
|
86
|
+
.head 4 - Text Color: System Default
|
87
|
+
.head 4 - Background Color: System Default
|
88
|
+
.head 3 + Data Field
|
89
|
+
.head 4 - Font Name: Use Parent
|
90
|
+
.head 4 - Font Size: Use Parent
|
91
|
+
.head 4 - Font Enhancement: Use Parent
|
92
|
+
.head 4 - Text Color: Use Parent
|
93
|
+
.head 4 - Background Color: Use Parent
|
94
|
+
.head 3 + Multiline Field
|
95
|
+
.head 4 - Font Name: Use Parent
|
96
|
+
.head 4 - Font Size: Use Parent
|
97
|
+
.head 4 - Font Enhancement: Use Parent
|
98
|
+
.head 4 - Text Color: Use Parent
|
99
|
+
.head 4 - Background Color: Use Parent
|
100
|
+
.head 3 + Spin Field
|
101
|
+
.head 4 - Font Name: Use Parent
|
102
|
+
.head 4 - Font Size: Use Parent
|
103
|
+
.head 4 - Font Enhancement: Use Parent
|
104
|
+
.head 4 - Text Color: Use Parent
|
105
|
+
.head 4 - Background Color: Use Parent
|
106
|
+
.head 3 + Background Text
|
107
|
+
.head 4 - Font Name: Use Parent
|
108
|
+
.head 4 - Font Size: Use Parent
|
109
|
+
.head 4 - Font Enhancement: Use Parent
|
110
|
+
.head 4 - Text Color: Use Parent
|
111
|
+
.head 4 - Background Color: Use Parent
|
112
|
+
.head 3 + Pushbutton
|
113
|
+
.head 4 - Font Name: Use Parent
|
114
|
+
.head 4 - Font Size: Use Parent
|
115
|
+
.head 4 - Font Enhancement: Use Parent
|
116
|
+
.head 3 + Radio Button
|
117
|
+
.head 4 - Font Name: Use Parent
|
118
|
+
.head 4 - Font Size: Use Parent
|
119
|
+
.head 4 - Font Enhancement: Use Parent
|
120
|
+
.head 4 - Text Color: Use Parent
|
121
|
+
.head 4 - Background Color: Use Parent
|
122
|
+
.head 3 + Check Box
|
123
|
+
.head 4 - Font Name: Use Parent
|
124
|
+
.head 4 - Font Size: Use Parent
|
125
|
+
.head 4 - Font Enhancement: Use Parent
|
126
|
+
.head 4 - Text Color: Use Parent
|
127
|
+
.head 4 - Background Color: Use Parent
|
128
|
+
.head 3 + Option Button
|
129
|
+
.head 4 - Font Name: Use Parent
|
130
|
+
.head 4 - Font Size: Use Parent
|
131
|
+
.head 4 - Font Enhancement: Use Parent
|
132
|
+
.head 3 + Group Box
|
133
|
+
.head 4 - Font Name: Use Parent
|
134
|
+
.head 4 - Font Size: Use Parent
|
135
|
+
.head 4 - Font Enhancement: Use Parent
|
136
|
+
.head 4 - Text Color: Use Parent
|
137
|
+
.head 4 - Background Color: Use Parent
|
138
|
+
.head 3 + Child Table Window
|
139
|
+
.head 4 - Font Name: Use Parent
|
140
|
+
.head 4 - Font Size: Use Parent
|
141
|
+
.head 4 - Font Enhancement: Use Parent
|
142
|
+
.head 4 - Text Color: Use Parent
|
143
|
+
.head 4 - Background Color: Use Parent
|
144
|
+
.head 3 + List Box
|
145
|
+
.head 4 - Font Name: Use Parent
|
146
|
+
.head 4 - Font Size: Use Parent
|
147
|
+
.head 4 - Font Enhancement: Use Parent
|
148
|
+
.head 4 - Text Color: Use Parent
|
149
|
+
.head 4 - Background Color: Use Parent
|
150
|
+
.head 3 + Combo Box
|
151
|
+
.head 4 - Font Name: Use Parent
|
152
|
+
.head 4 - Font Size: Use Parent
|
153
|
+
.head 4 - Font Enhancement: Use Parent
|
154
|
+
.head 4 - Text Color: Use Parent
|
155
|
+
.head 4 - Background Color: Use Parent
|
156
|
+
.head 3 + Line
|
157
|
+
.head 4 - Line Color: Use Parent
|
158
|
+
.head 3 + Frame
|
159
|
+
.head 4 - Border Color: Use Parent
|
160
|
+
.head 4 - Background Color: 3D Face Color
|
161
|
+
.head 3 + Picture
|
162
|
+
.head 4 - Border Color: Use Parent
|
163
|
+
.head 4 - Background Color: Use Parent
|
164
|
+
.head 2 + Formats
|
165
|
+
.head 3 - Number: 0'%'
|
166
|
+
.head 3 - Number: #0
|
167
|
+
.head 3 - Number: ###000
|
168
|
+
.head 3 - Number: ###000;'($'###000')'
|
169
|
+
.head 3 - Date/Time: hh:mm:ss AMPM
|
170
|
+
.head 3 - Date/Time: M/d/yy
|
171
|
+
.head 3 - Date/Time: MM-dd-yy
|
172
|
+
.head 3 - Date/Time: dd-MMM-yyyy
|
173
|
+
.head 3 - Date/Time: MMM d, yyyy
|
174
|
+
.head 3 - Date/Time: MMM d, yyyy hh:mm AMPM
|
175
|
+
.head 3 - Date/Time: MMMM d, yyyy hh:mm AMPM
|
176
|
+
.head 2 + External Functions
|
177
|
+
.head 3 + Library name: vti41.dll
|
178
|
+
.head 4 - ThreadSafe: No
|
179
|
+
.head 4 - !
|
180
|
+
.head 4 - ! ***** Visual Toolchest - VTARRAY.APL
|
181
|
+
.head 4 - !
|
182
|
+
.head 4 - ! ***** Array functions
|
183
|
+
.head 4 + Function: VisArrayAppend
|
184
|
+
.head 5 - Description: nNumItems VisArrayAppend( hArySource[*], hAryTarget[*] )
|
185
|
+
.head 5 - Export Ordinal: 165
|
186
|
+
.head 5 + Returns
|
187
|
+
.head 6 - Number: LONG
|
188
|
+
.head 5 + Parameters
|
189
|
+
.head 6 - String: HARRAY
|
190
|
+
.head 6 - String: HARRAY
|
191
|
+
.head 6 - Number: INT
|
192
|
+
.head 4 + Function: VisArrayCopy
|
193
|
+
.head 5 - Description: nNumItems VisArrayCopy( hArySource[*], hAryTarget[*] )
|
194
|
+
.head 5 - Export Ordinal: 166
|
195
|
+
.head 5 + Returns
|
196
|
+
.head 6 - Number: LONG
|
197
|
+
.head 5 + Parameters
|
198
|
+
.head 6 - String: HARRAY
|
199
|
+
.head 6 - String: HARRAY
|
200
|
+
.head 6 - Number: INT
|
201
|
+
.head 4 + Function: VisArrayDeleteItem
|
202
|
+
.head 5 - Description: nNumItems VisArrayDeleteItem( harray, nIndex, nDataType )
|
203
|
+
.head 5 - Export Ordinal: 167
|
204
|
+
.head 5 + Returns
|
205
|
+
.head 6 - Number: LONG
|
206
|
+
.head 5 + Parameters
|
207
|
+
.head 6 - String: HARRAY
|
208
|
+
.head 6 - Number: LONG
|
209
|
+
.head 6 - Number: INT
|
210
|
+
.head 4 + Function: VisArrayFillDateTime
|
211
|
+
.head 5 - Description: bOk VisArrayFillDateTime( dtArray[*], dtValue, nCount )
|
212
|
+
.head 5 - Export Ordinal: 168
|
213
|
+
.head 5 + Returns
|
214
|
+
.head 6 - Boolean: BOOL
|
215
|
+
.head 5 + Parameters
|
216
|
+
.head 6 - Date/Time: HARRAY
|
217
|
+
.head 6 - Date/Time: DATETIME
|
218
|
+
.head 6 - Number: LONG
|
219
|
+
.head 4 + Function: VisArrayFillNumber
|
220
|
+
.head 5 - Description: bOk VisArrayFillNumber( nArray[*], nValue, nCount )
|
221
|
+
.head 5 - Export Ordinal: 169
|
222
|
+
.head 5 + Returns
|
223
|
+
.head 6 - Boolean: BOOL
|
224
|
+
.head 5 + Parameters
|
225
|
+
.head 6 - Number: HARRAY
|
226
|
+
.head 6 - Number: NUMBER
|
227
|
+
.head 6 - Number: LONG
|
228
|
+
.head 4 + Function: VisArrayFillString
|
229
|
+
.head 5 - Description: bOk VisArrayFillString( sArray[*], sValue, nCount )
|
230
|
+
.head 5 - Export Ordinal: 170
|
231
|
+
.head 5 + Returns
|
232
|
+
.head 6 - Boolean: BOOL
|
233
|
+
.head 5 + Parameters
|
234
|
+
.head 6 - String: HARRAY
|
235
|
+
.head 6 - String: LPSTR
|
236
|
+
.head 6 - Number: LONG
|
237
|
+
.head 4 + Function: VisArrayFindDateTime
|
238
|
+
.head 5 - Description: nIndex VisArrayFindDateTime( dtDateTime[*], dtSearchFor )
|
239
|
+
.head 5 - Export Ordinal: 171
|
240
|
+
.head 5 + Returns
|
241
|
+
.head 6 - Number: LONG
|
242
|
+
.head 5 + Parameters
|
243
|
+
.head 6 - Date/Time: HARRAY
|
244
|
+
.head 6 - Date/Time: DATETIME
|
245
|
+
.head 4 + Function: VisArrayFindNumber
|
246
|
+
.head 5 - Description: nIndex VisArrayFindNumber( nNumbers[*], nSearchFor )
|
247
|
+
.head 5 - Export Ordinal: 172
|
248
|
+
.head 5 + Returns
|
249
|
+
.head 6 - Number: LONG
|
250
|
+
.head 5 + Parameters
|
251
|
+
.head 6 - Number: HARRAY
|
252
|
+
.head 6 - Number: NUMBER
|
253
|
+
.head 4 + Function: VisArrayFindString
|
254
|
+
.head 5 - Description: nIndex VisArrayFindString( sStrings[*], sSearchFor )
|
255
|
+
.head 5 - Export Ordinal: 149
|
256
|
+
.head 5 + Returns
|
257
|
+
.head 6 - Number: LONG
|
258
|
+
.head 5 + Parameters
|
259
|
+
.head 6 - String: HARRAY
|
260
|
+
.head 6 - String: LPSTR
|
261
|
+
.head 4 + Function: VisArrayInsertItem
|
262
|
+
.head 5 - Description: nNumItems VisArrayInsertItem( harray, nIndex, nDataType )
|
263
|
+
.head 5 - Export Ordinal: 173
|
264
|
+
.head 5 + Returns
|
265
|
+
.head 6 - Number: LONG
|
266
|
+
.head 5 + Parameters
|
267
|
+
.head 6 - String: HARRAY
|
268
|
+
.head 6 - Number: LONG
|
269
|
+
.head 6 - Number: INT
|
270
|
+
.head 4 + Function: VisArraySort ! comment test
|
271
|
+
.head 5 - Description: nNumItems VisArraySort( harray, nSortOrder, nDataType )
|
272
|
+
.head 5 - Export Ordinal: 150
|
273
|
+
.head 5 + Returns
|
274
|
+
.head 6 - Number: LONG
|
275
|
+
.head 5 + Parameters
|
276
|
+
.head 6 - String: HARRAY
|
277
|
+
.head 6 - Number: INT
|
278
|
+
.head 6 - Number: INT
|
279
|
+
.head 2 + Constants
|
280
|
+
.data CCDATA
|
281
|
+
0000: 3000000000000000 0000000000000000 00000000
|
282
|
+
.enddata
|
283
|
+
.data CCSIZE
|
284
|
+
0000: 1400
|
285
|
+
.enddata
|
286
|
+
.head 3 - System
|
287
|
+
.head 3 - User
|
288
|
+
.head 3 - Enumerations
|
289
|
+
.head 2 - Resources
|
290
|
+
.head 2 - Variables
|
291
|
+
.head 2 + Internal Functions
|
292
|
+
.head 3 + Function: A
|
293
|
+
.head 4 - Description: SalMessageBox
|
294
|
+
.head 4 - Returns
|
295
|
+
.head 4 - Parameters
|
296
|
+
.head 4 - Static Variables
|
297
|
+
.head 4 - Local variables
|
298
|
+
.head 4 + Actions
|
299
|
+
.head 5 + If 1
|
300
|
+
.head 6 - ! test
|
301
|
+
.head 5 - Call SalMessageBox( "", "", MB_Ok )
|
302
|
+
.head 3 + Function: B
|
303
|
+
.head 4 - Description:
|
304
|
+
.head 4 - Returns
|
305
|
+
.head 4 - Parameters
|
306
|
+
.head 4 - Static Variables
|
307
|
+
.head 4 - Local variables
|
308
|
+
.head 4 + Actions
|
309
|
+
.head 5 + ! If 1
|
310
|
+
.head 6 - Call SalMessageBox( "", "", MB_Ok )
|
311
|
+
.head 3 + Function: C
|
312
|
+
.head 4 - Description: Call VisArrayAppend( a, b, 0 )
|
313
|
+
.head 4 - Returns
|
314
|
+
.head 4 - Parameters
|
315
|
+
.head 4 - Static Variables
|
316
|
+
.head 4 + Local variables
|
317
|
+
.head 5 - String: a[*]
|
318
|
+
.head 5 - String: b[*]
|
319
|
+
.head 4 + Actions
|
320
|
+
.head 5 - Call VisArrayAppend( a, b, 0 )
|
321
|
+
.head 5 + ! Call VisArrayAppend( a, b, 0 )
|
322
|
+
.head 6 - Call VisArrayAppend( a, b, 0 )
|
323
|
+
.head 2 - Named Menus
|
324
|
+
.head 2 - Class Definitions
|
325
|
+
.head 2 + Default Classes
|
326
|
+
.head 3 - MDI Window: cBaseMDI
|
327
|
+
.head 3 - Form Window:
|
328
|
+
.head 3 - Dialog Box:
|
329
|
+
.head 3 - Table Window:
|
330
|
+
.head 3 - Quest Window:
|
331
|
+
.head 3 - Data Field:
|
332
|
+
.head 3 - Spin Field:
|
333
|
+
.head 3 - Multiline Field:
|
334
|
+
.head 3 - Pushbutton:
|
335
|
+
.head 3 - Radio Button:
|
336
|
+
.head 3 - Option Button:
|
337
|
+
.head 3 - Check Box:
|
338
|
+
.head 3 - Child Table:
|
339
|
+
.head 3 - Quest Child Window: cQuickDatabase
|
340
|
+
.head 3 - List Box:
|
341
|
+
.head 3 - Combo Box:
|
342
|
+
.head 3 - Picture:
|
343
|
+
.head 3 - Vertical Scroll Bar:
|
344
|
+
.head 3 - Horizontal Scroll Bar:
|
345
|
+
.head 3 - Column:
|
346
|
+
.head 3 - Background Text:
|
347
|
+
.head 3 - Group Box:
|
348
|
+
.head 3 - Line:
|
349
|
+
.head 3 - Frame:
|
350
|
+
.head 3 - Custom Control:
|
351
|
+
.head 3 - ActiveX:
|
352
|
+
.head 2 - Application Actions
|
data/test/test.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/opt/local/bin/ruby
|
2
|
+
|
3
|
+
require 'minitest/unit'
|
4
|
+
|
5
|
+
require_relative "test_class.rb"
|
6
|
+
require_relative "test_code.rb"
|
7
|
+
require_relative "test_command.rb"
|
8
|
+
require_relative "test_external.rb"
|
9
|
+
require_relative "test_externalfunction.rb"
|
10
|
+
require_relative "test_format.rb"
|
11
|
+
require_relative "test_function.rb"
|
12
|
+
require_relative "test_item.rb"
|
13
|
+
require_relative "test_library.rb"
|
14
|
+
require_relative "test_version.rb"
|
15
|
+
|
16
|
+
MiniTest::Unit.autorun
|
data/test/test_class.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
#!/opt/local/bin/ruby
|
2
|
+
|
3
|
+
require 'minitest/unit'
|
4
|
+
require_relative '../lib/sal/class'
|
5
|
+
require_relative '../lib/sal/code'
|
6
|
+
|
7
|
+
class TestClass < MiniTest::Unit::TestCase
|
8
|
+
|
9
|
+
def test_class
|
10
|
+
name = "Test"
|
11
|
+
type = "Functional Class"
|
12
|
+
code = "#{type}: #{name}"
|
13
|
+
line = ".head 3 + #{code}\r\n"
|
14
|
+
item = Sal::Item.new(line)
|
15
|
+
|
16
|
+
clas = Sal::Class.new(item)
|
17
|
+
|
18
|
+
assert_equal(item, clas.item)
|
19
|
+
assert_equal(name, clas.name)
|
20
|
+
assert_equal(type, clas.type)
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_libraries
|
24
|
+
code = Sal::Code.new("data/test.40.text.classes.app")
|
25
|
+
assert_equal(2, code.classes.length)
|
26
|
+
assert_equal("BaseClass", code.classes[0].name)
|
27
|
+
assert_equal("ClassName", code.classes[1].name)
|
28
|
+
assert_equal(1, code.classes[1].functions.length)
|
29
|
+
# assert_equal("functionName", code.classes[1].functions[0].name)
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
MiniTest::Unit.autorun
|
data/test/test_code.rb
ADDED
@@ -0,0 +1,180 @@
|
|
1
|
+
#!/opt/local/bin/ruby
|
2
|
+
|
3
|
+
require 'minitest/unit'
|
4
|
+
require 'ostruct'
|
5
|
+
|
6
|
+
require_relative '../lib/sal/code'
|
7
|
+
require_relative '../lib/sal/format'
|
8
|
+
|
9
|
+
class TestCode < MiniTest::Unit::TestCase
|
10
|
+
|
11
|
+
def setup
|
12
|
+
@files = []
|
13
|
+
@files << "data/test.40.indented.app"
|
14
|
+
@files << "data/test.40.text.app"
|
15
|
+
@files << "data/test.40.normal.app"
|
16
|
+
@files << "data/test.41.indented.app"
|
17
|
+
@files << "data/test.41.text.app"
|
18
|
+
@files << "data/test.41.normal.app"
|
19
|
+
|
20
|
+
@lines = []
|
21
|
+
@lines << ".head 0 + Application Description: Gupta SQLWindows Standard Application Template\r\n"
|
22
|
+
@lines << ".head 1 - Outline Version - 4.0.34\r\n"
|
23
|
+
|
24
|
+
@include1 = []
|
25
|
+
@include1 << ".head 0 + Application Description: File Include Test\r\n"
|
26
|
+
@include1 << ".head 1 - Outline Version - 4.0.34\r\n"
|
27
|
+
@include1 << ".head 1 + Libraries\r\n"
|
28
|
+
@include1 << ".head 2 - File Include: qckttip.apl\r\n"
|
29
|
+
@include1 << ".head 1 + Constants\r\n"
|
30
|
+
|
31
|
+
@include2 = []
|
32
|
+
@include2 << ".head 0 + Application Description: File Include Test\r\n"
|
33
|
+
@include2 << ".head 1 - Outline Version - 4.0.34\r\n"
|
34
|
+
@include2 << ".head 1 - Libraries\r\n"
|
35
|
+
@include2 << ".head 1 + Constants\r\n"
|
36
|
+
end
|
37
|
+
|
38
|
+
def code_class
|
39
|
+
# Neue Klasse um die Initialisierung zu umgehen
|
40
|
+
code_class = Class.new(Sal::Code) do
|
41
|
+
def initialize
|
42
|
+
end
|
43
|
+
end
|
44
|
+
code_class
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_filename
|
48
|
+
filename = @files[0]
|
49
|
+
assert_equal(filename, Sal::Code.new(filename).filename)
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_file_format
|
53
|
+
@files.grep(/\.indented\./).each do | file |
|
54
|
+
assert_equal( Sal::Format::INDENTED, Sal::Code.new(file).format )
|
55
|
+
end
|
56
|
+
|
57
|
+
@files.grep(/\.text\./).each do | file |
|
58
|
+
assert_equal( Sal::Format::TEXT, Sal::Code.new(file).format )
|
59
|
+
end
|
60
|
+
|
61
|
+
@files.grep(/\.normal\./).each do | file |
|
62
|
+
assert_equal( Sal::Format::NORMAL, Sal::Code.new(file).format )
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_version
|
67
|
+
@files.each do | file |
|
68
|
+
file =~ /\.(\d)(\d)\./
|
69
|
+
tdversion = "#{$1}.#{$2}"
|
70
|
+
assert_equal( tdversion, Sal::Code.new(file).version.td )
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_libraries
|
75
|
+
# assert_equal(2, Sal::Code.new("data/test.40.indented.app").libraries.length)
|
76
|
+
assert_equal(2, Sal::Code.new("data/test.40.text.app").libraries.length)
|
77
|
+
# assert_equal(0, Sal::Code.new("data/test.41.indented.app").libraries.length)
|
78
|
+
assert_equal(0, Sal::Code.new("data/test.41.text.app").libraries.length)
|
79
|
+
end
|
80
|
+
|
81
|
+
def test_private_get_item
|
82
|
+
|
83
|
+
@lines.each do | line |
|
84
|
+
# Initialisierungen
|
85
|
+
vars = OpenStruct.new
|
86
|
+
vars.counter = 0
|
87
|
+
vars.levels = Hash.new
|
88
|
+
vars.format = Sal::Format::TEXT
|
89
|
+
vars.lines = @lines
|
90
|
+
vars.line = line
|
91
|
+
|
92
|
+
# Level extrahieren
|
93
|
+
line =~ /^.head.+?(\d+).+/
|
94
|
+
level = $1.to_i
|
95
|
+
# Quellcode holen
|
96
|
+
# line =~ /^.head.+?\d+.+?(\w.*?)(\r\n)+.*$/m
|
97
|
+
line =~/(^\.head )(\d+?)( )([+-])( )(.*?)(\r\n.*)/m
|
98
|
+
code_part= $6
|
99
|
+
|
100
|
+
# Das private get_item aufrufen
|
101
|
+
code = code_class.new
|
102
|
+
item = code.send :get_item, vars
|
103
|
+
|
104
|
+
# Tests
|
105
|
+
assert_equal(level, item.level, line)
|
106
|
+
assert_equal(line, item.line, line)
|
107
|
+
assert_equal(vars.format, item.format)
|
108
|
+
assert_equal(false, item.commented?)
|
109
|
+
assert_equal(nil, item.parent)
|
110
|
+
assert_equal(0, item.childs.count)
|
111
|
+
assert_equal(1, item.code_line_nr)
|
112
|
+
assert_equal(true, item.analyzed?)
|
113
|
+
assert_equal(code_part, item.code)
|
114
|
+
end
|
115
|
+
|
116
|
+
end
|
117
|
+
|
118
|
+
def test_add_library_to_existing_libraries
|
119
|
+
code = code_class.new
|
120
|
+
code.code = @include1.join()
|
121
|
+
code.send :get_format_and_version_from_code
|
122
|
+
itemcount = code.items.count
|
123
|
+
libcount = code.libraries.count
|
124
|
+
libname = "test.apl"
|
125
|
+
|
126
|
+
code.add_library(libname)
|
127
|
+
|
128
|
+
assert_equal(itemcount + 1, code.items.count)
|
129
|
+
assert_equal(libcount + 1, code.libraries.count)
|
130
|
+
assert_equal(libname, code.libraries[0].name)
|
131
|
+
end
|
132
|
+
|
133
|
+
def test_add_library_as_first_library
|
134
|
+
code = code_class.new
|
135
|
+
code.code = @include2.join()
|
136
|
+
code.send :get_format_and_version_from_code
|
137
|
+
itemcount = code.items.count
|
138
|
+
libcount = code.libraries.count
|
139
|
+
libname = "test.apl"
|
140
|
+
|
141
|
+
code.add_library(libname)
|
142
|
+
|
143
|
+
assert_equal(itemcount + 1, code.items.count)
|
144
|
+
assert_equal(libcount + 1, code.libraries.count)
|
145
|
+
assert_equal(libname, code.libraries[0].name)
|
146
|
+
end
|
147
|
+
|
148
|
+
def test_private_code_split_text
|
149
|
+
vars = OpenStruct.new
|
150
|
+
vars.lines = []
|
151
|
+
code = code_class.new
|
152
|
+
code.code = @lines.join("\r\n")
|
153
|
+
code.send :code_split_text, vars
|
154
|
+
|
155
|
+
assert_equal(2,vars.lines.length)
|
156
|
+
end
|
157
|
+
|
158
|
+
def test_code_binary_data
|
159
|
+
source = <<END_OF_STRING
|
160
|
+
.head 2 - External Functions
|
161
|
+
.head 2 + Constants
|
162
|
+
.data CCDATA
|
163
|
+
0000: 3000000000000000 0000000000000000 00000000
|
164
|
+
.enddata
|
165
|
+
.data CCSIZE
|
166
|
+
0000: 1400
|
167
|
+
.enddata
|
168
|
+
.head 3 - System
|
169
|
+
END_OF_STRING
|
170
|
+
code = code_class.new
|
171
|
+
code.code = source
|
172
|
+
code.format = Sal::Format::TEXT
|
173
|
+
items = code.send :get_items_from_code
|
174
|
+
assert_equal(true, items[1].include?(".data CCDATA"))
|
175
|
+
assert_equal(true, items[1].include?(".data CCSIZE"))
|
176
|
+
end
|
177
|
+
|
178
|
+
end
|
179
|
+
|
180
|
+
MiniTest::Unit.autorun
|