public override object VisitSignedAtom([NotNull] DiceParser.SignedAtomContext context) { Atom atom = (Atom)this.VisitAtom(context.atom()); if (context.SIGN() != null && context.SIGN().GetText() == "-") { atom.Sign = AtomSign.Minus; } return(atom); }
public void NegativeAtomTest() { DiceParser parser = Setup("-4d8"); DiceParser.SignedAtomContext context = parser.signedAtom(); DiceVisitor visitor = new DiceVisitor(); Atom result = (Atom)visitor.VisitSignedAtom(context); result.IsDiceGroup.Should().BeTrue(); result.Sign.Should().Be(AtomSign.Minus); result.DiceGroupInstance.Should().BeEquivalentTo(new DiceGroup(new List <Dice> { new Dice(8), new Dice(8), new Dice(8), new Dice(8) })); }