@@ -653,97 +653,82 @@ inline ::testing::Matcher<const ::xls::Node*> TupleIndex(
653
653
// which communicate over channels (e.g., send and receive). Supported forms:
654
654
//
655
655
// m::Channel(/*name=*/"foo");
656
- // m::Channel(/*id=*/42);
657
- // m::Channel(ChannelKind::kPort);
656
+ // m::Channel(ChannelKind::kStreaming);
658
657
// m::Channel(node->GetType());
659
658
// m::ChannelWithType("bits[32]");
660
659
//
661
- class ChannelMatcher
662
- : public ::testing::MatcherInterface<const ::xls::Channel*> {
660
+ class ChannelMatcher : public ::testing::MatcherInterface<::xls::ChannelRef> {
663
661
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,
666
663
std::optional<ChannelKind> kind,
667
664
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) {}
672
666
673
- bool MatchAndExplain (const ::xls::Channel* channel,
667
+ bool MatchAndExplain (::xls::ChannelRef channel,
674
668
::testing::MatchResultListener* listener) const override ;
675
669
676
670
void DescribeTo (::std::ostream* os) const override ;
677
671
678
672
protected:
679
- std::optional<int64_t > id_;
680
673
std::optional<::testing::Matcher<std::string>> name_;
681
674
std::optional<ChannelKind> kind_;
682
675
std::optional<std::string> type_string_;
683
676
};
684
677
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 () {
692
679
return ::testing::MakeMatcher (new ::xls::op_matchers::ChannelMatcher (
693
- id, std::nullopt, std::nullopt, std::nullopt));
680
+ std::nullopt, std::nullopt, std::nullopt));
694
681
}
695
682
696
683
template <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_)
701
687
requires(std::is_convertible_v<T, std::string>)
702
688
{
703
689
return ::testing::MakeMatcher (new ::xls::op_matchers::ChannelMatcher (
704
- id, std::string{name}, kind,
690
+ std::string{name}, kind,
705
691
type_.has_value () ? std::optional (type_.value ()->ToString ())
706
692
: std::nullopt));
707
693
}
708
694
709
695
template <typename T>
710
- inline ::testing::Matcher<const ::xls::Channel* > Channel (T name)
696
+ inline ::testing::Matcher<::xls::ChannelRef > Channel (T name)
711
697
requires(std::is_convertible_v<T, std::string_view>)
712
698
{
713
699
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));
716
702
}
717
703
718
- inline ::testing::Matcher<const ::xls::Channel* > Channel (
704
+ inline ::testing::Matcher<::xls::ChannelRef > Channel (
719
705
const ::testing::Matcher<std::string>& matcher) {
720
706
return ::testing::MakeMatcher (new ::xls::op_matchers::ChannelMatcher (
721
- std::nullopt, matcher, std::nullopt, std::nullopt));
707
+ matcher, std::nullopt, std::nullopt));
722
708
}
723
709
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));
727
713
}
728
714
729
- inline ::testing::Matcher<const ::xls::Channel*> Channel (
730
- const ::xls::Type* type_) {
715
+ inline ::testing::Matcher<::xls::ChannelRef> Channel (const ::xls::Type* type_) {
731
716
return ::testing::MakeMatcher (new ::xls::op_matchers::ChannelMatcher (
732
- std::nullopt, std::nullopt, std::nullopt, type_->ToString ()));
717
+ std::nullopt, std::nullopt, type_->ToString ()));
733
718
}
734
719
735
- inline ::testing::Matcher<const ::xls::Channel* > ChannelWithType (
720
+ inline ::testing::Matcher<::xls::ChannelRef > ChannelWithType (
736
721
std::string_view type_string) {
737
722
return ::testing::MakeMatcher (new ::xls::op_matchers::ChannelMatcher (
738
- std::nullopt, std::nullopt, std::nullopt, type_string));
723
+ std::nullopt, std::nullopt, type_string));
739
724
}
740
725
741
726
// Abstract base class for matchers of nodes which use channels.
742
727
class ChannelNodeMatcher : public NodeMatcher {
743
728
public:
744
729
ChannelNodeMatcher (
745
730
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)
747
732
: NodeMatcher(op, operands),
748
733
channel_matcher_ (std::move(channel_matcher)) {}
749
734
@@ -752,50 +737,50 @@ class ChannelNodeMatcher : public NodeMatcher {
752
737
void DescribeTo (::std::ostream* os) const override ;
753
738
754
739
private:
755
- std::optional<::testing::Matcher<const ::xls::Channel* >> channel_matcher_;
740
+ std::optional<::testing::Matcher<::xls::ChannelRef >> channel_matcher_;
756
741
};
757
742
758
743
// Send matcher. Supported forms:
759
744
//
760
745
// EXPECT_THAT(foo, m::Send());
761
- // EXPECT_THAT(foo, m::Send(m::Channel(42 )));
746
+ // EXPECT_THAT(foo, m::Send(m::Channel("foo" )));
762
747
// EXPECT_THAT(foo, m::Send(/*token=*/m::Param(), /*data=*/m::Param(),
763
- // m::Channel(42 )));
748
+ // m::Channel("bar" )));
764
749
// EXPECT_THAT(foo, m::Send(/*token=*/m::Param(), /*data=*/m::Param(),
765
750
// /*predicate=*/m::Param(),
766
- // m::Channel(42 )));
751
+ // m::Channel("bazz" )));
767
752
class SendMatcher : public ChannelNodeMatcher {
768
753
public:
769
754
explicit SendMatcher (
770
- std::optional<::testing::Matcher<const ::xls::Channel* >> channel_matcher)
755
+ std::optional<::testing::Matcher<::xls::ChannelRef >> channel_matcher)
771
756
: ChannelNodeMatcher(Op::kSend , {}, std::move(channel_matcher)) {}
772
757
explicit SendMatcher (
773
758
::testing::Matcher<const Node*> token,
774
759
::testing::Matcher<const Node*> data,
775
- std::optional<::testing::Matcher<const ::xls::Channel* >> channel_matcher)
760
+ std::optional<::testing::Matcher<::xls::ChannelRef >> channel_matcher)
776
761
: ChannelNodeMatcher(Op::kSend , {std::move (token), std::move (data)},
777
762
std::move (channel_matcher)) {}
778
763
explicit SendMatcher (
779
764
::testing::Matcher<const Node*> token,
780
765
::testing::Matcher<const Node*> data,
781
766
::testing::Matcher<const Node*> predicate,
782
- std::optional<::testing::Matcher<const ::xls::Channel* >> channel_matcher)
767
+ std::optional<::testing::Matcher<::xls::ChannelRef >> channel_matcher)
783
768
: ChannelNodeMatcher(
784
769
Op::kSend ,
785
770
{std::move (token), std::move (data), std::move (predicate)},
786
771
std::move (channel_matcher)) {}
787
772
};
788
773
789
774
inline ::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 =
791
776
std::nullopt) {
792
777
return ::xls::op_matchers::SendMatcher (std::move (channel_matcher));
793
778
}
794
779
795
780
inline ::testing::Matcher<const ::xls::Node*> Send (
796
781
::testing::Matcher<const ::xls::Node*> token,
797
782
::testing::Matcher<const Node*> data,
798
- std::optional<::testing::Matcher<const ::xls::Channel* >> channel_matcher =
783
+ std::optional<::testing::Matcher<::xls::ChannelRef >> channel_matcher =
799
784
std::nullopt) {
800
785
return ::xls::op_matchers::SendMatcher (std::move (token), std::move (data),
801
786
std::move (channel_matcher));
@@ -805,7 +790,7 @@ inline ::testing::Matcher<const ::xls::Node*> Send(
805
790
::testing::Matcher<const ::xls::Node*> token,
806
791
::testing::Matcher<const Node*> data,
807
792
::testing::Matcher<const Node*> predicate,
808
- std::optional<::testing::Matcher<const ::xls::Channel* >> channel_matcher =
793
+ std::optional<::testing::Matcher<::xls::ChannelRef >> channel_matcher =
809
794
std::nullopt) {
810
795
return ::xls::op_matchers::SendMatcher (std::move (token), std::move (data),
811
796
std::move (predicate),
@@ -822,31 +807,31 @@ inline ::testing::Matcher<const ::xls::Node*> Send(
822
807
class ReceiveMatcher : public ChannelNodeMatcher {
823
808
public:
824
809
explicit ReceiveMatcher (
825
- std::optional<::testing::Matcher<const ::xls::Channel* >> channel_matcher)
810
+ std::optional<::testing::Matcher<::xls::ChannelRef >> channel_matcher)
826
811
: ChannelNodeMatcher(Op::kReceive , {}, std::move(channel_matcher)) {}
827
812
explicit ReceiveMatcher (
828
813
::testing::Matcher<const Node*> token,
829
- std::optional<::testing::Matcher<const ::xls::Channel* >> channel_matcher)
814
+ std::optional<::testing::Matcher<::xls::ChannelRef >> channel_matcher)
830
815
: ChannelNodeMatcher(Op::kReceive , {std::move (token)},
831
816
std::move (channel_matcher)) {}
832
817
explicit ReceiveMatcher (
833
818
::testing::Matcher<const Node*> token,
834
819
::testing::Matcher<const Node*> predicate,
835
- std::optional<::testing::Matcher<const ::xls::Channel* >> channel_matcher)
820
+ std::optional<::testing::Matcher<::xls::ChannelRef >> channel_matcher)
836
821
: ChannelNodeMatcher(Op::kReceive ,
837
822
{std::move (token), std::move (predicate)},
838
823
std::move (channel_matcher)) {}
839
824
};
840
825
841
826
inline ::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 =
843
828
std::nullopt) {
844
829
return ::xls::op_matchers::ReceiveMatcher (std::move (channel_matcher));
845
830
}
846
831
847
832
inline ::testing::Matcher<const ::xls::Node*> Receive (
848
833
::testing::Matcher<const Node*> token,
849
- std::optional<::testing::Matcher<const ::xls::Channel* >> channel_matcher =
834
+ std::optional<::testing::Matcher<::xls::ChannelRef >> channel_matcher =
850
835
std::nullopt) {
851
836
return ::xls::op_matchers::ReceiveMatcher (std::move (token),
852
837
std::move (channel_matcher));
@@ -855,7 +840,7 @@ inline ::testing::Matcher<const ::xls::Node*> Receive(
855
840
inline ::testing::Matcher<const ::xls::Node*> Receive (
856
841
::testing::Matcher<const Node*> token,
857
842
::testing::Matcher<const Node*> predicate,
858
- ::testing::Matcher<const ::xls::Channel* > channel_matcher) {
843
+ ::testing::Matcher<::xls::ChannelRef > channel_matcher) {
859
844
return ::xls::op_matchers::ReceiveMatcher (
860
845
std::move (token), std::move (predicate), channel_matcher);
861
846
}
0 commit comments