| skipped 44 lines |
45 | 45 | | assertMatch(t, fn, false, forward, "fooBarbaz1", "oBZ", 2, 9, |
46 | 46 | | scoreMatch*3+bonusCamel123+scoreGapStart+scoreGapExtension*3) |
47 | 47 | | assertMatch(t, fn, false, forward, "foo bar baz", "fbb", 0, 9, |
48 | | - | scoreMatch*3+bonusBoundaryWhite*bonusFirstCharMultiplier+ |
49 | | - | bonusBoundaryWhite*2+2*scoreGapStart+4*scoreGapExtension) |
| 48 | + | scoreMatch*3+int(bonusBoundaryWhite)*bonusFirstCharMultiplier+ |
| 49 | + | int(bonusBoundaryWhite)*2+2*scoreGapStart+4*scoreGapExtension) |
50 | 50 | | assertMatch(t, fn, false, forward, "/AutomatorDocument.icns", "rdoc", 9, 13, |
51 | 51 | | scoreMatch*4+bonusCamel123+bonusConsecutive*2) |
52 | 52 | | assertMatch(t, fn, false, forward, "/man1/zshcompctl.1", "zshc", 6, 10, |
53 | | - | scoreMatch*4+bonusBoundaryDelimiter*bonusFirstCharMultiplier+bonusBoundaryDelimiter*3) |
| 53 | + | scoreMatch*4+int(bonusBoundaryDelimiter)*bonusFirstCharMultiplier+int(bonusBoundaryDelimiter)*3) |
54 | 54 | | assertMatch(t, fn, false, forward, "/.oh-my-zsh/cache", "zshc", 8, 13, |
55 | | - | scoreMatch*4+bonusBoundary*bonusFirstCharMultiplier+bonusBoundary*2+scoreGapStart+bonusBoundaryDelimiter) |
| 55 | + | scoreMatch*4+bonusBoundary*bonusFirstCharMultiplier+bonusBoundary*2+scoreGapStart+int(bonusBoundaryDelimiter)) |
56 | 56 | | assertMatch(t, fn, false, forward, "ab0123 456", "12356", 3, 10, |
57 | 57 | | scoreMatch*5+bonusConsecutive*3+scoreGapStart+scoreGapExtension) |
58 | 58 | | assertMatch(t, fn, false, forward, "abc123 456", "12356", 3, 10, |
59 | 59 | | scoreMatch*5+bonusCamel123*bonusFirstCharMultiplier+bonusCamel123*2+bonusConsecutive+scoreGapStart+scoreGapExtension) |
60 | 60 | | assertMatch(t, fn, false, forward, "foo/bar/baz", "fbb", 0, 9, |
61 | | - | scoreMatch*3+bonusBoundaryWhite*bonusFirstCharMultiplier+ |
62 | | - | bonusBoundaryDelimiter*2+2*scoreGapStart+4*scoreGapExtension) |
| 61 | + | scoreMatch*3+int(bonusBoundaryWhite)*bonusFirstCharMultiplier+ |
| 62 | + | int(bonusBoundaryDelimiter)*2+2*scoreGapStart+4*scoreGapExtension) |
63 | 63 | | assertMatch(t, fn, false, forward, "fooBarBaz", "fbb", 0, 7, |
64 | | - | scoreMatch*3+bonusBoundaryWhite*bonusFirstCharMultiplier+ |
| 64 | + | scoreMatch*3+int(bonusBoundaryWhite)*bonusFirstCharMultiplier+ |
65 | 65 | | bonusCamel123*2+2*scoreGapStart+2*scoreGapExtension) |
66 | 66 | | assertMatch(t, fn, false, forward, "foo barbaz", "fbb", 0, 8, |
67 | | - | scoreMatch*3+bonusBoundaryWhite*bonusFirstCharMultiplier+bonusBoundaryWhite+ |
| 67 | + | scoreMatch*3+int(bonusBoundaryWhite)*bonusFirstCharMultiplier+int(bonusBoundaryWhite)+ |
68 | 68 | | scoreGapStart*2+scoreGapExtension*3) |
69 | 69 | | assertMatch(t, fn, false, forward, "fooBar Baz", "foob", 0, 4, |
70 | | - | scoreMatch*4+bonusBoundaryWhite*bonusFirstCharMultiplier+bonusBoundaryWhite*3) |
| 70 | + | scoreMatch*4+int(bonusBoundaryWhite)*bonusFirstCharMultiplier+int(bonusBoundaryWhite)*3) |
71 | 71 | | assertMatch(t, fn, false, forward, "xFoo-Bar Baz", "foo-b", 1, 6, |
72 | 72 | | scoreMatch*5+bonusCamel123*bonusFirstCharMultiplier+bonusCamel123*2+ |
73 | 73 | | bonusNonWord+bonusBoundary) |
| skipped 1 lines |
75 | 75 | | assertMatch(t, fn, true, forward, "fooBarbaz", "oBz", 2, 9, |
76 | 76 | | scoreMatch*3+bonusCamel123+scoreGapStart+scoreGapExtension*3) |
77 | 77 | | assertMatch(t, fn, true, forward, "Foo/Bar/Baz", "FBB", 0, 9, |
78 | | - | scoreMatch*3+bonusBoundaryWhite*bonusFirstCharMultiplier+bonusBoundaryDelimiter*2+ |
| 78 | + | scoreMatch*3+int(bonusBoundaryWhite)*bonusFirstCharMultiplier+int(bonusBoundaryDelimiter)*2+ |
79 | 79 | | scoreGapStart*2+scoreGapExtension*4) |
80 | 80 | | assertMatch(t, fn, true, forward, "FooBarBaz", "FBB", 0, 7, |
81 | | - | scoreMatch*3+bonusBoundaryWhite*bonusFirstCharMultiplier+bonusCamel123*2+ |
| 81 | + | scoreMatch*3+int(bonusBoundaryWhite)*bonusFirstCharMultiplier+bonusCamel123*2+ |
82 | 82 | | scoreGapStart*2+scoreGapExtension*2) |
83 | 83 | | assertMatch(t, fn, true, forward, "FooBar Baz", "FooB", 0, 4, |
84 | | - | scoreMatch*4+bonusBoundaryWhite*bonusFirstCharMultiplier+bonusBoundaryWhite*2+ |
85 | | - | util.Max(bonusCamel123, bonusBoundaryWhite)) |
| 84 | + | scoreMatch*4+int(bonusBoundaryWhite)*bonusFirstCharMultiplier+int(bonusBoundaryWhite)*2+ |
| 85 | + | util.Max(bonusCamel123, int(bonusBoundaryWhite))) |
86 | 86 | | |
87 | 87 | | // Consecutive bonus updated |
88 | 88 | | assertMatch(t, fn, true, forward, "foo-bar", "o-ba", 2, 6, |
| skipped 9 lines |
98 | 98 | | |
99 | 99 | | func TestFuzzyMatchBackward(t *testing.T) { |
100 | 100 | | assertMatch(t, FuzzyMatchV1, false, true, "foobar fb", "fb", 0, 4, |
101 | | - | scoreMatch*2+bonusBoundaryWhite*bonusFirstCharMultiplier+ |
| 101 | + | scoreMatch*2+int(bonusBoundaryWhite)*bonusFirstCharMultiplier+ |
102 | 102 | | scoreGapStart+scoreGapExtension) |
103 | 103 | | assertMatch(t, FuzzyMatchV1, false, false, "foobar fb", "fb", 7, 9, |
104 | | - | scoreMatch*2+bonusBoundaryWhite*bonusFirstCharMultiplier+bonusBoundaryWhite) |
| 104 | + | scoreMatch*2+int(bonusBoundaryWhite)*bonusFirstCharMultiplier+int(bonusBoundaryWhite)) |
105 | 105 | | } |
106 | 106 | | |
107 | 107 | | func TestExactMatchNaive(t *testing.T) { |
| skipped 6 lines |
114 | 114 | | assertMatch(t, ExactMatchNaive, false, dir, "/AutomatorDocument.icns", "rdoc", 9, 13, |
115 | 115 | | scoreMatch*4+bonusCamel123+bonusConsecutive*2) |
116 | 116 | | assertMatch(t, ExactMatchNaive, false, dir, "/man1/zshcompctl.1", "zshc", 6, 10, |
117 | | - | scoreMatch*4+bonusBoundaryDelimiter*(bonusFirstCharMultiplier+3)) |
| 117 | + | scoreMatch*4+int(bonusBoundaryDelimiter)*(bonusFirstCharMultiplier+3)) |
118 | 118 | | assertMatch(t, ExactMatchNaive, false, dir, "/.oh-my-zsh/cache", "zsh/c", 8, 13, |
119 | | - | scoreMatch*5+bonusBoundary*(bonusFirstCharMultiplier+3)+bonusBoundaryDelimiter) |
| 119 | + | scoreMatch*5+bonusBoundary*(bonusFirstCharMultiplier+3)+int(bonusBoundaryDelimiter)) |
120 | 120 | | } |
121 | 121 | | } |
122 | 122 | | |
| skipped 5 lines |
128 | 128 | | } |
129 | 129 | | |
130 | 130 | | func TestPrefixMatch(t *testing.T) { |
131 | | - | score := scoreMatch*3 + bonusBoundaryWhite*bonusFirstCharMultiplier + bonusBoundaryWhite*2 |
| 131 | + | score := scoreMatch*3 + int(bonusBoundaryWhite)*bonusFirstCharMultiplier + int(bonusBoundaryWhite)*2 |
132 | 132 | | |
133 | 133 | | for _, dir := range []bool{true, false} { |
134 | 134 | | assertMatch(t, PrefixMatch, true, dir, "fooBarbaz", "Foo", -1, -1, 0) |
| skipped 24 lines |
159 | 159 | | |
160 | 160 | | // Only when the pattern doesn't end with a space |
161 | 161 | | assertMatch(t, SuffixMatch, false, dir, "fooBarbaz ", "baz ", 6, 10, |
162 | | - | scoreMatch*4+bonusConsecutive*2+bonusBoundaryWhite) |
| 162 | + | scoreMatch*4+bonusConsecutive*2+int(bonusBoundaryWhite)) |
163 | 163 | | } |
164 | 164 | | } |
165 | 165 | | |
| skipped 34 lines |