@@ -4581,4 +4581,74 @@ void testComputedProperty_privacyCode_Multilingual() {
45814581 // #endregion: Privacy property cardinality
45824582
45834583 // #endregion: Cardinality x Consumer Gaps
4584+
4585+ // #region: EFX-2 COMPUTE syntax ---------------------------------------------
4586+
4587+ @ Test
4588+ void testCompute_BooleanExpression () {
4589+ testComputeExpressionWithContext ("(true() or true()) and false()" , "BT-00-Text" ,
4590+ "(ALWAYS or TRUE) and NEVER" );
4591+ }
4592+
4593+ @ Test
4594+ void testCompute_PresenceCondition () {
4595+ testComputeExpressionWithContext ("PathNode/TextField" , "ND-Root" , "BT-00-Text is present" );
4596+ }
4597+
4598+ @ Test
4599+ void testCompute_NumericExpression () {
4600+ testComputeExpressionWithContext ("1 + 2" , "BT-00-Text" , "1 + 2" );
4601+ }
4602+
4603+ @ Test
4604+ void testCompute_StringComparison () {
4605+ testComputeExpressionWithContext ("'abc' = 'def'" , "BT-00-Text" , "'abc' == 'def'" );
4606+ }
4607+
4608+ @ Test
4609+ void testCompute_FieldReference () {
4610+ testComputeExpressionWithContext ("PathNode/TextField/normalize-space(text())" , "ND-Root" ,
4611+ "BT-00-Text" );
4612+ }
4613+
4614+ @ Test
4615+ void testCompute_WithNodeContext () {
4616+ testComputeExpressionWithContext ("PathNode/TextField" , "ND-Root" , "BT-00-Text is present" );
4617+ }
4618+
4619+ @ Test
4620+ void testCompute_WithParameters () {
4621+ testExpressionTranslation ("'hello' = 'world'" ,
4622+ "WITH ND-Root, text:$p1, text:$p2 COMPUTE $p1 == $p2" , "'hello'" , "'world'" );
4623+ }
4624+
4625+ @ Test
4626+ void testCompute_WithNumericParameters () {
4627+ testExpressionTranslation ("1 = 2" ,
4628+ "WITH ND-Root, number:$p1, number:$p2 COMPUTE $p1 == $p2" , "1" , "2" );
4629+ }
4630+
4631+ @ Test
4632+ void testCompute_WithDateParameters () {
4633+ testExpressionTranslation ("xs:date('2018-01-01Z') = xs:date('2020-01-01Z')" ,
4634+ "WITH ND-Root, date:$p1, date:$p2 COMPUTE $p1 == $p2" , "2018-01-01Z" , "2020-01-01Z" );
4635+ }
4636+
4637+ @ Test
4638+ void testCompute_WithSequenceParameter () {
4639+ testExpressionTranslation ("count(('a','b','c'))" ,
4640+ "WITH ND-Root, text*:$items COMPUTE count($items)" , "['a', 'b', 'c']" );
4641+ }
4642+
4643+ @ Test
4644+ void testCompute_CaseInsensitive () {
4645+ testComputeExpressionWithContext ("(true() or true()) and false()" , "BT-00-Text" ,
4646+ "(ALWAYS or TRUE) and NEVER" );
4647+ // Also test lowercase
4648+ assertEquals (
4649+ translateComputeExpressionWithContext ("BT-00-Text" , "(ALWAYS or TRUE) and NEVER" ),
4650+ translateExpression ("with BT-00-Text compute (ALWAYS or TRUE) and NEVER" ));
4651+ }
4652+
4653+ // #endregion: EFX-2 COMPUTE syntax
45844654}
0 commit comments