indent_spec.lua 865 B

12345678910111213141516171819202122232425262728293031
  1. local helpers = require("test.unit.helpers")(after_each)
  2. local itp = helpers.gen_itp(it)
  3. local eq = helpers.eq
  4. local indent = helpers.cimport("./src/nvim/indent.h")
  5. local globals = helpers.cimport("./src/nvim/globals.h")
  6. describe('get_sts_value', function()
  7. itp([[returns 'softtabstop' when it is non-negative]], function()
  8. globals.curbuf.b_p_sts = 5
  9. eq(5, indent.get_sts_value())
  10. globals.curbuf.b_p_sts = 0
  11. eq(0, indent.get_sts_value())
  12. end)
  13. itp([[returns "effective shiftwidth" when 'softtabstop' is negative]], function()
  14. local shiftwidth = 2
  15. globals.curbuf.b_p_sw = shiftwidth
  16. local tabstop = 5
  17. globals.curbuf.b_p_ts = tabstop
  18. globals.curbuf.b_p_sts = -2
  19. eq(shiftwidth, indent.get_sts_value())
  20. shiftwidth = 0
  21. globals.curbuf.b_p_sw = shiftwidth
  22. eq(tabstop, indent.get_sts_value())
  23. end)
  24. end)