@@ -432,4 +432,83 @@ public void convertCelComprehension_toMutableComprehension() {
432432 CelMutableExpr .ofConstant (6L , CelConstant .ofValue (true )),
433433 CelMutableExpr .ofIdent (7L , "__result__" ))));
434434 }
435+
436+ @ Test
437+ public void convertMutableComprehension_withTwoIterVars_toCelComprehension () {
438+ CelMutableExpr mutableExpr =
439+ CelMutableExpr .ofComprehension (
440+ 1L ,
441+ CelMutableComprehension .create (
442+ "iterVar" ,
443+ "iterVar2" ,
444+ CelMutableExpr .ofList (
445+ 2L ,
446+ CelMutableList .create (
447+ CelMutableExpr .ofConstant (3L , CelConstant .ofValue (true )))),
448+ "accuVar" ,
449+ CelMutableExpr .ofConstant (4L , CelConstant .ofValue (true )),
450+ CelMutableExpr .ofConstant (5L , CelConstant .ofValue (true )),
451+ CelMutableExpr .ofConstant (6L , CelConstant .ofValue (true )),
452+ CelMutableExpr .ofIdent (7L , "__result__" )));
453+
454+ CelExpr celExpr = CelMutableExprConverter .fromMutableExpr (mutableExpr );
455+
456+ assertThat (celExpr )
457+ .isEqualTo (
458+ CelExpr .ofComprehension (
459+ 1L ,
460+ "iterVar" ,
461+ "iterVar2" ,
462+ CelExpr .newBuilder ()
463+ .setId (2L )
464+ .setList (
465+ CelList .newBuilder ()
466+ .addElements (CelExpr .ofConstant (3L , CelConstant .ofValue (true )))
467+ .build ())
468+ .build (),
469+ "accuVar" ,
470+ CelExpr .ofConstant (4L , CelConstant .ofValue (true )),
471+ CelExpr .ofConstant (5L , CelConstant .ofValue (true )),
472+ CelExpr .ofConstant (6L , CelConstant .ofValue (true )),
473+ CelExpr .ofIdent (7L , "__result__" )));
474+ }
475+
476+ @ Test
477+ public void convertCelComprehension_withTwoIterVars_toMutableComprehension () {
478+ CelExpr celExpr =
479+ CelExpr .ofComprehension (
480+ 1L ,
481+ "iterVar" ,
482+ "iterVar2" ,
483+ CelExpr .newBuilder ()
484+ .setId (2L )
485+ .setList (
486+ CelList .newBuilder ()
487+ .addElements (CelExpr .ofConstant (3L , CelConstant .ofValue (true )))
488+ .build ())
489+ .build (),
490+ "accuVar" ,
491+ CelExpr .ofConstant (4L , CelConstant .ofValue (true )),
492+ CelExpr .ofConstant (5L , CelConstant .ofValue (true )),
493+ CelExpr .ofConstant (6L , CelConstant .ofValue (true )),
494+ CelExpr .ofIdent (7L , "__result__" ));
495+
496+ CelMutableExpr mutableExpr = CelMutableExprConverter .fromCelExpr (celExpr );
497+ assertThat (mutableExpr )
498+ .isEqualTo (
499+ CelMutableExpr .ofComprehension (
500+ 1L ,
501+ CelMutableComprehension .create (
502+ "iterVar" ,
503+ "iterVar2" ,
504+ CelMutableExpr .ofList (
505+ 2L ,
506+ CelMutableList .create (
507+ CelMutableExpr .ofConstant (3L , CelConstant .ofValue (true )))),
508+ "accuVar" ,
509+ CelMutableExpr .ofConstant (4L , CelConstant .ofValue (true )),
510+ CelMutableExpr .ofConstant (5L , CelConstant .ofValue (true )),
511+ CelMutableExpr .ofConstant (6L , CelConstant .ofValue (true )),
512+ CelMutableExpr .ofIdent (7L , "__result__" ))));
513+ }
435514}
0 commit comments