pattern_binding_test_matchers.h 1.2 KB

123456789101112131415161718192021222324252627282930
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. #ifndef CARBON_TOOLCHAIN_SEMANTICS_NODES_PATTERN_BINDING_TEST_MATCHERS_H_
  5. #define CARBON_TOOLCHAIN_SEMANTICS_NODES_PATTERN_BINDING_TEST_MATCHERS_H_
  6. #include <gtest/gtest.h>
  7. #include "llvm/ADT/StringExtras.h"
  8. #include "toolchain/semantics/nodes/declared_name_test_matchers.h"
  9. #include "toolchain/semantics/nodes/pattern_binding.h"
  10. #include "toolchain/semantics/semantics_ir_for_test.h"
  11. namespace Carbon::Testing {
  12. inline auto PatternBinding(
  13. ::testing::Matcher<llvm::StringRef> name_matcher,
  14. ::testing::Matcher<Semantics::Expression> type_matcher)
  15. -> ::testing::Matcher<Semantics::PatternBinding> {
  16. return ::testing::AllOf(
  17. ::testing::Property("name", &Semantics::PatternBinding::name,
  18. DeclaredName(name_matcher)),
  19. ::testing::Property("type", &Semantics::PatternBinding::type,
  20. type_matcher));
  21. }
  22. } // namespace Carbon::Testing
  23. #endif // CARBON_TOOLCHAIN_SEMANTICS_NODES_PATTERN_BINDING_TEST_MATCHERS_H_