HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux ip-172-31-42-149 5.15.0-1084-aws #91~20.04.1-Ubuntu SMP Fri May 2 07:00:04 UTC 2025 aarch64
User: ubuntu (1000)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: //home/ubuntu/neovim/test/functional/legacy/fixeol_spec.lua
-- Tests for 'fixeol'

local n = require('test.functional.testnvim')()

local feed = n.feed
local clear, feed_command, expect = n.clear, n.feed_command, n.expect

describe('fixeol', function()
  local function rmtestfiles()
    os.remove('test.out')
    os.remove('XXEol')
    os.remove('XXNoEol')
    os.remove('XXTestEol')
    os.remove('XXTestNoEol')
  end
  setup(function()
    clear()
    rmtestfiles()
  end)
  teardown(function()
    rmtestfiles()
  end)

  it('is working', function()
    -- First write two test files – with and without trailing EOL.
    feed_command('enew!')
    feed('awith eol<esc>:w! XXEol<cr>')
    feed_command('enew!')
    feed_command('set noeol nofixeol')
    feed('awithout eol<esc>:w! XXNoEol<cr>')
    feed_command('set eol fixeol')
    feed_command('bwipe XXEol XXNoEol')

    -- Try editing files with 'fixeol' disabled.
    feed_command('e! XXEol')
    feed('ostays eol<esc>:set nofixeol<cr>')
    feed_command('w! XXTestEol')
    feed_command('e! XXNoEol')
    feed('ostays without<esc>:set nofixeol<cr>')
    feed_command('w! XXTestNoEol')
    feed_command('bwipe! XXEol XXNoEol XXTestEol XXTestNoEol')
    feed_command('set fixeol')

    -- Append "END" to each file so that we can see what the last written char was.
    feed('ggdGaEND<esc>:w >>XXEol<cr>')
    feed_command('w >>XXNoEol')
    feed_command('w >>XXTestEol')
    feed_command('w >>XXTestNoEol')

    -- Concatenate the results.
    feed_command('e! test.out')
    feed('a0<esc>:$r XXEol<cr>')
    feed_command('$r XXNoEol')
    feed('Go1<esc>:$r XXTestEol<cr>')
    feed_command('$r XXTestNoEol')
    feed_command('w')

    -- Assert buffer contents.
    expect([=[
      0
      with eol
      END
      without eolEND
      1
      with eol
      stays eol
      END
      without eol
      stays withoutEND]=])
  end)
end)