@@ -653,97 +653,82 @@ inline ::testing::Matcher<const ::xls::Node*> TupleIndex(
653653// which communicate over channels (e.g., send and receive). Supported forms:
654654//
655655// m::Channel(/*name=*/"foo");
656- // m::Channel(/*id=*/42);
657- // m::Channel(ChannelKind::kPort);
656+ // m::Channel(ChannelKind::kStreaming);
658657// m::Channel(node->GetType());
659658// m::ChannelWithType("bits[32]");
660659//
661- class ChannelMatcher
662- : public ::testing::MatcherInterface<const ::xls::Channel*> {
660+ class ChannelMatcher : public ::testing::MatcherInterface<::xls::ChannelRef> {
663661 public:
664- ChannelMatcher (std::optional<int64_t > id,
665- std::optional<::testing::Matcher<std::string>> name,
662+ ChannelMatcher (std::optional<::testing::Matcher<std::string>> name,
666663 std::optional<ChannelKind> kind,
667664 std::optional<std::string_view> type_string)
668- : id_(id),
669- name_ (std::move(name)),
670- kind_(kind),
671- type_string_(type_string) {}
665+ : name_(std::move(name)), kind_(kind), type_string_(type_string) {}
672666
673- bool MatchAndExplain (const ::xls::Channel* channel,
667+ bool MatchAndExplain (::xls::ChannelRef channel,
674668 ::testing::MatchResultListener* listener) const override ;
675669
676670 void DescribeTo (::std::ostream* os) const override ;
677671
678672 protected:
679- std::optional<int64_t > id_;
680673 std::optional<::testing::Matcher<std::string>> name_;
681674 std::optional<ChannelKind> kind_;
682675 std::optional<std::string> type_string_;
683676};
684677
685- inline ::testing::Matcher<const ::xls::Channel*> Channel () {
686- return ::testing::MakeMatcher (new ::xls::op_matchers::ChannelMatcher (
687- std::nullopt , std::nullopt , std::nullopt , std::nullopt ));
688- }
689-
690- inline ::testing::Matcher<const ::xls::Channel*> Channel (
691- std::optional<int64_t > id) {
678+ inline ::testing::Matcher<::xls::ChannelRef> Channel () {
692679 return ::testing::MakeMatcher (new ::xls::op_matchers::ChannelMatcher (
693- id, std::nullopt , std::nullopt , std::nullopt ));
680+ std::nullopt , std::nullopt , std::nullopt ));
694681}
695682
696683template <typename T>
697- inline ::testing::Matcher<const ::xls::Channel*> Channel (
698- std::optional<int64_t > id, T name,
699- std::optional<ChannelKind> kind = std::nullopt ,
700- std::optional<const ::xls::Type*> type_ = std::nullopt )
684+ inline ::testing::Matcher<::xls::ChannelRef> Channel (
685+ T name, std::optional<ChannelKind> kind,
686+ std::optional<const ::xls::Type*> type_)
701687 requires(std::is_convertible_v<T, std::string>)
702688{
703689 return ::testing::MakeMatcher (new ::xls::op_matchers::ChannelMatcher (
704- id, std::string{name}, kind,
690+ std::string{name}, kind,
705691 type_.has_value () ? std::optional (type_.value ()->ToString ())
706692 : std::nullopt ));
707693}
708694
709695template <typename T>
710- inline ::testing::Matcher<const ::xls::Channel* > Channel (T name)
696+ inline ::testing::Matcher<::xls::ChannelRef > Channel (T name)
711697 requires(std::is_convertible_v<T, std::string_view>)
712698{
713699 return ::testing::MakeMatcher (new ::xls::op_matchers::ChannelMatcher (
714- std:: nullopt , internal::NameMatcherInternal (std::string_view{name}),
715- std::nullopt , std:: nullopt ));
700+ internal::NameMatcherInternal (std::string_view{name}), std:: nullopt ,
701+ std::nullopt ));
716702}
717703
718- inline ::testing::Matcher<const ::xls::Channel* > Channel (
704+ inline ::testing::Matcher<::xls::ChannelRef > Channel (
719705 const ::testing::Matcher<std::string>& matcher) {
720706 return ::testing::MakeMatcher (new ::xls::op_matchers::ChannelMatcher (
721- std:: nullopt , matcher, std::nullopt , std::nullopt ));
707+ matcher, std::nullopt , std::nullopt ));
722708}
723709
724- inline ::testing::Matcher<const ::xls::Channel* > Channel (ChannelKind kind) {
725- return ::testing::MakeMatcher (new :: xls::op_matchers::ChannelMatcher (
726- std:: nullopt , std::nullopt , kind, std::nullopt ));
710+ inline ::testing::Matcher<::xls::ChannelRef > Channel (ChannelKind kind) {
711+ return ::testing::MakeMatcher (
712+ new :: xls::op_matchers::ChannelMatcher ( std::nullopt , kind, std::nullopt ));
727713}
728714
729- inline ::testing::Matcher<const ::xls::Channel*> Channel (
730- const ::xls::Type* type_) {
715+ inline ::testing::Matcher<::xls::ChannelRef> Channel (const ::xls::Type* type_) {
731716 return ::testing::MakeMatcher (new ::xls::op_matchers::ChannelMatcher (
732- std::nullopt , std::nullopt , std:: nullopt , type_->ToString ()));
717+ std::nullopt , std::nullopt , type_->ToString ()));
733718}
734719
735- inline ::testing::Matcher<const ::xls::Channel* > ChannelWithType (
720+ inline ::testing::Matcher<::xls::ChannelRef > ChannelWithType (
736721 std::string_view type_string) {
737722 return ::testing::MakeMatcher (new ::xls::op_matchers::ChannelMatcher (
738- std::nullopt , std::nullopt , std:: nullopt , type_string));
723+ std::nullopt , std::nullopt , type_string));
739724}
740725
741726// Abstract base class for matchers of nodes which use channels.
742727class ChannelNodeMatcher : public NodeMatcher {
743728 public:
744729 ChannelNodeMatcher (
745730 Op op, absl::Span<const ::testing::Matcher<const Node*>> operands,
746- std::optional<::testing::Matcher<const ::xls::Channel* >> channel_matcher)
731+ std::optional<::testing::Matcher<::xls::ChannelRef >> channel_matcher)
747732 : NodeMatcher(op, operands),
748733 channel_matcher_ (std::move(channel_matcher)) {}
749734
@@ -752,50 +737,50 @@ class ChannelNodeMatcher : public NodeMatcher {
752737 void DescribeTo (::std::ostream* os) const override ;
753738
754739 private:
755- std::optional<::testing::Matcher<const ::xls::Channel* >> channel_matcher_;
740+ std::optional<::testing::Matcher<::xls::ChannelRef >> channel_matcher_;
756741};
757742
758743// Send matcher. Supported forms:
759744//
760745// EXPECT_THAT(foo, m::Send());
761- // EXPECT_THAT(foo, m::Send(m::Channel(42 )));
746+ // EXPECT_THAT(foo, m::Send(m::Channel("foo" )));
762747// EXPECT_THAT(foo, m::Send(/*token=*/m::Param(), /*data=*/m::Param(),
763- // m::Channel(42 )));
748+ // m::Channel("bar" )));
764749// EXPECT_THAT(foo, m::Send(/*token=*/m::Param(), /*data=*/m::Param(),
765750// /*predicate=*/m::Param(),
766- // m::Channel(42 )));
751+ // m::Channel("bazz" )));
767752class SendMatcher : public ChannelNodeMatcher {
768753 public:
769754 explicit SendMatcher (
770- std::optional<::testing::Matcher<const ::xls::Channel* >> channel_matcher)
755+ std::optional<::testing::Matcher<::xls::ChannelRef >> channel_matcher)
771756 : ChannelNodeMatcher(Op::kSend , {}, std::move(channel_matcher)) {}
772757 explicit SendMatcher (
773758 ::testing::Matcher<const Node*> token,
774759 ::testing::Matcher<const Node*> data,
775- std::optional<::testing::Matcher<const ::xls::Channel* >> channel_matcher)
760+ std::optional<::testing::Matcher<::xls::ChannelRef >> channel_matcher)
776761 : ChannelNodeMatcher(Op::kSend , {std::move (token), std::move (data)},
777762 std::move (channel_matcher)) {}
778763 explicit SendMatcher (
779764 ::testing::Matcher<const Node*> token,
780765 ::testing::Matcher<const Node*> data,
781766 ::testing::Matcher<const Node*> predicate,
782- std::optional<::testing::Matcher<const ::xls::Channel* >> channel_matcher)
767+ std::optional<::testing::Matcher<::xls::ChannelRef >> channel_matcher)
783768 : ChannelNodeMatcher(
784769 Op::kSend ,
785770 {std::move (token), std::move (data), std::move (predicate)},
786771 std::move (channel_matcher)) {}
787772};
788773
789774inline ::testing::Matcher<const ::xls::Node*> Send (
790- std::optional<::testing::Matcher<const ::xls::Channel* >> channel_matcher =
775+ std::optional<::testing::Matcher<::xls::ChannelRef >> channel_matcher =
791776 std::nullopt ) {
792777 return ::xls::op_matchers::SendMatcher (std::move (channel_matcher));
793778}
794779
795780inline ::testing::Matcher<const ::xls::Node*> Send (
796781 ::testing::Matcher<const ::xls::Node*> token,
797782 ::testing::Matcher<const Node*> data,
798- std::optional<::testing::Matcher<const ::xls::Channel* >> channel_matcher =
783+ std::optional<::testing::Matcher<::xls::ChannelRef >> channel_matcher =
799784 std::nullopt ) {
800785 return ::xls::op_matchers::SendMatcher (std::move (token), std::move (data),
801786 std::move (channel_matcher));
@@ -805,7 +790,7 @@ inline ::testing::Matcher<const ::xls::Node*> Send(
805790 ::testing::Matcher<const ::xls::Node*> token,
806791 ::testing::Matcher<const Node*> data,
807792 ::testing::Matcher<const Node*> predicate,
808- std::optional<::testing::Matcher<const ::xls::Channel* >> channel_matcher =
793+ std::optional<::testing::Matcher<::xls::ChannelRef >> channel_matcher =
809794 std::nullopt ) {
810795 return ::xls::op_matchers::SendMatcher (std::move (token), std::move (data),
811796 std::move (predicate),
@@ -822,31 +807,31 @@ inline ::testing::Matcher<const ::xls::Node*> Send(
822807class ReceiveMatcher : public ChannelNodeMatcher {
823808 public:
824809 explicit ReceiveMatcher (
825- std::optional<::testing::Matcher<const ::xls::Channel* >> channel_matcher)
810+ std::optional<::testing::Matcher<::xls::ChannelRef >> channel_matcher)
826811 : ChannelNodeMatcher(Op::kReceive , {}, std::move(channel_matcher)) {}
827812 explicit ReceiveMatcher (
828813 ::testing::Matcher<const Node*> token,
829- std::optional<::testing::Matcher<const ::xls::Channel* >> channel_matcher)
814+ std::optional<::testing::Matcher<::xls::ChannelRef >> channel_matcher)
830815 : ChannelNodeMatcher(Op::kReceive , {std::move (token)},
831816 std::move (channel_matcher)) {}
832817 explicit ReceiveMatcher (
833818 ::testing::Matcher<const Node*> token,
834819 ::testing::Matcher<const Node*> predicate,
835- std::optional<::testing::Matcher<const ::xls::Channel* >> channel_matcher)
820+ std::optional<::testing::Matcher<::xls::ChannelRef >> channel_matcher)
836821 : ChannelNodeMatcher(Op::kReceive ,
837822 {std::move (token), std::move (predicate)},
838823 std::move (channel_matcher)) {}
839824};
840825
841826inline ::testing::Matcher<const ::xls::Node*> Receive (
842- std::optional<::testing::Matcher<const ::xls::Channel* >> channel_matcher =
827+ std::optional<::testing::Matcher<::xls::ChannelRef >> channel_matcher =
843828 std::nullopt ) {
844829 return ::xls::op_matchers::ReceiveMatcher (std::move (channel_matcher));
845830}
846831
847832inline ::testing::Matcher<const ::xls::Node*> Receive (
848833 ::testing::Matcher<const Node*> token,
849- std::optional<::testing::Matcher<const ::xls::Channel* >> channel_matcher =
834+ std::optional<::testing::Matcher<::xls::ChannelRef >> channel_matcher =
850835 std::nullopt ) {
851836 return ::xls::op_matchers::ReceiveMatcher (std::move (token),
852837 std::move (channel_matcher));
@@ -855,7 +840,7 @@ inline ::testing::Matcher<const ::xls::Node*> Receive(
855840inline ::testing::Matcher<const ::xls::Node*> Receive (
856841 ::testing::Matcher<const Node*> token,
857842 ::testing::Matcher<const Node*> predicate,
858- ::testing::Matcher<const ::xls::Channel* > channel_matcher) {
843+ ::testing::Matcher<::xls::ChannelRef > channel_matcher) {
859844 return ::xls::op_matchers::ReceiveMatcher (
860845 std::move (token), std::move (predicate), channel_matcher);
861846}
0 commit comments