Skip to content

Commit 7bb592c

Browse files
author
José Valim
committed
Merge pull request #1507 from AtKaaZ/reborntest1
revive a non-functioning test
2 parents a24b9c4 + eee3d3f commit 7bb592c

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

lib/elixir/test/elixir/kernel/cli_test.exs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,23 @@ end
5555
defmodule Kernel.CLI.SyntaxErrorTest do
5656
use ExUnit.Case, async: true
5757

58+
def check_output(elixir_cmd, expected_msg) do
59+
o = elixir(elixir_cmd)
60+
expected_msg = to_char_list(:unicode.characters_to_binary expected_msg)
61+
assert :string.str(o, expected_msg) == 1, "Expected this output: `#{expected_msg}`\nbut got this output: `#{o}`"
62+
end
63+
5864
test :syntax_code_error do
59-
message = '** (TokenMissingError) nofile:1: syntax error: expression is incomplete'
60-
assert :string.str(message, elixir('-e "[1,2"')) == 0
61-
message = '** (SyntaxError) nofile:1: syntax error before: \'end\''
62-
assert :string.str(message, elixir('-e "case 1 end"')) == 0
63-
message = '** (SyntaxError) nofile:1: invalid token: あ'
64-
assert :string.str(message, elixir('-e "あ"')) == 0
65-
message = '** (SyntaxError) nofile:1: invalid token: æ'
66-
assert :string.str(message, elixir('-e "æ"')) == 0
65+
check_output('-e "[1,2"', '** (TokenMissingError) nofile:1: missing terminator: ]')
66+
check_output('-e "case 1 end"', %C"** (SyntaxError) nofile:1: unexpected token: end")
67+
thischar = "あ"
68+
if is_win? do
69+
thatchar = %B"\x{3042}"
70+
else
71+
thatchar = :unicode.characters_to_binary(thischar)
72+
end
73+
check_output('-e "#{thischar}"', '** (SyntaxError) nofile:1: invalid token: #{thatchar}')
74+
check_output('-e "æ"', '** (SyntaxError) nofile:1: invalid token: æ')
6775
end
6876
end
6977

0 commit comments

Comments
 (0)