cmdtest/t/CMDTEST_crnl.rb
Johan Holmberg 9505af3dcc improve line ending detection + add tests
should hopefully work on Linux and Windows now
2016-11-16 22:34:00 +01:00

76 lines
1.4 KiB
Ruby

# coding: utf-8
require "selftest_utils"
class CMDTEST_crnl < Cmdtest::Testcase
include SelftestUtils
def test_crnl
create_CMDTEST_foo [
'cmd "echo_crnl.rb 1:rn 2:rn" do',
' comment "windows line endings"',
' stdout_equal "1\n2\n"',
'end',
]
if Cmdtest::Util.windows?
cmd_cmdtest do
stdout_equal [
"### windows line endings",
]
end
else
cmd_cmdtest do
stdout_equal [
"### windows line endings",
"--- ERROR: Windows line ending: STDOUT",
]
exit_nonzero
end
end
end
def test_nl
create_CMDTEST_foo [
'cmd "echo_crnl.rb 1:n 2:n" do',
' comment "unix line endings"',
' stdout_equal "1\n2\n"',
'end',
]
if Cmdtest::Util.windows?
cmd_cmdtest do
stdout_equal [
"### unix line endings",
"--- ERROR: UNIX line ending: STDOUT",
]
exit_nonzero
end
else
cmd_cmdtest do
stdout_equal [
"### unix line endings",
]
end
end
end
def test_crnl_and_nl
create_CMDTEST_foo [
'cmd "echo_crnl.rb 1:n 2:rn" do',
' comment "mixed line endings"',
'end',
]
cmd_cmdtest do
stdout_equal [
"### mixed line endings",
"--- ERROR: mixed line ending: STDOUT",
]
exit_nonzero
end
end
end