Skip to content

Commit f83183d

Browse files
bcpeinhardtlpil
authored andcommitted
add failing test
1 parent f2edfad commit f83183d

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

compiler-core/src/erlang/tests/bit_arrays.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,3 +314,19 @@ pub fn main() {
314314
"
315315
);
316316
}
317+
318+
#[test]
319+
fn unicode_character_encoding() {
320+
assert_erl!(
321+
"
322+
pub fn main() -> Nil {
323+
let foo = <<\"\\u{feff}foo\":utf8>>
324+
let _bits = case foo {
325+
<<\"\\u{feff}\":utf8, rest: bits>> -> rest
326+
_ -> foo
327+
}
328+
Nil
329+
}
330+
"
331+
);
332+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
source: compiler-core/src/erlang/tests/bit_arrays.rs
3+
assertion_line: 320
4+
expression: "\npub fn main() -> Nil {\n let foo = <<\"\\u{feff}foo\":utf8>>\n let _bits = case foo {\n <<\"\\u{feff}\":utf8, rest: bits>> -> rest\n _ -> foo\n }\n Nil\n}\n"
5+
snapshot_kind: text
6+
---
7+
----- SOURCE CODE
8+
9+
pub fn main() -> Nil {
10+
let foo = <<"\u{feff}foo":utf8>>
11+
let _bits = case foo {
12+
<<"\u{feff}":utf8, rest: bits>> -> rest
13+
_ -> foo
14+
}
15+
Nil
16+
}
17+
18+
19+
----- COMPILED ERLANG
20+
-module(my@mod).
21+
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
22+
-define(FILEPATH, "project/test/my/mod.gleam").
23+
-export([main/0]).
24+
25+
-file("project/test/my/mod.gleam", 2).
26+
-spec main() -> nil.
27+
main() ->
28+
Foo = <<"\x{feff}foo"/utf8>>,
29+
_ = case Foo of
30+
<<"\u{feff}"/utf8, Rest/bitstring>> ->
31+
Rest;
32+
33+
_ ->
34+
Foo
35+
end,
36+
nil.

0 commit comments

Comments
 (0)