Debian Codegraph @

match_test.go

raw symbols SCIP
1 package mainscip-go gomod github.com/cespare/reflex . `github.com/cespare/reflex`/
2
3 import (
4 "regexpscip-go gomod github.com/golang/go/src go1.24.0 regexp/"
5 "testingscip-go gomod github.com/golang/go/src go1.24.0 testing/"
6 )
7
8 func TestMatchersscip-go gomod github.com/cespare/reflex . `github.com/cespare/reflex`/TestMatchers().(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) {
9 var (
10 glob = &globMatcherscip-go gomod github.com/cespare/reflex . `github.com/cespare/reflex`/globMatcher#{globscip-go gomod github.com/cespare/reflex . `github.com/cespare/reflex`/globMatcher#glob.: "foo*"}
11 globInv = &globMatcherscip-go gomod github.com/cespare/reflex . `github.com/cespare/reflex`/globMatcher#{globscip-go gomod github.com/cespare/reflex . `github.com/cespare/reflex`/globMatcher#glob.: "foo*", inversescip-go gomod github.com/cespare/reflex . `github.com/cespare/reflex`/globMatcher#inverse.: true}
12
13 regex = newRegexMatcherscip-go gomod github.com/cespare/reflex . `github.com/cespare/reflex`/newRegexMatcher().(regexpscip-go gomod github.com/golang/go/src go1.24.0 regexp/.MustCompilescip-go gomod github.com/golang/go/src go1.24.0 regexp/MustCompile().("foo.*"), false)
14 regexInv = newRegexMatcherscip-go gomod github.com/cespare/reflex . `github.com/cespare/reflex`/newRegexMatcher().(regexpscip-go gomod github.com/golang/go/src go1.24.0 regexp/.MustCompilescip-go gomod github.com/golang/go/src go1.24.0 regexp/MustCompile().("foo.*"), true)
15
16 multi = multiMatcherscip-go gomod github.com/cespare/reflex . `github.com/cespare/reflex`/multiMatcher#{
17 newRegexMatcherscip-go gomod github.com/cespare/reflex . `github.com/cespare/reflex`/newRegexMatcher().(regexpscip-go gomod github.com/golang/go/src go1.24.0 regexp/.MustCompilescip-go gomod github.com/golang/go/src go1.24.0 regexp/MustCompile().("foo"), false),
18 newRegexMatcherscip-go gomod github.com/cespare/reflex . `github.com/cespare/reflex`/newRegexMatcher().(regexpscip-go gomod github.com/golang/go/src go1.24.0 regexp/.MustCompilescip-go gomod github.com/golang/go/src go1.24.0 regexp/MustCompile().(`\.go$`), false),
19 newRegexMatcherscip-go gomod github.com/cespare/reflex . `github.com/cespare/reflex`/newRegexMatcher().(regexpscip-go gomod github.com/golang/go/src go1.24.0 regexp/.MustCompilescip-go gomod github.com/golang/go/src go1.24.0 regexp/MustCompile().("foobar"), true),
20 }
21 )
22 for _, tt := range []struct {
23 m Matcherscip-go gomod github.com/cespare/reflex . `github.com/cespare/reflex`/Matcher#
24 s string
25 want bool
26 }{
27 {glob, "foo", true},
28 {glob, "foobar", true},
29 {glob, "bar", false},
30 {globInv, "foo", false},
31 {globInv, "foobar", false},
32 {globInv, "bar", true},
33
34 {regex, "foo", true},
35 {regex, "foobar", true},
36 {regex, "bar", false},
37 {regexInv, "foo", false},
38 {regexInv, "foobar", false},
39 {regexInv, "bar", true},
40
41 {multi, "foo.go", true},
42 {multi, "foo/bar.go", true},
43 {multi, "foobar/blah.go", false},
44 } {
45 if got := tt.m.Matchscip-go gomod github.com/cespare/reflex . `github.com/cespare/reflex`/Matcher#Match.(tt.s); got != tt.want {
46 t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("(%v).Match(%q): got %t; want %t",
47 tt.m, tt.s, got, tt.want)
48 }
49 }
50 }
51
52 func TestExcludePrefixscip-go gomod github.com/cespare/reflex . `github.com/cespare/reflex`/TestExcludePrefix().(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) {
53 m := newRegexMatcherscip-go gomod github.com/cespare/reflex . `github.com/cespare/reflex`/newRegexMatcher().(regexpscip-go gomod github.com/golang/go/src go1.24.0 regexp/.MustCompilescip-go gomod github.com/golang/go/src go1.24.0 regexp/MustCompile().("foo"), false)
54 if m.ExcludePrefixscip-go gomod github.com/cespare/reflex . `github.com/cespare/reflex`/regexMatcher#ExcludePrefix().("bar") {
55 t.Errorscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Error().("m.ExcludePrefix gave true for a non-inverted matcher")
56 }
57
58 for _, tt := range []struct {
59 re string
60 prefix string
61 want bool
62 }{
63 {"foo", "foo", true},
64 {"((foo{3,4})|abc*)+|foo", "foo", true},
65 {"foo$", "foo", false},
66 {`foo\b`, "foo", false},
67 {`(foo\b)|(baz$)`, "foo", false},
68 } {
69 m := newRegexMatcherscip-go gomod github.com/cespare/reflex . `github.com/cespare/reflex`/newRegexMatcher().(regexpscip-go gomod github.com/golang/go/src go1.24.0 regexp/.MustCompilescip-go gomod github.com/golang/go/src go1.24.0 regexp/MustCompile().(tt.re), true)
70 if got := m.ExcludePrefixscip-go gomod github.com/cespare/reflex . `github.com/cespare/reflex`/regexMatcher#ExcludePrefix().(tt.prefix); got != tt.want {
71 t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("(%v).ExcludePrefix(%q): got %t; want %t",
72 m, tt.prefix, got, tt.want)
73 }
74 }
75 }
76
77 func TestDefaultExcludesscip-go gomod github.com/cespare/reflex . `github.com/cespare/reflex`/TestDefaultExcludes().(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) {
78 for _, tt := range []struct {
79 name string
80 want bool
81 }{
82 {".git/HEAD", false},
83 {"foo.git", true},
84 {"foo/bar.git", true},
85 {"foo/bar/.git/HEAD", false},
86 {"foo~", false},
87 {"foo/bar~", false},
88 {"~foo", true},
89 {"foo~bar", true},
90 {"foo.swp", false},
91 {"foo.swp.bar", true},
92 {"foo/bar.swp", false},
93 {"foo.#123", false},
94 {"foo#123", true},
95 {"foo/bar.#123", false},
96 {"#foo#", false},
97 {"foo/#bar#", false},
98 {".DS_Store", false},
99 {"foo/.DS_Store", false},
100 } {
101 if got := defaultExcludeMatcherscip-go gomod github.com/cespare/reflex . `github.com/cespare/reflex`/defaultExcludeMatcher..Matchscip-go gomod github.com/cespare/reflex . `github.com/cespare/reflex`/multiMatcher#Match().(tt.name); got != tt.want {
102 if got {
103 t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("%q was excluded by the default excludes matcher", tt.name)
104 } else {
105 t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("%q was not excluded by the default excludes matcher", tt.name)
106 }
107 }
108 }
109 }