mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 22:09:09 +00:00
90 lines
2.2 KiB
Rust
90 lines
2.2 KiB
Rust
#[macro_use]
|
|
extern crate pretty_assertions;
|
|
#[macro_use]
|
|
extern crate indoc;
|
|
|
|
extern crate bumpalo;
|
|
extern crate inkwell;
|
|
extern crate libc;
|
|
extern crate roc_gen;
|
|
|
|
#[macro_use]
|
|
mod helpers;
|
|
|
|
#[cfg(test)]
|
|
mod gen_str {
|
|
#[test]
|
|
fn str_concat() {
|
|
assert_evals_to!("Str.concat \"a\" \"b\"", "ab", &'static str);
|
|
assert_evals_to!("Str.concat \"\" \"second str\"", "second str", &'static str);
|
|
assert_evals_to!("Str.concat \"first str\" \"\"", "first str", &'static str);
|
|
assert_evals_to!("Str.concat \"\" \"\"", "", &'static str);
|
|
}
|
|
|
|
#[test]
|
|
fn big_str_concat() {
|
|
assert_evals_to!(
|
|
indoc!(
|
|
r#"
|
|
Str.concat
|
|
"First string that is fairly long. Longer strings make for different errors. "
|
|
"Second string that is also fairly long. Two long strings test things that might not appear with short strings."
|
|
"#
|
|
),
|
|
"First string that is fairly long. Longer strings make for different errors. Second string that is also fairly long. Two long strings test things that might not appear with short strings.",
|
|
&'static str
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn small_str_concat() {
|
|
assert_evals_to!(
|
|
"Str.concat \"JJJJJJJ\" \"JJJJJJJJ\"",
|
|
[
|
|
0x4a,
|
|
0x4a,
|
|
0x4a,
|
|
0x4a,
|
|
0x4a,
|
|
0x4a,
|
|
0x4a,
|
|
0x4a,
|
|
0x4a,
|
|
0x4a,
|
|
0x4a,
|
|
0x4a,
|
|
0x4a,
|
|
0x4a,
|
|
0x4a,
|
|
0b1000_1111
|
|
],
|
|
[u8; 16]
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn small_str() {
|
|
assert_evals_to!(
|
|
"\"JJJJJJJJJJJJJJJ\"",
|
|
[
|
|
0x4a,
|
|
0x4a,
|
|
0x4a,
|
|
0x4a,
|
|
0x4a,
|
|
0x4a,
|
|
0x4a,
|
|
0x4a,
|
|
0x4a,
|
|
0x4a,
|
|
0x4a,
|
|
0x4a,
|
|
0x4a,
|
|
0x4a,
|
|
0x4a,
|
|
0b1000_1111
|
|
],
|
|
[u8; 16]
|
|
);
|
|
}
|
|
}
|