Skip to content

Commit 8958834

Browse files
Additional optional field selection tests (#353)
1 parent d9a0a0d commit 8958834

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

tests/simple/testdata/optionals.textproto

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,26 @@ section: {
2222
expr: "{'key': {}}.?key.optFlatMap(k, k.?subkey).hasValue()"
2323
value: { bool_value: false }
2424
}
25+
test {
26+
name: "map_null_entry_hasValue"
27+
expr: "{'null_key': dyn(null)}.?null_key.hasValue()"
28+
value: { bool_value: true }
29+
}
2530
test {
2631
name: "map_null_entry_no_such_key"
27-
expr: "{'null_key': null}.?null_key.invalid.hasValue()"
32+
expr: "{'null_key': dyn(null)}.?null_key.invalid.hasValue()"
33+
eval_error: {
34+
errors: { message: "no such key" }
35+
}
36+
}
37+
test {
38+
name: "map_absent_key_absent_field_none"
39+
expr: "{true: dyn(0)}[?false].absent.hasValue()"
40+
value: { bool_value: false }
41+
}
42+
test {
43+
name: "map_present_key_invalid_field"
44+
expr: "{true: dyn(0)}[?true].absent.hasValue()"
2845
eval_error: {
2946
errors: { message: "no such key" }
3047
}

0 commit comments

Comments
 (0)