|
@@ -2174,9 +2174,9 @@ void expression_tests() {
|
|
|
|
|
|
|
|
Test.add_func("/invercargill/expressions/parameter_single", () => {
|
|
Test.add_func("/invercargill/expressions/parameter_single", () => {
|
|
|
// Single parameter: $0 > 5
|
|
// Single parameter: $0 > 5
|
|
|
- var expr = ExpressionParser.parse_with_params("$0 > 5",
|
|
|
|
|
- new NativeElement<int>(10)
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ var params = new Series<Element>();
|
|
|
|
|
+ params.add(new NativeElement<int>(10));
|
|
|
|
|
+ var expr = ExpressionParser.parse_with_params("$0 > 5", params);
|
|
|
var context = new EvaluationContext(new PropertyDictionary());
|
|
var context = new EvaluationContext(new PropertyDictionary());
|
|
|
var result = expr.evaluate(context);
|
|
var result = expr.evaluate(context);
|
|
|
|
|
|
|
@@ -2187,10 +2187,10 @@ void expression_tests() {
|
|
|
|
|
|
|
|
Test.add_func("/invercargill/expressions/parameter_multiple", () => {
|
|
Test.add_func("/invercargill/expressions/parameter_multiple", () => {
|
|
|
// Multiple parameters: $0 + $1
|
|
// Multiple parameters: $0 + $1
|
|
|
- var expr = ExpressionParser.parse_with_params("$0 + $1",
|
|
|
|
|
- new NativeElement<int>(3),
|
|
|
|
|
- new NativeElement<int>(4)
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ var params = new Series<Element>();
|
|
|
|
|
+ params.add(new NativeElement<int>(3));
|
|
|
|
|
+ params.add(new NativeElement<int>(4));
|
|
|
|
|
+ var expr = ExpressionParser.parse_with_params("$0 + $1", params);
|
|
|
var context = new EvaluationContext(new PropertyDictionary());
|
|
var context = new EvaluationContext(new PropertyDictionary());
|
|
|
var result = expr.evaluate(context);
|
|
var result = expr.evaluate(context);
|
|
|
|
|
|
|
@@ -2201,9 +2201,9 @@ void expression_tests() {
|
|
|
|
|
|
|
|
Test.add_func("/invercargill/expressions/parameter_with_variable", () => {
|
|
Test.add_func("/invercargill/expressions/parameter_with_variable", () => {
|
|
|
// Parameter with variable: x > $0
|
|
// Parameter with variable: x > $0
|
|
|
- var expr = ExpressionParser.parse_with_params("x > $0",
|
|
|
|
|
- new NativeElement<int>(5)
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ var params = new Series<Element>();
|
|
|
|
|
+ params.add(new NativeElement<int>(5));
|
|
|
|
|
+ var expr = ExpressionParser.parse_with_params("x > $0", params);
|
|
|
var props = new PropertyDictionary();
|
|
var props = new PropertyDictionary();
|
|
|
props.set("x", new NativeElement<int>(10));
|
|
props.set("x", new NativeElement<int>(10));
|
|
|
var context = new EvaluationContext(props);
|
|
var context = new EvaluationContext(props);
|
|
@@ -2216,9 +2216,9 @@ void expression_tests() {
|
|
|
|
|
|
|
|
Test.add_func("/invercargill/expressions/parameter_string", () => {
|
|
Test.add_func("/invercargill/expressions/parameter_string", () => {
|
|
|
// String parameter: $0 == "hello"
|
|
// String parameter: $0 == "hello"
|
|
|
- var expr = ExpressionParser.parse_with_params("$0 == \"hello\"",
|
|
|
|
|
- new NativeElement<string>("hello")
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ var params = new Series<Element>();
|
|
|
|
|
+ params.add(new NativeElement<string>("hello"));
|
|
|
|
|
+ var expr = ExpressionParser.parse_with_params("$0 == \"hello\"", params);
|
|
|
var context = new EvaluationContext(new PropertyDictionary());
|
|
var context = new EvaluationContext(new PropertyDictionary());
|
|
|
var result = expr.evaluate(context);
|
|
var result = expr.evaluate(context);
|
|
|
|
|
|
|
@@ -2230,9 +2230,9 @@ void expression_tests() {
|
|
|
Test.add_func("/invercargill/expressions/parameter_complex_object", () => {
|
|
Test.add_func("/invercargill/expressions/parameter_complex_object", () => {
|
|
|
// Complex object parameter: $0.name
|
|
// Complex object parameter: $0.name
|
|
|
var person = new ExprTestPerson("Alice", 30);
|
|
var person = new ExprTestPerson("Alice", 30);
|
|
|
- var expr = ExpressionParser.parse_with_params("$0.name",
|
|
|
|
|
- new NativeElement<ExprTestPerson>(person)
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ var params = new Series<Element>();
|
|
|
|
|
+ params.add(new NativeElement<ExprTestPerson>(person));
|
|
|
|
|
+ var expr = ExpressionParser.parse_with_params("$0.name", params);
|
|
|
var context = new EvaluationContext(new PropertyDictionary());
|
|
var context = new EvaluationContext(new PropertyDictionary());
|
|
|
var result = expr.evaluate(context);
|
|
var result = expr.evaluate(context);
|
|
|
|
|
|
|
@@ -2243,9 +2243,9 @@ void expression_tests() {
|
|
|
|
|
|
|
|
Test.add_func("/invercargill/expressions/parameter_in_ternary", () => {
|
|
Test.add_func("/invercargill/expressions/parameter_in_ternary", () => {
|
|
|
// Parameter in ternary: $0 ? "yes" : "no"
|
|
// Parameter in ternary: $0 ? "yes" : "no"
|
|
|
- var expr = ExpressionParser.parse_with_params("$0 ? \"yes\" : \"no\"",
|
|
|
|
|
- new NativeElement<bool>(true)
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ var params = new Series<Element>();
|
|
|
|
|
+ params.add(new NativeElement<bool>(true));
|
|
|
|
|
+ var expr = ExpressionParser.parse_with_params("$0 ? \"yes\" : \"no\"", params);
|
|
|
var context = new EvaluationContext(new PropertyDictionary());
|
|
var context = new EvaluationContext(new PropertyDictionary());
|
|
|
var result = expr.evaluate(context);
|
|
var result = expr.evaluate(context);
|
|
|
|
|
|
|
@@ -2261,9 +2261,9 @@ void expression_tests() {
|
|
|
persons.add(new ExprTestPerson("Bob", 25, 1));
|
|
persons.add(new ExprTestPerson("Bob", 25, 1));
|
|
|
persons.add(new ExprTestPerson("Charlie", 35, 3));
|
|
persons.add(new ExprTestPerson("Charlie", 35, 3));
|
|
|
|
|
|
|
|
- var expr = ExpressionParser.parse_with_params("items.where(i => i.rank > $0)",
|
|
|
|
|
- new NativeElement<int>(2)
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ var params = new Series<Element>();
|
|
|
|
|
+ params.add(new NativeElement<int>(2));
|
|
|
|
|
+ var expr = ExpressionParser.parse_with_params("items.where(i => i.rank > $0)", params);
|
|
|
var props = new PropertyDictionary();
|
|
var props = new PropertyDictionary();
|
|
|
props.set("items", new NativeElement<Enumerable<ExprTestPerson>?>(persons));
|
|
props.set("items", new NativeElement<Enumerable<ExprTestPerson>?>(persons));
|
|
|
var context = new EvaluationContext(props);
|
|
var context = new EvaluationContext(props);
|
|
@@ -2279,10 +2279,10 @@ void expression_tests() {
|
|
|
|
|
|
|
|
Test.add_func("/invercargill/expressions/parameter_range_check", () => {
|
|
Test.add_func("/invercargill/expressions/parameter_range_check", () => {
|
|
|
// Range check with two parameters: $0 <= x && x <= $1
|
|
// Range check with two parameters: $0 <= x && x <= $1
|
|
|
- var expr = ExpressionParser.parse_with_params("$0 <= x && x <= $1",
|
|
|
|
|
- new NativeElement<int>(0),
|
|
|
|
|
- new NativeElement<int>(100)
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ var params = new Series<Element>();
|
|
|
|
|
+ params.add(new NativeElement<int>(0));
|
|
|
|
|
+ params.add(new NativeElement<int>(100));
|
|
|
|
|
+ var expr = ExpressionParser.parse_with_params("$0 <= x && x <= $1", params);
|
|
|
var props = new PropertyDictionary();
|
|
var props = new PropertyDictionary();
|
|
|
props.set("x", new NativeElement<int>(50));
|
|
props.set("x", new NativeElement<int>(50));
|
|
|
var context = new EvaluationContext(props);
|
|
var context = new EvaluationContext(props);
|