Skip to content

Commit

Permalink
Merge branch 'stage' into fix/83/tracked-event-infinite-loop
Browse files Browse the repository at this point in the history
  • Loading branch information
jcowman2 committed Oct 26, 2019
2 parents e1130ee + cc445d8 commit 98eceed
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 0 additions & 4 deletions src/agents/impl/instance-agents-impl.ts
Expand Up @@ -218,10 +218,6 @@ class InstanceAgentsImpl implements InstanceAgentsInternal {
);
value = this.game.using(value);
value = new AgentArrayReference(value.meta.id);
} else if (typeof value === "function") {
throw new RegalError(
"Agents can't have arrow functions as properties. If you need a class method, please use traditional function syntax."
);
}

am.setProperty(property, value);
Expand Down
14 changes: 9 additions & 5 deletions test/unit/agents.test.ts
Expand Up @@ -2004,14 +2004,18 @@ describe("Agents", function() {
expect(() => myGame.using(_d)).to.throw(RegalError);
});

it("Throws a RegalError if an agent's property is set to an arrow function", function() {
class ArrowFuncAgent extends Agent {
constructor(public func: () => {}) {
super();
}
}

it("Agent properties can be arrow functions", function() {
Game.init(MD);
const myGame = buildGameInstance();
const dummy = myGame.using(new Dummy("D1", 1));
const dummy = myGame.using(new ArrowFuncAgent(() => "yo"));

expect(() => ((dummy as any).foo = () => "yo")).to.throw(
RegalError
);
expect(dummy.func()).to.equal("yo");
});
});
});
Expand Down

0 comments on commit 98eceed

Please sign in to comment.