robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
343436f97d
master
1" Tests for 'lispwords' settings being global-local. 2" And other lisp indent stuff. 3 4set nocompatible viminfo += nviminfo 5 6func Test_global_local_lispwords () 7setglobal lispwords=foo,bar,baz 8setlocal lispwords -= foo |setlocal lispwords += quux 9call assert_equal ( 'foo,bar,baz' , & g: lispwords ) 10call assert_equal ( 'bar,baz,quux' , & l: lispwords ) 11call assert_equal ( 'bar,baz,quux' , & lispwords ) 12 13setlocal lispwords < 14call assert_equal ( 'foo,bar,baz' , & g: lispwords ) 15call assert_equal ( 'foo,bar,baz' , & l: lispwords ) 16call assert_equal ( 'foo,bar,baz' , & lispwords ) 17endfunc 18 19func Test_lisp_indent () 20enew ! 21 22call append ( 0 , [ 23 \'(defun html-file (base)' , 24 \'(format nil "~(~A~).html" base))' , 25 \'' , 26 \'(defmacro page (name title &rest body)' , 27 \'(let ((ti (gensym)))' , 28 \'`(with-open-file (*standard-output*' , 29 \'(html-file ,name)' , 30 \':direction :output' , 31 \':if-exists :supersede)' , 32 \'(let ((,ti ,title))' , 33 \'(as title ,ti)' , 34 \'(with center ' , 35 \'(as h2 (string-upcase ,ti)))' , 36 \'(brs 3)' , 37 \',@body))))' , 38 \'' , 39 \';;; Utilities for generating links' , 40 \'' , 41 \'(defmacro with-link (dest &rest body)' , 42 \'`(progn' , 43 \'(format t "<a href=\"~A\">" (html-file ,dest))' , 44 \',@body' , 45 \'(princ "</a>")))' 46 \]) 47call assert_equal ( 7 , lispindent ( 2 )) 48call assert_equal ( 5 , 6 ->lispindent ()) 49call assert_equal ( -1 , lispindent ( -1 )) 50 51set lisp 52set lispwords & 53throw 'Skipped: cpo+=p not supported' 54let save_copt = & cpoptions 55set cpoptions += p 56normal 1G=G 57 58call assert_equal ([ 59 \'(defun html-file (base)' , 60 \' (format nil "~(~A~).html" base))' , 61 \'' , 62 \'(defmacro page (name title &rest body)' , 63 \' (let ((ti (gensym)))' , 64 \' `(with-open-file (*standard-output*' , 65 \' (html-file ,name)' , 66 \' :direction :output' , 67 \' :if-exists :supersede)' , 68 \' (let ((,ti ,title))' , 69 \' (as title ,ti)' , 70 \' (with center ' , 71 \' (as h2 (string-upcase ,ti)))' , 72 \' (brs 3)' , 73 \' ,@body))))' , 74 \'' , 75 \';;; Utilities for generating links' , 76 \'' , 77 \'(defmacro with-link (dest &rest body)' , 78 \' `(progn' , 79 \' (format t "<a href=\"~A\">" (html-file ,dest))' , 80 \' ,@body' , 81 \' (princ "</a>")))' , 82 \'' 83 \], getline ( 1 , "$" )) 84 85enew ! 86let & cpoptions = save_copt 87set nolisp 88endfunc 89 90func Test_lispindent_negative () 91" in legacy script there is no error 92call assert_equal ( -1 , lispindent ( -1 )) 93endfunc 94 95func Test_lispindent_with_indentexpr () 96enew 97setl ai lisp nocin indentexpr = 11 98exe "normal a(x\<CR>1\<CR>2)\<Esc>" 99let expected = [ '(x' , ' 1' , ' 2)' ] 100call assert_equal ( expected , getline ( 1 , 3 )) 101" with Lisp indenting the first line is not indented 102normal 1G=G 103call assert_equal ( expected , getline ( 1 , 3 )) 104 105 %del 106setl lispoptions = expr:1indentexpr = 5 107exe "normal a(x\<CR>1\<CR>2)\<Esc>" 108let expected_expr = [ '(x' , ' 1' , ' 2)' ] 109call assert_equal ( expected_expr , getline ( 1 , 3 )) 110normal 2G2<<=G 111call assert_equal ( expected_expr , getline ( 1 , 3 )) 112 113setl lispoptions = expr:0 114" with Lisp indenting the first line is not indented 115normal 1G3<<=G 116call assert_equal ( expected , getline ( 1 , 3 )) 117 118bwipe ! 119endfunc 120 121func Test_lisp_indent_works () 122" This was reading beyond the end of the line 123new 124exe "norm a\tü(\<CR>=" 125set lisp 126norm == 127bwipe ! 128endfunc 129 130" vim: shiftwidth=2 sts=2 expandtab