Skip to content

Commit 54db13a

Browse files
author
José Valim
committed
Merge pull request #2354 from chyndman/eex-test-crlf-newlines
EEx tests aware of CR+LF newline on Windows
2 parents bf7d172 + f60d366 commit 54db13a

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

lib/eex/test/eex_test.exs

+10-3
Original file line numberDiff line numberDiff line change
@@ -303,13 +303,13 @@ foo
303303
test "evaluates the source from a given file" do
304304
filename = Path.join(__DIR__, "fixtures/eex_template.eex")
305305
result = EEx.eval_file(filename)
306-
assert result == "foo bar.\n"
306+
assert result == "foo bar." <> os_newline
307307
end
308308

309309
test "evaluates the source from a given file with bindings" do
310310
filename = Path.join(__DIR__, "fixtures/eex_template_with_bindings.eex")
311311
result = EEx.eval_file(filename, [bar: 1])
312-
assert result == "foo 1\n"
312+
assert result == "foo 1" <> os_newline
313313
end
314314

315315
test "raises an Exception when there's an error with the given file" do
@@ -324,7 +324,7 @@ foo
324324
end
325325

326326
test "defined from file" do
327-
assert EExText.Compiled.file_sample(1) == "foo 1\n"
327+
assert EExText.Compiled.file_sample(1) == "foo 1" <> os_newline
328328
end
329329

330330
test "defined from file do not affect backtrace" do
@@ -356,6 +356,13 @@ foo
356356
}
357357
end
358358

359+
defp os_newline do
360+
case :os.type do
361+
{:win32, _} -> "\r\n"
362+
_ -> "\n"
363+
end
364+
end
365+
359366
defmodule TestEngine do
360367
@behaviour EEx.Engine
361368

0 commit comments

Comments
 (0)