Skip to content

Instantly share code, notes, and snippets.

@toptensoftware
Created October 26, 2016 02:52
Show Gist options
  • Select an option

  • Save toptensoftware/151e0cefc6641232a5f578cecf281691 to your computer and use it in GitHub Desktop.

Select an option

Save toptensoftware/151e0cefc6641232a5f578cecf281691 to your computer and use it in GitHub Desktop.
// Negative
Assert.AreEqual(Parser.Parse("-10").Eval(), -10);
// Positive
Assert.AreEqual(Parser.Parse("+10").Eval(), 10);
// Negative of a negative
Assert.AreEqual(Parser.Parse("--10").Eval(), 10);
// Woah!
Assert.AreEqual(Parser.Parse("--++-+-10").Eval(), 10);
// All together now
Assert.AreEqual(Parser.Parse("10 + -20 - +30").Eval(), -40);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment