robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
551cc3a2a3
master
1" Test glob2regpat() 2 3source vim9.vim 4 5func Test_glob2regpat_invalid () 6if has ( 'float' ) 7call assert_equal ( '^1\.33$' , glob2regpat ( 1.33 )) 8call CheckDefExecAndScriptFailure ([ 'echo glob2regpat(1.33)' ], 'E806:' ) 9endif 10call assert_fails ( 'call glob2regpat("}")' , 'E219:' ) 11call assert_fails ( 'call glob2regpat("{")' , 'E220:' ) 12endfunc 13 14func Test_glob2regpat_valid () 15call assert_equal ( '^foo\.' , glob2regpat ( 'foo.*' )) 16call assert_equal ( '^foo.$' , 'foo?' ->glob2regpat ()) 17call assert_equal ( '\.vim$' , glob2regpat ( '*.vim' )) 18call assert_equal ( '^[abc]$' , glob2regpat ( '[abc]' )) 19call assert_equal ( '^foo bar$' , glob2regpat ( 'foo\ bar' )) 20call assert_equal ( '^foo,bar$' , glob2regpat ( 'foo,bar' )) 21call assert_equal ( '^\(foo\|bar\)$' , glob2regpat ( '{foo,bar}' )) 22call assert_equal ( '.*' , glob2regpat ( '**' )) 23 24if exists ( '+shellslash' ) 25call assert_equal ( '^foo[\/].$' , glob2regpat ( 'foo\?' )) 26call assert_equal ( '^\(foo[\/]\|bar\|foobar\)$' , glob2regpat ( '{foo\,bar,foobar}' )) 27call assert_equal ( '^[\/]\(foo\|bar[\/]\)$' , glob2regpat ( '\{foo,bar\}' )) 28call assert_equal ( '^[\/][\/]\(foo\|bar[\/][\/]\)$' , glob2regpat ( '\\{foo,bar\\}' )) 29else 30call assert_equal ( '^foo?$' , glob2regpat ( 'foo\?' )) 31call assert_equal ( '^\(foo,bar\|foobar\)$' , glob2regpat ( '{foo\,bar,foobar}' )) 32call assert_equal ( '^{foo,bar}$' , glob2regpat ( '\{foo,bar\}' )) 33call assert_equal ( '^\\\(foo\|bar\\\)$' , glob2regpat ( '\\{foo,bar\\}' )) 34endif 35endfunc