mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 22:02:23 +01:00
Reduce use of gmock matcher infrastructure for diagnosing mismatches,
and instead manually stream an explanation of the difference. The
gmock-style "EXPECT_THAT" approach adds an unsuppressable "Actual: ..."
line into the output that only contains unreadable and redundant noise.
We're getting zero value from using a matcher diagnostic here, so don't.
Before:
```
Value of: SplitOutput(test_file.actual_stdout)
Expected: matches elements with unified diff
Actual: { "--- else.carbon", "", "constants {", " %F.type: type = fn_type @F [concrete]", " %empty_tuple.type: type = tuple_type () [concrete]", " %F: %F.type = struct_value () [concrete]", " %H.type: type = fn_type @H [concrete]", " %H: %H.type = struct_value () [concrete]", " %pattern_type: type = pattern_type bool [concrete]", " %b.param_patt: %pattern_type = value_param_pattern [concrete]", " %b.patt: %pattern_type = at_binding_pattern b, %b.param_patt [concrete]", " %If.type: type = fn_type @If [concrete]", " %If: %If.type = struct_value () [concrete]", "}", "", "file {", " %If.decl: %If.type = fn_decl @If [concrete = constants.%If] {", " %b.param_patt: %pattern_type = value_param_pattern [concrete = constants.%b.param_patt]", " %b.patt: %pattern_type = at_binding_pattern b, %b.param_patt [concrete = constants.%b.patt]", " } {", " %b.param: bool = value_param call_param0", " %.loc8: type = type_literal bool [concrete = bool]", " %b: bool = wrapper_binding b, %b.param", " }", "}", "", "fn @If(%b.param: bool) {", "!entry:", " %b.ref: bool = name_ref b, %b", " if %b.ref br !if.then else br !if.else", "", "!if.then:", ... }, unified diff (- expected, + actual):
=== diff in expected elements 4 to 11 (1-based index):
%F.type: type = fn_type @F [concrete]
%empty_tuple.type: type = tuple_type () [concrete]
%F: %F.type = struct_value () [concrete]
- is equal to " %G.type: type = fn_type @G [concrete]"
- is equal to " %G: %G.type = struct_value () [concrete]"
%H.type: type = fn_type @H [concrete]
%H: %H.type = struct_value () [concrete]
%pattern_type: type = pattern_type bool [concrete]
=== diff in expected elements 37 to 44 (1-based index):
br !if.done
!if.else:
- is equal to " %G.ref: %G.type = name_ref G, file.%G.decl [concrete = constants.%G]"
- is equal to " %G.call: init %empty_tuple.type = call %G.ref()"
br !if.done
!if.done:
=== diff end
```
After:
```
Value of: testing::Value(SplitOutput(test_file.actual_stdout), testing::ElementsAreArray(test_file.expected_stdout))
Actual: false
Expected: true
unified diff (- expected, + actual):
=== diff in expected elements 4 to 11 (1-based index):
%F.type: type = fn_type @F [concrete]
%empty_tuple.type: type = tuple_type () [concrete]
%F: %F.type = struct_value () [concrete]
- %G.type: type = fn_type @G [concrete]
- %G: %G.type = struct_value () [concrete]
%H.type: type = fn_type @H [concrete]
%H: %H.type = struct_value () [concrete]
%pattern_type: type = pattern_type bool [concrete]
=== diff in expected elements 37 to 44 (1-based index):
br !if.done
!if.else:
- %G.ref: %G.type = name_ref G, file.%G.decl [concrete = constants.%G]
- %G.call: init %empty_tuple.type = call %G.ref()
br !if.done
!if.done:
=== diff end
```
Assisted-by: Gemini via Antigravity