Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(extensions): Add _brs_.testData associative array #646

Merged
merged 6 commits into from
Apr 30, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add UT for testData
  • Loading branch information
Vasyl Martynych committed Apr 19, 2021
commit 0f269ca32db94fb1011f5614d478cb406b21de44
29 changes: 29 additions & 0 deletions test/extensions/testData.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const brs = require("brs");
const { BrsString, BrsInvalid, ValueKind } = brs.types;
const { Interpreter } = require("../../lib/interpreter");
const { identifier } = require("../parser/ParserTests");

describe("_brs_.testData", () => {
it("check testData object", () => {
let _brs_ = new Interpreter().environment.get(identifier("_brs_"));
let testData = _brs_.get(new BrsString("testData"));

expect(testData.kind).toBe(ValueKind.Object);
expect(testData.componentName).toBe("roAssociativeArray");
expect(testData.elements.size).toBe(0);
testData.set(new BrsString("foo"), BrsInvalid.Instance);
expect(testData.elements.size).toBe(1);

testData = new Interpreter().environment
.get(identifier("_brs_"))
.get(new BrsString("testData"));
expect(testData.elements.size).toBe(1);

brs.resetTestData(); // will clear testData for next new Interpreter instances
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want the _brs_.testData to persist across interpreter instances? IIRC there's only one created as part of roca anyway. We'll still want this type of behavior, but perhaps simpler solution would be for each Interpreter instance to get its own copy of the _brs_ extensions 🤔


testData = new Interpreter().environment
.get(identifier("_brs_"))
.get(new BrsString("testData"));
expect(testData.elements.size).toBe(0);
});
});