rooibos-roku 5.15.1 → 5.15.2
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/dist/lib/rooibos/CodeCoverageProcessor.spec.js +507 -0
- package/dist/lib/rooibos/CodeCoverageProcessor.spec.js.map +1 -0
- package/dist/lib/rooibos/MockUtil.spec.js +484 -0
- package/dist/lib/rooibos/MockUtil.spec.js.map +1 -0
- package/dist/lib/rooibos/TestGroup.js +2 -1
- package/dist/lib/rooibos/TestGroup.js.map +1 -1
- package/dist/lib/rooibos/TestSuiteBuilder.spec.js +1126 -0
- package/dist/lib/rooibos/TestSuiteBuilder.spec.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,507 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/* eslint-disable @typescript-eslint/no-confusing-void-expression */
|
|
4
|
+
const brighterscript_1 = require("brighterscript");
|
|
5
|
+
const chai_1 = require("chai");
|
|
6
|
+
const PluginInterface_1 = require("brighterscript/dist/PluginInterface");
|
|
7
|
+
const fsExtra = require("fs-extra");
|
|
8
|
+
const plugin_1 = require("../../plugin");
|
|
9
|
+
const undent_1 = require("undent");
|
|
10
|
+
let tmpPath = (0, brighterscript_1.standardizePath) `${process.cwd()}/tmp`;
|
|
11
|
+
let _rootDir = (0, brighterscript_1.standardizePath) `${tmpPath}/rootDir`;
|
|
12
|
+
let _stagingFolderPath = (0, brighterscript_1.standardizePath) `${tmpPath}/staging`;
|
|
13
|
+
describe('RooibosPlugin', () => {
|
|
14
|
+
let program;
|
|
15
|
+
let builder;
|
|
16
|
+
let plugin;
|
|
17
|
+
let options;
|
|
18
|
+
function getContents(filename) {
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
20
|
+
let contents = fsExtra.readFileSync((0, brighterscript_1.standardizePath) `${_stagingFolderPath}/${filename}`).toString();
|
|
21
|
+
return (0, undent_1.default)(contents);
|
|
22
|
+
}
|
|
23
|
+
describe('CodeCoverageProcessor', () => {
|
|
24
|
+
beforeEach(() => {
|
|
25
|
+
plugin = new plugin_1.RooibosPlugin();
|
|
26
|
+
options = {
|
|
27
|
+
rootDir: _rootDir,
|
|
28
|
+
stagingFolderPath: _stagingFolderPath,
|
|
29
|
+
rooibos: {
|
|
30
|
+
isRecordingCodeCoverage: true,
|
|
31
|
+
coverageExcludedFiles: [
|
|
32
|
+
'**/*.coverageExcluded.bs'
|
|
33
|
+
]
|
|
34
|
+
},
|
|
35
|
+
allowBrighterScriptInBrightScript: true
|
|
36
|
+
};
|
|
37
|
+
fsExtra.ensureDirSync(_stagingFolderPath);
|
|
38
|
+
fsExtra.ensureDirSync(_rootDir);
|
|
39
|
+
fsExtra.ensureDirSync(tmpPath);
|
|
40
|
+
builder = new brighterscript_1.ProgramBuilder();
|
|
41
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
42
|
+
builder.options = brighterscript_1.util.normalizeAndResolveConfig(options);
|
|
43
|
+
builder.program = new brighterscript_1.Program(builder.options);
|
|
44
|
+
program = builder.program;
|
|
45
|
+
program.logger = builder.logger;
|
|
46
|
+
builder.plugins = new PluginInterface_1.default([plugin], { logger: builder.logger });
|
|
47
|
+
program.plugins = new PluginInterface_1.default([plugin], { logger: builder.logger });
|
|
48
|
+
program.createSourceScope(); //ensure source scope is created
|
|
49
|
+
plugin.beforeProgramCreate(builder);
|
|
50
|
+
});
|
|
51
|
+
afterEach(() => {
|
|
52
|
+
plugin.afterProgramCreate(program);
|
|
53
|
+
fsExtra.ensureDirSync(tmpPath);
|
|
54
|
+
fsExtra.emptyDirSync(tmpPath);
|
|
55
|
+
builder.dispose();
|
|
56
|
+
program.dispose();
|
|
57
|
+
});
|
|
58
|
+
describe('basic brs tests', () => {
|
|
59
|
+
// This test fails unless `allowBrighterScriptInBrightScript` is set to true when setting up the program
|
|
60
|
+
// in `beforeEach`. This is because the compiler normally skips processing .brs files and copies them as-is.
|
|
61
|
+
it('adds code coverage to a brs file', async () => {
|
|
62
|
+
program.setFile('source/code.brs', `
|
|
63
|
+
function new(a1, a2)
|
|
64
|
+
c = 0
|
|
65
|
+
text = ""
|
|
66
|
+
for i = 0 to 10
|
|
67
|
+
text = text + "hello"
|
|
68
|
+
c++
|
|
69
|
+
c += 1
|
|
70
|
+
if c = 2
|
|
71
|
+
? "is true"
|
|
72
|
+
end if
|
|
73
|
+
|
|
74
|
+
if c = 3
|
|
75
|
+
? "free"
|
|
76
|
+
else
|
|
77
|
+
? "not free"
|
|
78
|
+
end if
|
|
79
|
+
end for
|
|
80
|
+
end function
|
|
81
|
+
`);
|
|
82
|
+
program.validate();
|
|
83
|
+
(0, chai_1.expect)(program.getDiagnostics()).to.be.empty;
|
|
84
|
+
await builder.transpile();
|
|
85
|
+
let a = getContents('source/code.brs');
|
|
86
|
+
let b = (0, undent_1.default)(`
|
|
87
|
+
function new(a1, a2)
|
|
88
|
+
RBS_CC_1_reportLine("2", 1)
|
|
89
|
+
c = 0
|
|
90
|
+
RBS_CC_1_reportLine("3", 1)
|
|
91
|
+
text = ""
|
|
92
|
+
RBS_CC_1_reportLine("4", 1): for i = 0 to 10
|
|
93
|
+
RBS_CC_1_reportLine("5", 1)
|
|
94
|
+
text = text + "hello"
|
|
95
|
+
RBS_CC_1_reportLine("6", 1)
|
|
96
|
+
c++
|
|
97
|
+
RBS_CC_1_reportLine("7", 1)
|
|
98
|
+
c += 1
|
|
99
|
+
if RBS_CC_1_reportLine("8", 2) and (c = 2)
|
|
100
|
+
RBS_CC_1_reportLine("8", 3)
|
|
101
|
+
RBS_CC_1_reportLine("9", 1)
|
|
102
|
+
? "is true"
|
|
103
|
+
end if
|
|
104
|
+
if RBS_CC_1_reportLine("12", 2) and (c = 3)
|
|
105
|
+
RBS_CC_1_reportLine("12", 3)
|
|
106
|
+
RBS_CC_1_reportLine("13", 1)
|
|
107
|
+
? "free"
|
|
108
|
+
else
|
|
109
|
+
RBS_CC_1_reportLine("14", 3)
|
|
110
|
+
RBS_CC_1_reportLine("15", 1)
|
|
111
|
+
? "not free"
|
|
112
|
+
end if
|
|
113
|
+
end for
|
|
114
|
+
end function
|
|
115
|
+
|
|
116
|
+
function RBS_CC_1_reportLine(lineNumber, reportType = 1)
|
|
117
|
+
_rbs_ccn = m._rbs_ccn
|
|
118
|
+
if _rbs_ccn <> invalid
|
|
119
|
+
_rbs_ccn.entry = {
|
|
120
|
+
"f": "1"
|
|
121
|
+
"l": lineNumber
|
|
122
|
+
"r": reportType
|
|
123
|
+
}
|
|
124
|
+
return true
|
|
125
|
+
end if
|
|
126
|
+
_rbs_ccn = m?.global?._rbs_ccn
|
|
127
|
+
if _rbs_ccn <> invalid
|
|
128
|
+
_rbs_ccn.entry = {
|
|
129
|
+
"f": "1"
|
|
130
|
+
"l": lineNumber
|
|
131
|
+
"r": reportType
|
|
132
|
+
}
|
|
133
|
+
m._rbs_ccn = _rbs_ccn
|
|
134
|
+
return true
|
|
135
|
+
end if
|
|
136
|
+
return true
|
|
137
|
+
end function
|
|
138
|
+
`);
|
|
139
|
+
(0, chai_1.expect)(a).to.equal(b);
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
describe('basic bs tests', () => {
|
|
143
|
+
it('adds code coverage to a bs file', async () => {
|
|
144
|
+
program.setFile('source/code.bs', `
|
|
145
|
+
function new(a1, a2)
|
|
146
|
+
c = 0
|
|
147
|
+
text = ""
|
|
148
|
+
for i = 0 to 10
|
|
149
|
+
text = text + "hello"
|
|
150
|
+
c++
|
|
151
|
+
c += 1
|
|
152
|
+
if c = 2
|
|
153
|
+
? "is true"
|
|
154
|
+
end if
|
|
155
|
+
|
|
156
|
+
if c = 3
|
|
157
|
+
? "free"
|
|
158
|
+
else
|
|
159
|
+
? "not free"
|
|
160
|
+
end if
|
|
161
|
+
end for
|
|
162
|
+
end function
|
|
163
|
+
`);
|
|
164
|
+
program.validate();
|
|
165
|
+
(0, chai_1.expect)(program.getDiagnostics()).to.be.empty;
|
|
166
|
+
await builder.transpile();
|
|
167
|
+
let a = getContents('source/code.brs');
|
|
168
|
+
let b = (0, undent_1.default)(`
|
|
169
|
+
function new(a1, a2)
|
|
170
|
+
RBS_CC_1_reportLine("2", 1)
|
|
171
|
+
c = 0
|
|
172
|
+
RBS_CC_1_reportLine("3", 1)
|
|
173
|
+
text = ""
|
|
174
|
+
RBS_CC_1_reportLine("4", 1): for i = 0 to 10
|
|
175
|
+
RBS_CC_1_reportLine("5", 1)
|
|
176
|
+
text = text + "hello"
|
|
177
|
+
RBS_CC_1_reportLine("6", 1)
|
|
178
|
+
c++
|
|
179
|
+
RBS_CC_1_reportLine("7", 1)
|
|
180
|
+
c += 1
|
|
181
|
+
if RBS_CC_1_reportLine("8", 2) and (c = 2)
|
|
182
|
+
RBS_CC_1_reportLine("8", 3)
|
|
183
|
+
RBS_CC_1_reportLine("9", 1)
|
|
184
|
+
? "is true"
|
|
185
|
+
end if
|
|
186
|
+
if RBS_CC_1_reportLine("12", 2) and (c = 3)
|
|
187
|
+
RBS_CC_1_reportLine("12", 3)
|
|
188
|
+
RBS_CC_1_reportLine("13", 1)
|
|
189
|
+
? "free"
|
|
190
|
+
else
|
|
191
|
+
RBS_CC_1_reportLine("14", 3)
|
|
192
|
+
RBS_CC_1_reportLine("15", 1)
|
|
193
|
+
? "not free"
|
|
194
|
+
end if
|
|
195
|
+
end for
|
|
196
|
+
end function
|
|
197
|
+
|
|
198
|
+
function RBS_CC_1_reportLine(lineNumber, reportType = 1)
|
|
199
|
+
_rbs_ccn = m._rbs_ccn
|
|
200
|
+
if _rbs_ccn <> invalid
|
|
201
|
+
_rbs_ccn.entry = {
|
|
202
|
+
"f": "1"
|
|
203
|
+
"l": lineNumber
|
|
204
|
+
"r": reportType
|
|
205
|
+
}
|
|
206
|
+
return true
|
|
207
|
+
end if
|
|
208
|
+
_rbs_ccn = m?.global?._rbs_ccn
|
|
209
|
+
if _rbs_ccn <> invalid
|
|
210
|
+
_rbs_ccn.entry = {
|
|
211
|
+
"f": "1"
|
|
212
|
+
"l": lineNumber
|
|
213
|
+
"r": reportType
|
|
214
|
+
}
|
|
215
|
+
m._rbs_ccn = _rbs_ccn
|
|
216
|
+
return true
|
|
217
|
+
end if
|
|
218
|
+
return true
|
|
219
|
+
end function
|
|
220
|
+
`);
|
|
221
|
+
(0, chai_1.expect)(a).to.equal(b);
|
|
222
|
+
});
|
|
223
|
+
});
|
|
224
|
+
describe('basic tests', () => {
|
|
225
|
+
it('adds code coverage to a bs file', async () => {
|
|
226
|
+
program.setFile('source/code.bs', `
|
|
227
|
+
class BasicClass
|
|
228
|
+
private field1
|
|
229
|
+
public field2
|
|
230
|
+
|
|
231
|
+
function new(a1, a2)
|
|
232
|
+
c = 0
|
|
233
|
+
text = ""
|
|
234
|
+
for i = 0 to 10
|
|
235
|
+
text = text + "hello"
|
|
236
|
+
c++
|
|
237
|
+
c += 1
|
|
238
|
+
if c = 2
|
|
239
|
+
? "is true"
|
|
240
|
+
end if
|
|
241
|
+
|
|
242
|
+
if c = 3
|
|
243
|
+
? "free"
|
|
244
|
+
else
|
|
245
|
+
? "not free"
|
|
246
|
+
end if
|
|
247
|
+
end for
|
|
248
|
+
|
|
249
|
+
end function
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
end class
|
|
253
|
+
`);
|
|
254
|
+
program.validate();
|
|
255
|
+
(0, chai_1.expect)(program.getDiagnostics()).to.be.empty;
|
|
256
|
+
await builder.transpile();
|
|
257
|
+
let a = getContents('source/code.brs');
|
|
258
|
+
let b = (0, undent_1.default)(`
|
|
259
|
+
function __BasicClass_builder()
|
|
260
|
+
instance = {}
|
|
261
|
+
instance.new = function(a1, a2)
|
|
262
|
+
m.field1 = invalid
|
|
263
|
+
m.field2 = invalid
|
|
264
|
+
RBS_CC_1_reportLine("6", 1)
|
|
265
|
+
c = 0
|
|
266
|
+
RBS_CC_1_reportLine("7", 1)
|
|
267
|
+
text = ""
|
|
268
|
+
RBS_CC_1_reportLine("8", 1): for i = 0 to 10
|
|
269
|
+
RBS_CC_1_reportLine("9", 1)
|
|
270
|
+
text = text + "hello"
|
|
271
|
+
RBS_CC_1_reportLine("10", 1)
|
|
272
|
+
c++
|
|
273
|
+
RBS_CC_1_reportLine("11", 1)
|
|
274
|
+
c += 1
|
|
275
|
+
if RBS_CC_1_reportLine("12", 2) and (c = 2)
|
|
276
|
+
RBS_CC_1_reportLine("12", 3)
|
|
277
|
+
RBS_CC_1_reportLine("13", 1)
|
|
278
|
+
? "is true"
|
|
279
|
+
end if
|
|
280
|
+
if RBS_CC_1_reportLine("16", 2) and (c = 3)
|
|
281
|
+
RBS_CC_1_reportLine("16", 3)
|
|
282
|
+
RBS_CC_1_reportLine("17", 1)
|
|
283
|
+
? "free"
|
|
284
|
+
else
|
|
285
|
+
RBS_CC_1_reportLine("18", 3)
|
|
286
|
+
RBS_CC_1_reportLine("19", 1)
|
|
287
|
+
? "not free"
|
|
288
|
+
end if
|
|
289
|
+
end for
|
|
290
|
+
end function
|
|
291
|
+
return instance
|
|
292
|
+
end function
|
|
293
|
+
function BasicClass(a1, a2)
|
|
294
|
+
instance = __BasicClass_builder()
|
|
295
|
+
instance.new(a1, a2)
|
|
296
|
+
return instance
|
|
297
|
+
end function
|
|
298
|
+
|
|
299
|
+
function RBS_CC_1_reportLine(lineNumber, reportType = 1)
|
|
300
|
+
_rbs_ccn = m._rbs_ccn
|
|
301
|
+
if _rbs_ccn <> invalid
|
|
302
|
+
_rbs_ccn.entry = {
|
|
303
|
+
"f": "1"
|
|
304
|
+
"l": lineNumber
|
|
305
|
+
"r": reportType
|
|
306
|
+
}
|
|
307
|
+
return true
|
|
308
|
+
end if
|
|
309
|
+
_rbs_ccn = m?.global?._rbs_ccn
|
|
310
|
+
if _rbs_ccn <> invalid
|
|
311
|
+
_rbs_ccn.entry = {
|
|
312
|
+
"f": "1"
|
|
313
|
+
"l": lineNumber
|
|
314
|
+
"r": reportType
|
|
315
|
+
}
|
|
316
|
+
m._rbs_ccn = _rbs_ccn
|
|
317
|
+
return true
|
|
318
|
+
end if
|
|
319
|
+
return true
|
|
320
|
+
end function
|
|
321
|
+
`);
|
|
322
|
+
(0, chai_1.expect)(a).to.equal(b);
|
|
323
|
+
});
|
|
324
|
+
it('correctly transpiles some statements', async () => {
|
|
325
|
+
const source = `sub foo()
|
|
326
|
+
x = function(y)
|
|
327
|
+
if (true) then
|
|
328
|
+
return 1
|
|
329
|
+
end if
|
|
330
|
+
return 0
|
|
331
|
+
end function
|
|
332
|
+
end sub`;
|
|
333
|
+
program.setFile('source/code.bs', source);
|
|
334
|
+
program.validate();
|
|
335
|
+
(0, chai_1.expect)(program.getDiagnostics()).to.be.empty;
|
|
336
|
+
await builder.transpile();
|
|
337
|
+
let a = getContents('source/code.brs');
|
|
338
|
+
let b = (0, undent_1.default)(`
|
|
339
|
+
sub foo()
|
|
340
|
+
RBS_CC_1_reportLine("1", 1)
|
|
341
|
+
x = function(y)
|
|
342
|
+
if RBS_CC_1_reportLine("2", 2) and ((true)) then
|
|
343
|
+
RBS_CC_1_reportLine("2", 3)
|
|
344
|
+
RBS_CC_1_reportLine("3", 1)
|
|
345
|
+
return 1
|
|
346
|
+
end if
|
|
347
|
+
RBS_CC_1_reportLine("5", 1)
|
|
348
|
+
return 0
|
|
349
|
+
end function
|
|
350
|
+
end sub
|
|
351
|
+
|
|
352
|
+
function RBS_CC_1_reportLine(lineNumber, reportType = 1)
|
|
353
|
+
_rbs_ccn = m._rbs_ccn
|
|
354
|
+
if _rbs_ccn <> invalid
|
|
355
|
+
_rbs_ccn.entry = {
|
|
356
|
+
"f": "1"
|
|
357
|
+
"l": lineNumber
|
|
358
|
+
"r": reportType
|
|
359
|
+
}
|
|
360
|
+
return true
|
|
361
|
+
end if
|
|
362
|
+
_rbs_ccn = m?.global?._rbs_ccn
|
|
363
|
+
if _rbs_ccn <> invalid
|
|
364
|
+
_rbs_ccn.entry = {
|
|
365
|
+
"f": "1"
|
|
366
|
+
"l": lineNumber
|
|
367
|
+
"r": reportType
|
|
368
|
+
}
|
|
369
|
+
m._rbs_ccn = _rbs_ccn
|
|
370
|
+
return true
|
|
371
|
+
end if
|
|
372
|
+
return true
|
|
373
|
+
end function
|
|
374
|
+
`);
|
|
375
|
+
(0, chai_1.expect)(a).to.equal(b);
|
|
376
|
+
});
|
|
377
|
+
it('correctly transpiles some statements', async () => {
|
|
378
|
+
const source = `
|
|
379
|
+
sub foo(action as string)
|
|
380
|
+
if action = "action1" then
|
|
381
|
+
print "action1"
|
|
382
|
+
else if action = "action2" or action = "action2" then
|
|
383
|
+
print "action2"
|
|
384
|
+
else if action = "action3" then
|
|
385
|
+
print "action3"
|
|
386
|
+
else if action = "action4" then
|
|
387
|
+
else if action = "action5" then
|
|
388
|
+
print "action5"
|
|
389
|
+
else if action = "action6" then
|
|
390
|
+
print "action6"
|
|
391
|
+
else if action = "action7" then
|
|
392
|
+
print "action7"
|
|
393
|
+
else if action = "action8" then
|
|
394
|
+
print "action8"
|
|
395
|
+
else if action = "action9" then
|
|
396
|
+
print "action9"
|
|
397
|
+
else if action = "action10" then
|
|
398
|
+
print "action10"
|
|
399
|
+
else
|
|
400
|
+
end if
|
|
401
|
+
end sub
|
|
402
|
+
`;
|
|
403
|
+
program.setFile('source/code.bs', source);
|
|
404
|
+
program.validate();
|
|
405
|
+
(0, chai_1.expect)(program.getDiagnostics()).to.be.empty;
|
|
406
|
+
await builder.transpile();
|
|
407
|
+
let a = getContents('source/code.brs');
|
|
408
|
+
let b = (0, undent_1.default)(`
|
|
409
|
+
sub foo(action as string)
|
|
410
|
+
if RBS_CC_1_reportLine("2", 2) and (action = "action1") then
|
|
411
|
+
RBS_CC_1_reportLine("2", 3)
|
|
412
|
+
RBS_CC_1_reportLine("3", 1)
|
|
413
|
+
print "action1"
|
|
414
|
+
else if RBS_CC_1_reportLine("4", 2) and (action = "action2" or action = "action2") then
|
|
415
|
+
RBS_CC_1_reportLine("4", 3)
|
|
416
|
+
RBS_CC_1_reportLine("5", 1)
|
|
417
|
+
print "action2"
|
|
418
|
+
else if RBS_CC_1_reportLine("6", 2) and (action = "action3") then
|
|
419
|
+
RBS_CC_1_reportLine("6", 3)
|
|
420
|
+
RBS_CC_1_reportLine("7", 1)
|
|
421
|
+
print "action3"
|
|
422
|
+
else if RBS_CC_1_reportLine("8", 2) and (action = "action4") then
|
|
423
|
+
RBS_CC_1_reportLine("8", 3)
|
|
424
|
+
else if RBS_CC_1_reportLine("9", 2) and (action = "action5") then
|
|
425
|
+
RBS_CC_1_reportLine("9", 3)
|
|
426
|
+
RBS_CC_1_reportLine("10", 1)
|
|
427
|
+
print "action5"
|
|
428
|
+
else if RBS_CC_1_reportLine("11", 2) and (action = "action6") then
|
|
429
|
+
RBS_CC_1_reportLine("11", 3)
|
|
430
|
+
RBS_CC_1_reportLine("12", 1)
|
|
431
|
+
print "action6"
|
|
432
|
+
else if RBS_CC_1_reportLine("13", 2) and (action = "action7") then
|
|
433
|
+
RBS_CC_1_reportLine("13", 3)
|
|
434
|
+
RBS_CC_1_reportLine("14", 1)
|
|
435
|
+
print "action7"
|
|
436
|
+
else if RBS_CC_1_reportLine("15", 2) and (action = "action8") then
|
|
437
|
+
RBS_CC_1_reportLine("15", 3)
|
|
438
|
+
RBS_CC_1_reportLine("16", 1)
|
|
439
|
+
print "action8"
|
|
440
|
+
else if RBS_CC_1_reportLine("17", 2) and (action = "action9") then
|
|
441
|
+
RBS_CC_1_reportLine("17", 3)
|
|
442
|
+
RBS_CC_1_reportLine("18", 1)
|
|
443
|
+
print "action9"
|
|
444
|
+
else if RBS_CC_1_reportLine("19", 2) and (action = "action10") then
|
|
445
|
+
RBS_CC_1_reportLine("19", 3)
|
|
446
|
+
RBS_CC_1_reportLine("20", 1)
|
|
447
|
+
print "action10"
|
|
448
|
+
else
|
|
449
|
+
RBS_CC_1_reportLine("21", 3)
|
|
450
|
+
end if
|
|
451
|
+
end sub
|
|
452
|
+
|
|
453
|
+
function RBS_CC_1_reportLine(lineNumber, reportType = 1)
|
|
454
|
+
_rbs_ccn = m._rbs_ccn
|
|
455
|
+
if _rbs_ccn <> invalid
|
|
456
|
+
_rbs_ccn.entry = {
|
|
457
|
+
"f": "1"
|
|
458
|
+
"l": lineNumber
|
|
459
|
+
"r": reportType
|
|
460
|
+
}
|
|
461
|
+
return true
|
|
462
|
+
end if
|
|
463
|
+
_rbs_ccn = m?.global?._rbs_ccn
|
|
464
|
+
if _rbs_ccn <> invalid
|
|
465
|
+
_rbs_ccn.entry = {
|
|
466
|
+
"f": "1"
|
|
467
|
+
"l": lineNumber
|
|
468
|
+
"r": reportType
|
|
469
|
+
}
|
|
470
|
+
m._rbs_ccn = _rbs_ccn
|
|
471
|
+
return true
|
|
472
|
+
end if
|
|
473
|
+
return true
|
|
474
|
+
end function
|
|
475
|
+
`);
|
|
476
|
+
(0, chai_1.expect)(a).to.equal(b);
|
|
477
|
+
});
|
|
478
|
+
});
|
|
479
|
+
it('excludes files from coverage', async () => {
|
|
480
|
+
const source = `sub foo()
|
|
481
|
+
x = function(y)
|
|
482
|
+
if (true) then
|
|
483
|
+
return 1
|
|
484
|
+
end if
|
|
485
|
+
return 0
|
|
486
|
+
end function
|
|
487
|
+
end sub`;
|
|
488
|
+
program.setFile('source/code.coverageExcluded.bs', source);
|
|
489
|
+
program.validate();
|
|
490
|
+
(0, chai_1.expect)(program.getDiagnostics()).to.be.empty;
|
|
491
|
+
await builder.transpile();
|
|
492
|
+
let a = getContents('source/code.coverageExcluded.brs');
|
|
493
|
+
let b = (0, undent_1.default)(`
|
|
494
|
+
sub foo()
|
|
495
|
+
x = function(y)
|
|
496
|
+
if (true) then
|
|
497
|
+
return 1
|
|
498
|
+
end if
|
|
499
|
+
return 0
|
|
500
|
+
end function
|
|
501
|
+
end sub
|
|
502
|
+
`);
|
|
503
|
+
(0, chai_1.expect)(a).to.equal(b);
|
|
504
|
+
});
|
|
505
|
+
});
|
|
506
|
+
});
|
|
507
|
+
//# sourceMappingURL=CodeCoverageProcessor.spec.js.map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