@@ -4604,4 +4604,74 @@ void testComputedProperty_privacyCode_Multilingual() {
46044604 // #endregion: Privacy property cardinality
46054605
46064606 // #endregion: Cardinality x Consumer Gaps
4607+
4608+ // #region: EFX-2 COMPUTE syntax ---------------------------------------------
4609+
4610+ @ Test
4611+ void testCompute_BooleanExpression () {
4612+ testComputeExpressionWithContext ("(true() or true()) and false()" , "BT-00-Text" ,
4613+ "(ALWAYS or TRUE) and NEVER" );
4614+ }
4615+
4616+ @ Test
4617+ void testCompute_PresenceCondition () {
4618+ testComputeExpressionWithContext ("PathNode/TextField" , "ND-Root" , "BT-00-Text is present" );
4619+ }
4620+
4621+ @ Test
4622+ void testCompute_NumericExpression () {
4623+ testComputeExpressionWithContext ("1 + 2" , "BT-00-Text" , "1 + 2" );
4624+ }
4625+
4626+ @ Test
4627+ void testCompute_StringComparison () {
4628+ testComputeExpressionWithContext ("'abc' = 'def'" , "BT-00-Text" , "'abc' == 'def'" );
4629+ }
4630+
4631+ @ Test
4632+ void testCompute_FieldReference () {
4633+ testComputeExpressionWithContext ("PathNode/TextField/normalize-space(text())" , "ND-Root" ,
4634+ "BT-00-Text" );
4635+ }
4636+
4637+ @ Test
4638+ void testCompute_WithNodeContext () {
4639+ testComputeExpressionWithContext ("PathNode/TextField" , "ND-Root" , "BT-00-Text is present" );
4640+ }
4641+
4642+ @ Test
4643+ void testCompute_WithParameters () {
4644+ testExpressionTranslation ("'hello' = 'world'" ,
4645+ "WITH ND-Root, text:$p1, text:$p2 COMPUTE $p1 == $p2" , "'hello'" , "'world'" );
4646+ }
4647+
4648+ @ Test
4649+ void testCompute_WithNumericParameters () {
4650+ testExpressionTranslation ("1 = 2" ,
4651+ "WITH ND-Root, number:$p1, number:$p2 COMPUTE $p1 == $p2" , "1" , "2" );
4652+ }
4653+
4654+ @ Test
4655+ void testCompute_WithDateParameters () {
4656+ testExpressionTranslation ("xs:date('2018-01-01Z') = xs:date('2020-01-01Z')" ,
4657+ "WITH ND-Root, date:$p1, date:$p2 COMPUTE $p1 == $p2" , "2018-01-01Z" , "2020-01-01Z" );
4658+ }
4659+
4660+ @ Test
4661+ void testCompute_WithSequenceParameter () {
4662+ testExpressionTranslation ("count(('a','b','c'))" ,
4663+ "WITH ND-Root, text*:$items COMPUTE count($items)" , "['a', 'b', 'c']" );
4664+ }
4665+
4666+ @ Test
4667+ void testCompute_CaseInsensitive () {
4668+ testComputeExpressionWithContext ("(true() or true()) and false()" , "BT-00-Text" ,
4669+ "(ALWAYS or TRUE) and NEVER" );
4670+ // Also test lowercase
4671+ assertEquals (
4672+ translateComputeExpressionWithContext ("BT-00-Text" , "(ALWAYS or TRUE) and NEVER" ),
4673+ translateExpression ("with BT-00-Text compute (ALWAYS or TRUE) and NEVER" ));
4674+ }
4675+
4676+ // #endregion: EFX-2 COMPUTE syntax
46074677}
0 commit comments