Skip to content

Commit

Permalink
Add Roku_Ads() to global callables for now
Browse files Browse the repository at this point in the history
  • Loading branch information
TwitchBronBron committed Feb 13, 2021
1 parent 2ead412 commit 4836f2c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
13 changes: 13 additions & 0 deletions src/globalCallables.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { standardizePath as s } from './util';
import { Program } from './Program';
import { expect } from 'chai';
import { expectZeroDiagnostics } from './testHelpers.spec';

let tmpPath = s`${process.cwd()}/.tmp`;
let rootDir = s`${tmpPath}/rootDir`;
Expand All @@ -18,6 +19,18 @@ describe('globalCallables', () => {
program.dispose();
});

describe('Roku_ads', () => {
it('exists', () => {
program.addOrReplaceFile('source/main.brs', `
sub main()
adIface = Roku_Ads()
end sub
`);
program.validate();
expectZeroDiagnostics(program);
});
});

describe('val', () => {
it('allows single parameter', () => {
program.addOrReplaceFile('source/main.brs', `
Expand Down
7 changes: 7 additions & 0 deletions src/globalCallables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,13 @@ let programStatementFunctions = [
name: 'x',
type: new IntegerType()
}]
//TODO this is a temporary fix for library imported files. Eventually this should be moved into `Roku_Ads.brs` and handled by the `Library` statement
}, {
name: 'Roku_Ads',
shortDescription: 'The main entry point for instantiating the ad interface. This object manages ad server requests, parses ad structure, schedules and renders ads, and triggers tracking beacons.\n\nThe Roku ad parser/renderer object returned has global scope because it is meant to represent interaction with external resources (the ad server and any tracking services) that have persistence and state independent of the ad rendering within a client application.',
type: new FunctionType(new ObjectType()),
file: globalFile,
params: []
}
] as Callable[];

Expand Down
4 changes: 2 additions & 2 deletions src/testHelpers.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ export function expectZeroDiagnostics(arg: { getDiagnostics(): Array<Diagnostic>
let diagnostics: BsDiagnostic[];
if (Array.isArray(arg)) {
diagnostics = arg as BsDiagnostic[];
} else if ((arg as any).diagnostics) {
diagnostics = (arg as any).diagnostics;
} else if ((arg as any).getDiagnostics) {
diagnostics = (arg as any).getDiagnostics();
} else if ((arg as any).diagnostics) {
diagnostics = (arg as any).diagnostics;
} else {
throw new Error('Cannot derive a list of diagnostics from ' + JSON.stringify(arg));
}
Expand Down

0 comments on commit 4836f2c

Please sign in to comment.