summaryrefslogtreecommitdiff
path: root/src/pattern_test.go
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2017-02-01 02:05:58 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2017-02-01 02:06:56 +0900
commitdd1f26522c965612cb4f55b44e700b8b85868b27 (patch)
treebf1199ad58f51393612697e8a9e5d6c85e82b250 /src/pattern_test.go
parent712b7b218815fe2368884515852327401311a215 (diff)
downloadfzf-dd1f26522c965612cb4f55b44e700b8b85868b27.tar.gz
Fix caching scheme when --exact is set and '-prefix is used
Diffstat (limited to 'src/pattern_test.go')
-rw-r--r--src/pattern_test.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/pattern_test.go b/src/pattern_test.go
index ea0082f3..9d66c798 100644
--- a/src/pattern_test.go
+++ b/src/pattern_test.go
@@ -186,3 +186,21 @@ func TestCacheKey(t *testing.T) {
test(true, "foo | bar !baz", "", false)
test(true, "| | | foo", "foo", true)
}
+
+func TestCacheable(t *testing.T) {
+ test := func(fuzzy bool, str string, cacheable bool) {
+ clearPatternCache()
+ pat := BuildPattern(fuzzy, algo.FuzzyMatchV2, true, CaseSmart, true, true, true, []Range{}, Delimiter{}, []rune(str))
+ if cacheable != pat.cacheable {
+ t.Errorf("Invalid Pattern.cacheable for \"%s\": %v (expected: %v)", str, pat.cacheable, cacheable)
+ }
+ }
+ test(true, "foo bar", true)
+ test(true, "foo 'bar", true)
+ test(true, "foo !bar", false)
+
+ test(false, "foo bar", true)
+ test(false, "foo '", true)
+ test(false, "foo 'bar", false)
+ test(false, "foo !bar", false)
+}