Handle UTF-8 in character literals
Also handle `\x{hhh..}` in strings... Character literals has to be a single character, not composite.
+ tests (and the corresponding fix to the char literal pretty printer)
This commit is contained in:
@@ -63,7 +63,8 @@ simple_contracts_test_() ->
|
||||
%% Parse tests of example contracts
|
||||
[ {lists:concat(["Parse the ", Contract, " contract."]),
|
||||
fun() -> roundtrip_contract(Contract) end}
|
||||
|| Contract <- [counter, voting, all_syntax, '05_greeter', aeproof, multi_sig, simple_storage, fundme, dutch_auction] ]
|
||||
|| Contract <- [counter, voting, all_syntax, '05_greeter', aeproof,
|
||||
multi_sig, simple_storage, fundme, dutch_auction, utf8] ]
|
||||
}.
|
||||
|
||||
parse_contract(Name) ->
|
||||
@@ -85,7 +86,7 @@ parse_expr(Text) ->
|
||||
round_trip(Text) ->
|
||||
Contract = parse_string(Text),
|
||||
Text1 = prettypr:format(aeso_pretty:decls(strip_stdlib(Contract))),
|
||||
Contract1 = parse_string(Text1),
|
||||
Contract1 = parse_string(aeso_scan:utf8_encode(Text1)),
|
||||
NoSrcLoc = remove_line_numbers(Contract),
|
||||
NoSrcLoc1 = remove_line_numbers(Contract1),
|
||||
?assertMatch(NoSrcLoc, diff(NoSrcLoc, NoSrcLoc1)).
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
contract UTF8 =
|
||||
entrypoint f1() : char = '1'
|
||||
entrypoint f2() : char = '+'
|
||||
entrypoint f3() : char = 'd'
|
||||
entrypoint f4() : char = 'X'
|
||||
entrypoint f5() : char = 'å'
|
||||
entrypoint f6() : char = 'Ä'
|
||||
entrypoint f7() : char = 'æ'
|
||||
entrypoint f8() : char = 'ë'
|
||||
entrypoint f9() : char = 'ẻ'
|
||||
entrypoint f10() : char = '\x27'
|
||||
entrypoint f11() : char = '\x{2200}'
|
||||
entrypoint f12() : char = '💩'
|
||||
entrypoint f13() : char = '\n'
|
||||
|
||||
|
||||
|
||||
// entrypoint f13() : char = 'e̊'
|
||||
// entrypoint f14() : char = '\Ì'
|
||||
|
||||
// '💩' vs. map('a,'b)
|
||||
Reference in New Issue
Block a user