| 1 | // Copyright 2026 The Go Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style |
| 3 | // license that can be found in the LICENSE file. |
| 4 | |
| 5 | package graphscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/graph`/ |
| 6 | |
| 7 | import ( |
| 8 | "mapsscip-go gomod github.com/golang/go/src go1.25.0 maps/" |
| 9 | "testingscip-go gomod github.com/golang/go/src go1.25.0 testing/" |
| 10 | ) |
| 11 | |
| 12 | func TestReachablescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/graph`/TestReachable().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) { |
| 13 | g := stringGraphscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/graph`/stringGraph#{ |
| 14 | "A": {"B", "C"}, |
| 15 | "B": {"D"}, |
| 16 | "C": {"D"}, |
| 17 | "D": {}, |
| 18 | "E": {"F"}, |
| 19 | "F": {}, |
| 20 | // Cycle |
| 21 | "c1": {"c2"}, |
| 22 | "c2": {"c3"}, |
| 23 | "c3": {"c2", "c4"}, |
| 24 | "c4": {}, |
| 25 | // Self-cycle |
| 26 | "sc1": {"sc1", "sc2"}, |
| 27 | "sc2": {}, |
| 28 | } |
| 29 | |
| 30 | got := Reachablescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/graph`/Reachable().(g, "A") |
| 31 | want := map[string]bool{"A": true, "B": true, "C": true, "D": true} |
| 32 | if !mapsscip-go gomod github.com/golang/go/src go1.25.0 maps/.Equalscip-go gomod github.com/golang/go/src go1.25.0 maps/Equal().(got, want) { |
| 33 | t.Errorfscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Errorf().("Reachable(A) = %v, want %v", got, want) |
| 34 | } |
| 35 | |
| 36 | got = Reachablescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/graph`/Reachable().(g, "E") |
| 37 | want = map[string]bool{"E": true, "F": true} |
| 38 | if !mapsscip-go gomod github.com/golang/go/src go1.25.0 maps/.Equalscip-go gomod github.com/golang/go/src go1.25.0 maps/Equal().(got, want) { |
| 39 | t.Errorfscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Errorf().("Reachable(E) = %v, want %v", got, want) |
| 40 | } |
| 41 | |
| 42 | got = Reachablescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/graph`/Reachable().(g, "c1") |
| 43 | want = map[string]bool{"c1": true, "c2": true, "c3": true, "c4": true} |
| 44 | if !mapsscip-go gomod github.com/golang/go/src go1.25.0 maps/.Equalscip-go gomod github.com/golang/go/src go1.25.0 maps/Equal().(got, want) { |
| 45 | t.Errorfscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Errorf().("Reachable(c1) = %v, want %v", got, want) |
| 46 | } |
| 47 | |
| 48 | got = Reachablescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/graph`/Reachable().(g, "sc1") |
| 49 | want = map[string]bool{"sc1": true, "sc2": true} |
| 50 | if !mapsscip-go gomod github.com/golang/go/src go1.25.0 maps/.Equalscip-go gomod github.com/golang/go/src go1.25.0 maps/Equal().(got, want) { |
| 51 | t.Errorfscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Errorf().("Reachable(sc1) = %v, want %v", got, want) |
| 52 | } |
| 53 | } |