@@ -5525,7 +5525,7 @@ pub mod test {
5525
5525
}
5526
5526
5527
5527
#[ test]
5528
- fn parital_if_noerrors ( ) {
5528
+ fn partial_if_noerrors ( ) {
5529
5529
let guard = Expr :: get_attr ( Expr :: unknown ( Unknown :: new_untyped ( "a" ) ) , "field" . into ( ) ) ;
5530
5530
let cons = Expr :: val ( 1 ) ;
5531
5531
let alt = Expr :: val ( 2 ) ;
@@ -6144,4 +6144,72 @@ pub mod test {
6144
6144
) ;
6145
6145
assert_matches ! ( eval. partial_eval_expr( & e) , Err ( _) ) ;
6146
6146
}
6147
+
6148
+ #[ test]
6149
+ fn interpret_extended_has ( ) {
6150
+ let es = Entities :: new ( ) ;
6151
+ let eval = Evaluator :: new ( empty_request ( ) , & es, Extensions :: none ( ) ) ;
6152
+ assert_matches ! ( eval. interpret_inline_policy( & parse_expr( r#"
6153
+ {a: {b: {c: 1}}} has a.b.c
6154
+ "# ) . unwrap( ) ) , Ok ( v) => {
6155
+ assert_eq!( v, Value :: from( true ) ) ;
6156
+ } ) ;
6157
+ assert_matches ! ( eval. interpret_inline_policy( & parse_expr( r#"
6158
+ {a: {b: {c: 1}}} has a.b
6159
+ "# ) . unwrap( ) ) , Ok ( v) => {
6160
+ assert_eq!( v, Value :: from( true ) ) ;
6161
+ } ) ;
6162
+ assert_matches ! ( eval. interpret_inline_policy( & parse_expr( r#"
6163
+ {a: {b: {c: 1}}} has a
6164
+ "# ) . unwrap( ) ) , Ok ( v) => {
6165
+ assert_eq!( v, Value :: from( true ) ) ;
6166
+ } ) ;
6167
+ assert_matches ! ( eval. interpret_inline_policy( & parse_expr( r#"
6168
+ {a: {b: {c: 1}}} has b.c
6169
+ "# ) . unwrap( ) ) , Ok ( v) => {
6170
+ assert_eq!( v, Value :: from( false ) ) ;
6171
+ } ) ;
6172
+ assert_matches ! ( eval. interpret_inline_policy( & parse_expr( r#"
6173
+ {a: {b: {c: 1}}} has c
6174
+ "# ) . unwrap( ) ) , Ok ( v) => {
6175
+ assert_eq!( v, Value :: from( false ) ) ;
6176
+ } ) ;
6177
+ assert_matches ! ( eval. interpret_inline_policy( & parse_expr( r#"
6178
+ {a: {b: {c: 1}}} has d
6179
+ "# ) . unwrap( ) ) , Ok ( v) => {
6180
+ assert_eq!( v, Value :: from( false ) ) ;
6181
+ } ) ;
6182
+ assert_matches ! ( eval. interpret_inline_policy( & parse_expr( r#"
6183
+ {a: {b: {c: 1}}} has "🚫"
6184
+ "# ) . unwrap( ) ) , Ok ( v) => {
6185
+ assert_eq!( v, Value :: from( false ) ) ;
6186
+ } ) ;
6187
+
6188
+ assert_matches ! ( eval. interpret_inline_policy( & parse_expr( r#"
6189
+ {a: {b: {c: 1}}} has a.b.c && {a: {b: {c: 1}}}.a.b.c == 1
6190
+ "# ) . unwrap( ) ) , Ok ( v) => {
6191
+ assert_eq!( v, Value :: from( true ) ) ;
6192
+ } ) ;
6193
+ assert_matches ! ( eval. interpret_inline_policy( & parse_expr( r#"
6194
+ {a: {b: {c: 1}}} has a.b && {a: {b: {c: 1}}}.a.b == {c: 1}
6195
+ "# ) . unwrap( ) ) , Ok ( v) => {
6196
+ assert_eq!( v, Value :: from( true ) ) ;
6197
+ } ) ;
6198
+ assert_matches ! ( eval. interpret_inline_policy( & parse_expr( r#"
6199
+ {a: {b: {c: 1}}} has a && {a: {b: {c: 1}}}.a == {b: {c: 1}}
6200
+ "# ) . unwrap( ) ) , Ok ( v) => {
6201
+ assert_eq!( v, Value :: from( true ) ) ;
6202
+ } ) ;
6203
+ assert_matches ! ( eval. interpret_inline_policy( & parse_expr( r#"
6204
+ {a: {b: {d: 1}}} has a.b.c && {a: {b: {d: 1}}}.a.b.c == 1
6205
+ "# ) . unwrap( ) ) , Ok ( v) => {
6206
+ assert_eq!( v, Value :: from( false ) ) ;
6207
+ } ) ;
6208
+
6209
+ assert_matches ! ( eval. interpret_inline_policy( & parse_expr( r#"
6210
+ {a: {b: {c: 1}}} has a.b && {a: {b: {c: 1}}}.a.b.d == 1
6211
+ "# ) . unwrap( ) ) , Err ( EvaluationError :: RecordAttrDoesNotExist ( err) ) => {
6212
+ assert_eq!( err. attr, "d" ) ;
6213
+ } ) ;
6214
+ }
6147
6215
}
0 commit comments