Debian Codegraph @

internal/flow/lattice_test.go

raw symbols SCIP
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 flow_testscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow_test`/
6
7 import (
8 "testingscip-go gomod github.com/golang/go/src go1.25.0 testing/"
9
10 "golang.org/x/tools/internal/flowscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/"
11 )
12
13 type nodeSetscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow_test`/nodeSet# uint64
14
15 type nodeSetUnionscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow_test`/nodeSetUnion# struct{}
16
17 func (nodeSetUnionscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow_test`/nodeSetUnion#) Identscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow_test`/nodeSetUnion#Ident().() nodeSetscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow_test`/nodeSet# { return 0 }
18 func (nodeSetUnionscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow_test`/nodeSetUnion#) Equalsscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow_test`/nodeSetUnion#Equals().(a, b nodeSetscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow_test`/nodeSet#) bool { return a == b }
19 func (nodeSetUnionscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow_test`/nodeSetUnion#) Mergescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow_test`/nodeSetUnion#Merge().(a, b nodeSetscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow_test`/nodeSet#) nodeSetscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow_test`/nodeSet# { return a | b }
20
21 var _ flowscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/.Semilatticescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/Semilattice#[nodeSetscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow_test`/nodeSet#] = nodeSetUnionscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow_test`/nodeSetUnion#{}
22
23 func setscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow_test`/set().(nodes ...int) nodeSetscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow_test`/nodeSet# {
24 var out nodeSetscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow_test`/nodeSet#
25 for _, node := range nodes {
26 if node < 0 || node >= 64 {
27 panic("NodeID out of range")
28 }
29 out |= 1 << node
30 }
31 return out
32 }
33
34 func TestMapLattice_Trivialscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow_test`/TestMapLattice_Trivial().(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#) {
35 l := flowscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/.MapLatticescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/MapLattice#[int, nodeSetscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow_test`/nodeSet#, nodeSetUnionscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow_test`/nodeSetUnion#]{}
36
37 // Case 1: a is empty, b is not
38 a := map[int]nodeSetscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow_test`/nodeSet#{}
39 b := map[int]nodeSetscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow_test`/nodeSet#{1: setscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow_test`/set().(1)}
40
41 got := l.Mergescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/MapLattice#Merge().(a, b)
42 if !l.Equalsscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/MapLattice#Equals().(got, b) {
43 t.Errorfscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Errorf().("Merge(empty, b) = %v, want %v", got, b)
44 }
45
46 // Case 2: b is empty, a is not
47 got = l.Mergescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/MapLattice#Merge().(b, a)
48 if !l.Equalsscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/MapLattice#Equals().(got, b) {
49 t.Errorfscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Errorf().("Merge(b, empty) = %v, want %v", got, b)
50 }
51 }
52
53 func TestMapLattice_Mergescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow_test`/TestMapLattice_Merge().(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#) {
54 l := flowscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/.MapLatticescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/MapLattice#[int, nodeSetscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow_test`/nodeSet#, nodeSetUnionscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow_test`/nodeSetUnion#]{}
55
56 a := map[int]nodeSetscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow_test`/nodeSet#{
57 1: setscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow_test`/set().(1), // Only in a
58 2: setscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow_test`/set().(2), // In both
59 }
60 b := map[int]nodeSetscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow_test`/nodeSet#{
61 2: setscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow_test`/set().(3), // In both
62 3: setscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow_test`/set().(4), // Only in b
63 }
64
65 want := map[int]nodeSetscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow_test`/nodeSet#{
66 1: setscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow_test`/set().(1),
67 2: setscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow_test`/set().(2, 3),
68 3: setscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow_test`/set().(4),
69 }
70
71 got := l.Mergescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/MapLattice#Merge().(a, b)
72 if !l.Equalsscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/flow`/MapLattice#Equals().(got, want) {
73 t.Errorfscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Errorf().("Merge(a, b) = %v, want %v", got, want)
74 }
75 }