v2 / vlib / v / token / keywords_matcher_trie_test.v
13 lines · 12 sloc · 545 bytes · ef05fb1210fcc8cd4c3814627e35b12dcc5b335d
Raw
1import v.token
2
3fn test_new_keywords_matcher_from_array_trie_works() {
4 method_names := ['filter', 'clone', 'repeat', 'reverse', 'map', 'slice', 'sort', 'contains',
5 'index', 'last_index', 'wait', 'any', 'all', 'first', 'last', 'pop_left', 'pop']
6 matcher := token.new_keywords_matcher_from_array_trie(method_names)
7 for word in [method_names.first(), method_names.last(), 'something', 'another', 'x', 'y', '',
8 '---', '123', 'abc.def', 'xyz !@#'] {
9 res1 := matcher.find(word) != -1
10 res2 := word in method_names
11 assert res1 == res2
12 }
13}
14