Could you please provide a failing unit test because negative literals work for me. I used the HEAD of our NVelocity source repository, however I am not aware of any changes in that area since 1.1.1 was released. If my unit test fails for you with that build, I can look into when this was fixed if you like.
[Test]
public void NegativeLiterals()
{
Assert.AreEqual("-27", Eval("#set($result = -27)\r\n$result"));
Assert.AreEqual("-27", Eval("#set($result = 27 * -1)\r\n$result"));
Assert.AreEqual("-27", Eval("#set($result = 27*-1)\r\n$result"));
Assert.AreEqual("27", Eval("#set($result = -27*-1)\r\n$result"));
}
private string Eval(string template)
{
VelocityEngine velocityEngine = new VelocityEngine();
velocityEngine.Init();
using (StringWriter sw = new StringWriter())
{
bool ok = velocityEngine.Evaluate(new VelocityContext(), sw, "", template);
Assert.IsTrue(ok, "Evaluation returned failure");
return sw.ToString();
}
}