您能否提供一个失败的单元测试,因为负面文字对我有用。我使用了我们的 NVelocity 源存储库的HEAD,但是我不知道自 1.1.1 发布以来该区域的任何更改。如果我的单元测试在该构建中对您失败,如果您愿意,我可以查看何时修复。
[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();
}
}