-
-
Notifications
You must be signed in to change notification settings - Fork 383
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
No longer stop parsing an expression after invoking a custom function #…
- Loading branch information
Showing
4 changed files
with
55 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using System; | ||
using NUnit.Framework; | ||
|
||
namespace DynamicExpresso.UnitTest | ||
{ | ||
[TestFixture] | ||
public class FunctionTest | ||
{ | ||
[Test] | ||
public void Calling_Function() | ||
{ | ||
var target = new Interpreter(); | ||
Func<double, double, double> pow = (x, y) => Math.Pow(x, y); | ||
target.SetFunction("pow", pow); | ||
|
||
Assert.AreEqual(25, target.Eval("pow(5, 2)")); | ||
} | ||
|
||
[Test] | ||
public void Chaining_Functions() | ||
{ | ||
var target = new Interpreter(); | ||
Func<double, double, double> pow = (x, y) => Math.Pow(x, y); | ||
target.SetFunction("pow", pow); | ||
|
||
Assert.AreEqual("25", target.Eval("pow(5, 2).ToString()")); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters