diff --git a/JexlNet.ExtendedGrammar/ExtendedGrammar.cs b/JexlNet.ExtendedGrammar/ExtendedGrammar.cs index 1df8874..8a66046 100644 --- a/JexlNet.ExtendedGrammar/ExtendedGrammar.cs +++ b/JexlNet.ExtendedGrammar/ExtendedGrammar.cs @@ -105,6 +105,10 @@ public ExtendedGrammar() AddFunction("$number", ToNumber); AddTransform("number", ToNumber); AddTransform("toNumber", ToNumber); + AddFunction("parseFloat", ToNumber); + AddFunction("$parseFloat", ToNumber); + AddTransform("float", ToNumber); + AddTransform("toFloat", ToNumber); // AbsoluteValue AddFunction("abs", AbsoluteValue); AddFunction("$abs", AbsoluteValue); @@ -151,6 +155,7 @@ public ExtendedGrammar() AddTransform("parseInteger", ParseInteger); AddTransform("parseInt", ParseInteger); AddTransform("toInt", ParseInteger); + AddTransform("integer", ParseInteger); // Sum AddFunction("sum", Sum); AddFunction("$sum", Sum); diff --git a/JexlNet.Test/ExtendedGrammar.cs b/JexlNet.Test/ExtendedGrammar.cs index 5f032f4..086d1ae 100644 --- a/JexlNet.Test/ExtendedGrammar.cs +++ b/JexlNet.Test/ExtendedGrammar.cs @@ -159,6 +159,7 @@ public void ConvertBase64(string expression, string expected) [InlineData("3|power(2)", 9)] [InlineData("3|power", 9)] [InlineData("9|sqrt", 3)] + [InlineData("random() < 1 ? 1 : 0", 1)] public void Number(string expression, decimal expected) { var jexl = new Jexl(new ExtendedGrammar()); @@ -233,7 +234,8 @@ public void Boolean(string expression, bool? expected) [InlineData("['tek', 'baz', 'bar', 'foo']|reverse")] [InlineData("['tek', 'baz', 'bar', 'foo', 'foo']|reverse|distinct")] [InlineData("{'foo':0, bar:1, 'baz':2, tek:3}|keys")] // doesn't work in TS - [InlineData("{foo:0, bar:1, baz:2, tek:3}|keys")] // doesn't work in TS + // [InlineData("{['foo']:0, bar:1, ['baz']:2, tek:3}|keys")] // doesn't work + [InlineData("{foo:0, bar:1, baz:2, tek:3}|keys")] [InlineData("{a:'foo', b:'bar', c:'baz', d:'tek'}|values")] [InlineData("[{name:'foo'}, {name:'bar'}, {name:'baz'}, {name:'tek'}]|mapField('name')")] [InlineData("[{name:'tek',age:32}, {name:'bar',age:34}, {name:'baz',age:33}, {name:'foo',age:35}]|sort('age',true)|mapField('name')")]