README.txt 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. TESTING INDENT SCRIPTS
  2. We'll use FILETYPE for the filetype name here.
  3. FORMAT OF THE FILETYPE.IN FILE
  4. First of all, create a FILETYPE.in file. It should contain:
  5. - A modeline setting the 'filetype' and any other option values.
  6. This must work like a comment for FILETYPE. E.g. for vim:
  7. " vim: set ft=vim sw=4 :
  8. - At least one block of lines to indent, prefixed with START_INDENT and
  9. followed by END_INDENT. These lines must also look like a comment for your
  10. FILETYPE. You would normally leave out all indent, so that the effect of
  11. the indent command results in adding indent. Example:
  12. " START_INDENT
  13. func Some()
  14. let x = 1
  15. endfunc
  16. " END_INDENT
  17. If you just want to test normal indenting with default options, you can make
  18. this a large number of lines. Just add all kinds of language constructs,
  19. nested statements, etc. with valid syntax.
  20. - Optionally, add lines with INDENT_EXE after START_INDENT, followed by a Vim
  21. command. This will be executed before indenting the lines. Example:
  22. " START_INDENT
  23. " INDENT_EXE let g:vim_indent_cont = 6
  24. let cmd =
  25. \ 'some '
  26. \ 'string'
  27. " END_INDENT
  28. Note that the command is not undone, you may need to reverse the effect for
  29. the next block of lines.
  30. - Alternatively to indenting all the lines between START_INDENT and
  31. END_INDENT, use an INDENT_AT line, which specifies a pattern to find the
  32. line to indent. Example:
  33. " START_INDENT
  34. " INDENT_AT this-line
  35. func Some()
  36. let f = x " this-line
  37. endfunc
  38. " END_INDENT
  39. Alternatively you can use INDENT_NEXT to indent the line below the matching
  40. pattern. Keep in mind that quite often it will indent relative to the
  41. matching line:
  42. " START_INDENT
  43. " INDENT_NEXT next-line
  44. func Some()
  45. " next-line
  46. let f = x
  47. endfunc
  48. " END_INDENT
  49. Or use INDENT_PREV to indent the line above the matching pattern:
  50. " START_INDENT
  51. " INDENT_PREV prev-line
  52. func Some()
  53. let f = x
  54. " prev-line
  55. endfunc
  56. " END_INDENT
  57. It's best to keep the whole file valid for FILETYPE, so that syntax
  58. highlighting works normally, and any indenting that depends on the syntax
  59. highlighting also works.
  60. RUNNING THE TEST
  61. Before running the test, create a FILETYPE.ok file. You can leave it empty at
  62. first.
  63. Now run "make test" from the parent directory. After Vim has done the
  64. indenting you will see a FILETYPE.fail file. This contains the actual result
  65. of indenting, and it's different from the FILETYPE.ok file.
  66. Check the contents of the FILETYPE.fail file. If it is perfectly OK, then
  67. rename it to overwrite the FILETYPE.ok file. If you now run "make test" again,
  68. the test will pass and create a FILETYPE.out file, which is identical to the
  69. FILETYPE.ok file. The FILETYPE.fail file will be deleted.
  70. If you try to run "make test" again you will notice that nothing happens,
  71. because the FILETYPE.out file already exists. Delete it, or do "make clean",
  72. so that the text runs again. If you edit the FILETYPE.in file, so that it's
  73. newer than the FILETYPE.out file, the test will also run.