mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-04 12:18:19 +00:00
Merge pull request #5020 from roc-lang/dev-unbox-u32
dev backend: reading and writing 32, 16 and 8-bit values
This commit is contained in:
commit
34340de60c
18 changed files with 1862 additions and 706 deletions
|
@ -1859,13 +1859,11 @@ fn first_int_list() {
|
|||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
when List.first [12, 9, 6, 3] is
|
||||
Ok val -> val
|
||||
Err _ -> -1
|
||||
List.first [12, 9, 6, 3]
|
||||
"#
|
||||
),
|
||||
12,
|
||||
i64
|
||||
RocResult::ok(12),
|
||||
RocResult<i64, ()>
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1889,45 +1887,42 @@ fn first_wildcard_empty_list() {
|
|||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
when List.first [] is
|
||||
Ok _ -> 5
|
||||
Err _ -> -1
|
||||
List.last [] |> Result.map (\_ -> 0i64)
|
||||
"#
|
||||
),
|
||||
-1,
|
||||
i64
|
||||
RocResult::err(()),
|
||||
RocResult<i64, ()>
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn first_empty_list() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
when List.first [] is
|
||||
Ok val -> val
|
||||
Err _ -> -1
|
||||
list : List I64
|
||||
list = []
|
||||
|
||||
List.first list
|
||||
"#
|
||||
),
|
||||
-1,
|
||||
i64
|
||||
RocResult::err(()),
|
||||
RocResult<i64, ()>
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn last_int_list() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
when List.last [12, 9, 6, 3] is
|
||||
Ok val -> val
|
||||
Err _ -> -1
|
||||
List.last [12, 9, 6, 3]
|
||||
"#
|
||||
),
|
||||
3,
|
||||
i64
|
||||
RocResult::ok(3),
|
||||
RocResult<i64, ()>
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1937,13 +1932,11 @@ fn last_wildcard_empty_list() {
|
|||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
when List.last [] is
|
||||
Ok _ -> 5
|
||||
Err _ -> -1
|
||||
List.last [] |> Result.map (\_ -> 0i64)
|
||||
"#
|
||||
),
|
||||
-1,
|
||||
i64
|
||||
RocResult::err(()),
|
||||
RocResult<i64, ()>
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1953,13 +1946,14 @@ fn last_empty_list() {
|
|||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
when List.last [] is
|
||||
Ok val -> val
|
||||
Err _ -> -1
|
||||
list : List I64
|
||||
list = []
|
||||
|
||||
List.last list
|
||||
"#
|
||||
),
|
||||
-1,
|
||||
i64
|
||||
RocResult::err(()),
|
||||
RocResult<i64, ()>
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1969,29 +1963,32 @@ fn get_empty_list() {
|
|||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
when List.get [] 0 is
|
||||
Ok val -> val
|
||||
Err _ -> -1
|
||||
list : List I64
|
||||
list = []
|
||||
|
||||
List.get list 0
|
||||
"#
|
||||
),
|
||||
-1,
|
||||
i64
|
||||
RocResult::err(()),
|
||||
RocResult<i64, ()>
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
fn get_wildcard_empty_list() {
|
||||
// NOTE: by default, the return type is `Result [] [NotFound]`, which is actually represented
|
||||
// as just `[NotFound]`. Casting that to `RocResult<(), ()>` is invalid! But accepting any `()`
|
||||
// would make the test pointless. Therefore, we must explicitly change the type on the roc side
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
when List.get [] 0 is
|
||||
Ok _ -> 5
|
||||
Err _ -> -1
|
||||
List.get [] 0
|
||||
|> Result.map (\_ -> {})
|
||||
"#
|
||||
),
|
||||
-1,
|
||||
i64
|
||||
RocResult::err(()),
|
||||
RocResult<(), ()>
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -2010,39 +2007,35 @@ fn get_str_list_ok() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn get_int_list_ok() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
when List.get [12, 9, 6] 1 is
|
||||
Ok val -> val
|
||||
Err _ -> -1
|
||||
List.get [12, 9, 6] 1
|
||||
"#
|
||||
),
|
||||
9,
|
||||
i64
|
||||
RocResult::ok(9),
|
||||
RocResult<i64, ()>
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn get_int_list_oob() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
when List.get [12, 9, 6] 1000 is
|
||||
Ok val -> val
|
||||
Err _ -> -1
|
||||
List.get [12, 9, 6] 1000
|
||||
"#
|
||||
),
|
||||
-1,
|
||||
i64
|
||||
RocResult::err(()),
|
||||
RocResult<i64, ()>
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn replace_unique_int_list() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
|
@ -2057,7 +2050,7 @@ fn replace_unique_int_list() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn replace_unique_int_list_out_of_bounds() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
|
@ -2072,7 +2065,7 @@ fn replace_unique_int_list_out_of_bounds() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn replace_unique_int_list_get_old_value() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
|
@ -2087,7 +2080,7 @@ fn replace_unique_int_list_get_old_value() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn replace_unique_get_large_value() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
|
@ -2138,13 +2131,11 @@ fn get_set_unique_int_list_i64() {
|
|||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
when List.get (List.set [12, 9, 7, 3] 1 42) 1 is
|
||||
Ok val -> val
|
||||
Err _ -> -1
|
||||
List.get (List.set [12, 9, 7, 3] 1 42) 1
|
||||
"#
|
||||
),
|
||||
42,
|
||||
i64
|
||||
RocResult::ok(42),
|
||||
RocResult<i64, ()>
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -2154,13 +2145,11 @@ fn get_set_unique_int_list_i8() {
|
|||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
when List.get (List.set [12, 9, 7, 3] 1 42i8) 1 is
|
||||
Ok val -> val
|
||||
Err _ -> -1i8
|
||||
List.get (List.set [12, 9, 7, 3] 1 42i8) 1
|
||||
"#
|
||||
),
|
||||
42,
|
||||
i8
|
||||
RocResult::ok(42),
|
||||
RocResult<i8, ()>
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -2175,7 +2164,7 @@ fn set_unique_int_list() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn set_unique_list_oob() {
|
||||
assert_evals_to!(
|
||||
"List.set [3, 17, 4.1] 1337 9.25",
|
||||
|
@ -2240,20 +2229,18 @@ fn set_shared_list_oob() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn get_unique_int_list() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
unique = [2, 4]
|
||||
|
||||
when List.get unique 1 is
|
||||
Ok num -> num
|
||||
Err _ -> -1
|
||||
List.get unique 1
|
||||
"#
|
||||
),
|
||||
4,
|
||||
i64
|
||||
RocResult::ok(4),
|
||||
RocResult<i64, ()>
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -2275,7 +2262,7 @@ fn gen_wrap_len() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn gen_wrap_first() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
|
@ -2292,7 +2279,7 @@ fn gen_wrap_first() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn gen_duplicate() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
|
@ -2605,7 +2592,7 @@ fn list_literal_increment_decrement() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn list_pass_to_function() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
|
@ -2625,7 +2612,7 @@ fn list_pass_to_function() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn list_pass_to_set() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
|
@ -2713,24 +2700,22 @@ fn list_min() {
|
|||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
when List.min [] is
|
||||
Ok val -> val
|
||||
Err _ -> -1
|
||||
"#
|
||||
List.min []
|
||||
|> Result.map (\_ -> {})
|
||||
"#
|
||||
),
|
||||
-1,
|
||||
i64
|
||||
RocResult::err(()),
|
||||
RocResult<(), ()>
|
||||
);
|
||||
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
when List.min [3, 1, 2] is
|
||||
Ok val -> val
|
||||
Err _ -> -1
|
||||
"#
|
||||
List.min [3, 1, 2]
|
||||
"#
|
||||
),
|
||||
1,
|
||||
i64
|
||||
RocResult::ok(1),
|
||||
RocResult<i64, ()>
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -2740,24 +2725,22 @@ fn list_max() {
|
|||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
when List.max [] is
|
||||
Ok val -> val
|
||||
Err _ -> -1
|
||||
"#
|
||||
List.max []
|
||||
|> Result.map (\_ -> {})
|
||||
"#
|
||||
),
|
||||
-1,
|
||||
i64
|
||||
RocResult::err(()),
|
||||
RocResult<(), ()>
|
||||
);
|
||||
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
when List.max [3, 1, 2] is
|
||||
Ok val -> val
|
||||
Err _ -> -1
|
||||
"#
|
||||
List.max [3, 1, 2]
|
||||
"#
|
||||
),
|
||||
3,
|
||||
i64
|
||||
RocResult::ok(3),
|
||||
RocResult<i64, ()>
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -3440,7 +3423,7 @@ fn with_capacity() {
|
|||
r#"
|
||||
l : List U64
|
||||
l = List.withCapacity 10
|
||||
|
||||
|
||||
l
|
||||
"#
|
||||
),
|
||||
|
|
|
@ -3307,10 +3307,46 @@ fn box_str() {
|
|||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn box_and_unbox_num() {
|
||||
fn box_and_unbox_u64() {
|
||||
assert_evals_to!("Box.unbox (Box.box (123u64))", 123, u64)
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn box_and_unbox_u32() {
|
||||
assert_evals_to!("Box.unbox (Box.box (123u32))", 123, u32)
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn box_and_unbox_u16() {
|
||||
assert_evals_to!("Box.unbox (Box.box (123u16))", 123, u16)
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn box_and_unbox_u8() {
|
||||
assert_evals_to!("Box.unbox (Box.box (123u8))", 123, u8)
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn box_and_unbox_bool() {
|
||||
assert_evals_to!("Box.unbox (Box.box (Bool.true))", true, bool)
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn box_and_unbox_f64() {
|
||||
assert_evals_to!("Box.unbox (Box.box (123.0f64))", 123.0, f64)
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn box_and_unbox_f32() {
|
||||
assert_evals_to!("Box.unbox (Box.box (123.0f32))", 123.0, f32)
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
fn box_and_unbox_record() {
|
||||
|
|
|
@ -360,7 +360,7 @@ fn i64_record1_literal() {
|
|||
// );
|
||||
// }
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn bool_literal() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
|
@ -1111,3 +1111,22 @@ fn toplevel_accessor_fn_thunk() {
|
|||
u8
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
fn pass_record_of_u8s() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
app "test" provides [main] to "./platform"
|
||||
|
||||
ra = \_ -> 1u8
|
||||
|
||||
main =
|
||||
ra { a: 1u8, b: 0u8 }
|
||||
"#
|
||||
),
|
||||
true,
|
||||
bool
|
||||
)
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ use indoc::indoc;
|
|||
use roc_std::{RocList, RocResult, RocStr};
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_split_empty_delimiter() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
|
@ -46,7 +46,7 @@ fn str_split_empty_delimiter() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_split_bigger_delimiter_small_str() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
|
@ -110,7 +110,7 @@ fn str_split_small_str_bigger_delimiter() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_split_big_str_small_delimiter() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
|
@ -154,7 +154,7 @@ fn str_split_small_str_small_delimiter() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_split_bigger_delimiter_big_strs() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
|
@ -198,7 +198,7 @@ fn str_split_minimal_example() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_split_small_str_big_delimiter() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
|
@ -227,7 +227,7 @@ fn str_split_small_str_big_delimiter() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_split_small_str_20_char_delimiter() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
|
@ -243,7 +243,7 @@ fn str_split_small_str_20_char_delimiter() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_concat_big_to_big() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
|
@ -402,7 +402,7 @@ fn small_str_concat_empty_second_arg() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn small_str_concat_small_to_big() {
|
||||
assert_evals_to!(
|
||||
r#"Str.concat "abc" " this is longer than 15 chars""#,
|
||||
|
@ -530,7 +530,7 @@ fn str_count_graphemes_three_js() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_count_graphemes_big_str() {
|
||||
assert_evals_to!(
|
||||
r#"Str.countGraphemes "6🤔å🤔e¥🤔çppkd🙃1jdal🦯asdfa∆ltråø˚waia8918.,🏅jjc""#,
|
||||
|
@ -540,7 +540,7 @@ fn str_count_graphemes_big_str() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_starts_with_same_big_str() {
|
||||
assert_evals_to!(
|
||||
r#"Str.startsWith "123456789123456789" "123456789123456789""#,
|
||||
|
@ -550,7 +550,7 @@ fn str_starts_with_same_big_str() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_starts_with_different_big_str() {
|
||||
assert_evals_to!(
|
||||
r#"Str.startsWith "12345678912345678910" "123456789123456789""#,
|
||||
|
@ -560,24 +560,24 @@ fn str_starts_with_different_big_str() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_starts_with_same_small_str() {
|
||||
assert_evals_to!(r#"Str.startsWith "1234" "1234""#, true, bool);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_starts_with_different_small_str() {
|
||||
assert_evals_to!(r#"Str.startsWith "1234" "12""#, true, bool);
|
||||
}
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_starts_with_false_small_str() {
|
||||
assert_evals_to!(r#"Str.startsWith "1234" "23""#, false, bool);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_from_utf8_pass_single_ascii() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
|
@ -593,7 +593,7 @@ fn str_from_utf8_pass_single_ascii() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_from_utf8_pass_many_ascii() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
|
@ -609,7 +609,7 @@ fn str_from_utf8_pass_many_ascii() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_from_utf8_pass_single_unicode() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
|
@ -625,7 +625,7 @@ fn str_from_utf8_pass_single_unicode() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_from_utf8_pass_many_unicode() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
|
@ -641,7 +641,7 @@ fn str_from_utf8_pass_many_unicode() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_from_utf8_pass_single_grapheme() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
|
@ -657,7 +657,7 @@ fn str_from_utf8_pass_single_grapheme() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_from_utf8_pass_many_grapheme() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
|
@ -673,7 +673,7 @@ fn str_from_utf8_pass_many_grapheme() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_from_utf8_pass_all() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
|
@ -689,7 +689,7 @@ fn str_from_utf8_pass_all() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_from_utf8_fail_invalid_start_byte() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
|
@ -709,7 +709,7 @@ fn str_from_utf8_fail_invalid_start_byte() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_from_utf8_fail_unexpected_end_of_sequence() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
|
@ -729,7 +729,7 @@ fn str_from_utf8_fail_unexpected_end_of_sequence() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_from_utf8_fail_expected_continuation() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
|
@ -749,7 +749,7 @@ fn str_from_utf8_fail_expected_continuation() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_from_utf8_fail_overlong_encoding() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
|
@ -769,7 +769,7 @@ fn str_from_utf8_fail_overlong_encoding() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_from_utf8_fail_codepoint_too_large() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
|
@ -789,7 +789,7 @@ fn str_from_utf8_fail_codepoint_too_large() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_from_utf8_fail_surrogate_half() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
|
@ -809,7 +809,7 @@ fn str_from_utf8_fail_surrogate_half() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_equality() {
|
||||
assert_evals_to!(r#""a" == "a""#, true, bool);
|
||||
assert_evals_to!(
|
||||
|
@ -865,7 +865,7 @@ fn nested_recursive_literal() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_join_comma_small() {
|
||||
assert_evals_to!(
|
||||
r#"Str.joinWith ["1", "2"] ", " "#,
|
||||
|
@ -875,7 +875,7 @@ fn str_join_comma_small() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_join_comma_big() {
|
||||
assert_evals_to!(
|
||||
r#"Str.joinWith ["10000000", "2000000", "30000000"] ", " "#,
|
||||
|
@ -885,13 +885,13 @@ fn str_join_comma_big() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_join_comma_single() {
|
||||
assert_evals_to!(r#"Str.joinWith ["1"] ", " "#, RocStr::from("1"), RocStr);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_to_utf8() {
|
||||
assert_evals_to!(
|
||||
r#"Str.toUtf8 "hello""#,
|
||||
|
@ -909,7 +909,7 @@ fn str_to_utf8() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_from_utf8_range() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
|
@ -926,7 +926,7 @@ fn str_from_utf8_range() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_from_utf8_range_slice() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
|
@ -943,7 +943,7 @@ fn str_from_utf8_range_slice() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_from_utf8_range_slice_not_end() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
|
@ -960,7 +960,7 @@ fn str_from_utf8_range_slice_not_end() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_from_utf8_range_order_does_not_matter() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
|
@ -977,7 +977,7 @@ fn str_from_utf8_range_order_does_not_matter() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_from_utf8_range_out_of_bounds_start_value() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
|
@ -995,7 +995,7 @@ fn str_from_utf8_range_out_of_bounds_start_value() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_from_utf8_range_count_too_high() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
|
@ -1013,7 +1013,7 @@ fn str_from_utf8_range_count_too_high() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_from_utf8_range_count_too_high_for_start() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
|
@ -1031,7 +1031,7 @@ fn str_from_utf8_range_count_too_high_for_start() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_repeat_small_stays_small() {
|
||||
assert_evals_to!(
|
||||
indoc!(r#"Str.repeat "Roc" 3"#),
|
||||
|
@ -1041,7 +1041,7 @@ fn str_repeat_small_stays_small() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_repeat_small_becomes_big() {
|
||||
assert_evals_to!(
|
||||
indoc!(r#"Str.repeat "less than 23 characters" 2"#),
|
||||
|
@ -1051,7 +1051,7 @@ fn str_repeat_small_becomes_big() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_repeat_big() {
|
||||
assert_evals_to!(
|
||||
indoc!(r#"Str.repeat "more than 23 characters now" 2"#),
|
||||
|
@ -1061,27 +1061,26 @@ fn str_repeat_big() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_repeat_empty_string() {
|
||||
let a = indoc!(r#"Str.repeat "" 3"#);
|
||||
let b = RocStr::from("");
|
||||
assert_evals_to!(a, b, RocStr);
|
||||
assert_evals_to!(a, RocStr::from(""), RocStr);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_repeat_zero_times() {
|
||||
assert_evals_to!(indoc!(r#"Str.repeat "Roc" 0"#), RocStr::from(""), RocStr);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_trim_empty_string() {
|
||||
assert_evals_to!(indoc!(r#"Str.trim """#), RocStr::from(""), RocStr);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_trim_null_byte() {
|
||||
assert_evals_to!(
|
||||
indoc!(r#"Str.trim (Str.reserve "\u(0000)" 40)"#),
|
||||
|
@ -1091,13 +1090,13 @@ fn str_trim_null_byte() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_trim_small_blank_string() {
|
||||
assert_evals_to!(indoc!(r#"Str.trim " ""#), RocStr::from(""), RocStr);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_trim_small_to_small() {
|
||||
assert_evals_to!(
|
||||
indoc!(r#"Str.trim " hello world ""#),
|
||||
|
@ -1107,7 +1106,7 @@ fn str_trim_small_to_small() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_trim_large_to_large_unique() {
|
||||
assert_evals_to!(
|
||||
indoc!(r#"Str.trim (Str.concat " " "hello world from a large string ")"#),
|
||||
|
@ -1117,7 +1116,7 @@ fn str_trim_large_to_large_unique() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_trim_large_to_small_unique() {
|
||||
assert_evals_to!(
|
||||
indoc!(r#"Str.trim (Str.concat " " "hello world ")"#),
|
||||
|
@ -1184,13 +1183,13 @@ fn str_trim_small_to_small_shared() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_trim_left_small_blank_string() {
|
||||
assert_evals_to!(indoc!(r#"Str.trimLeft " ""#), RocStr::from(""), RocStr);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_trim_left_small_to_small() {
|
||||
assert_evals_to!(
|
||||
indoc!(r#"Str.trimLeft " hello world ""#),
|
||||
|
@ -1200,7 +1199,7 @@ fn str_trim_left_small_to_small() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_trim_left_large_to_large_unique() {
|
||||
assert_evals_to!(
|
||||
indoc!(r#"Str.trimLeft (Str.concat " " "hello world from a large string ")"#),
|
||||
|
@ -1210,7 +1209,7 @@ fn str_trim_left_large_to_large_unique() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_trim_left_large_to_small_unique() {
|
||||
assert_evals_to!(
|
||||
indoc!(r#"Str.trimLeft (Str.concat " " "hello world ")"#),
|
||||
|
@ -1277,13 +1276,13 @@ fn str_trim_left_small_to_small_shared() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_trim_right_small_blank_string() {
|
||||
assert_evals_to!(indoc!(r#"Str.trimRight " ""#), RocStr::from(""), RocStr);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_trim_right_small_to_small() {
|
||||
assert_evals_to!(
|
||||
indoc!(r#"Str.trimRight " hello world ""#),
|
||||
|
@ -1293,7 +1292,7 @@ fn str_trim_right_small_to_small() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_trim_right_large_to_large_unique() {
|
||||
assert_evals_to!(
|
||||
indoc!(r#"Str.trimRight (Str.concat " hello world from a large string" " ")"#),
|
||||
|
@ -1303,7 +1302,7 @@ fn str_trim_right_large_to_large_unique() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_trim_right_large_to_small_unique() {
|
||||
assert_evals_to!(
|
||||
indoc!(r#"Str.trimRight (Str.concat " hello world" " ")"#),
|
||||
|
@ -1370,9 +1369,17 @@ fn str_trim_right_small_to_small_shared() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_to_nat() {
|
||||
assert_evals_to!(r#"Str.toNat "1" |> Result.withDefault 0"#, 1, usize);
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
Str.toNat "1"
|
||||
"#
|
||||
),
|
||||
RocResult::ok(1),
|
||||
RocResult<usize, ()>
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -1381,14 +1388,11 @@ fn str_to_i128() {
|
|||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
when Str.toI128 "1" is
|
||||
Ok n -> n
|
||||
Err _ -> 0
|
||||
|
||||
"#
|
||||
Str.toI128 "1"
|
||||
"#
|
||||
),
|
||||
1,
|
||||
i128
|
||||
RocResult::ok(1),
|
||||
RocResult<i128, ()>
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1398,41 +1402,39 @@ fn str_to_u128() {
|
|||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
when Str.toU128 "1" is
|
||||
Ok n -> n
|
||||
Err _ -> 0
|
||||
|
||||
"#
|
||||
Str.toU128 "1"
|
||||
"#
|
||||
),
|
||||
1,
|
||||
u128
|
||||
RocResult::ok(1),
|
||||
RocResult<u128, ()>
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_to_i64() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
when Str.toI64 "1" is
|
||||
Ok n -> n
|
||||
Err _ -> 0
|
||||
|
||||
"#
|
||||
Str.toI64 "1"
|
||||
"#
|
||||
),
|
||||
1,
|
||||
i64
|
||||
RocResult::ok(1),
|
||||
RocResult<i64, ()>
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_to_u64() {
|
||||
assert_evals_to!(
|
||||
r#"Str.toU64 "1""#,
|
||||
RocResult::ok(1u64),
|
||||
RocResult<u64, u8>
|
||||
indoc!(
|
||||
r#"
|
||||
Str.toU64 "1"
|
||||
"#
|
||||
),
|
||||
RocResult::ok(1),
|
||||
RocResult<u64, ()>
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1442,14 +1444,11 @@ fn str_to_i32() {
|
|||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
when Str.toI32 "1" is
|
||||
Ok n -> n
|
||||
Err _ -> 0
|
||||
|
||||
"#
|
||||
Str.toI32 "1"
|
||||
"#
|
||||
),
|
||||
1,
|
||||
i32
|
||||
RocResult::ok(1),
|
||||
RocResult<i32, ()>
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1457,9 +1456,13 @@ fn str_to_i32() {
|
|||
#[cfg(any(feature = "gen-llvm"))]
|
||||
fn str_to_u32() {
|
||||
assert_evals_to!(
|
||||
r#"Str.toU32 "1""#,
|
||||
RocResult::ok(1u32),
|
||||
RocResult<u32, u8>
|
||||
indoc!(
|
||||
r#"
|
||||
Str.toU32 "1"
|
||||
"#
|
||||
),
|
||||
RocResult::ok(1),
|
||||
RocResult<u32, ()>
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1469,14 +1472,11 @@ fn str_to_i16() {
|
|||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
when Str.toI16 "1" is
|
||||
Ok n -> n
|
||||
Err _ -> 0
|
||||
|
||||
"#
|
||||
Str.toI16 "1"
|
||||
"#
|
||||
),
|
||||
1,
|
||||
i16
|
||||
RocResult::ok(1),
|
||||
RocResult<i16, ()>
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1486,14 +1486,11 @@ fn str_to_u16() {
|
|||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
when Str.toU16 "1" is
|
||||
Ok n -> n
|
||||
Err _ -> 0
|
||||
|
||||
"#
|
||||
Str.toU16 "1"
|
||||
"#
|
||||
),
|
||||
1,
|
||||
u16
|
||||
RocResult::ok(1),
|
||||
RocResult<u16, ()>
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1503,14 +1500,11 @@ fn str_to_i8() {
|
|||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
when Str.toI8 "1" is
|
||||
Ok n -> n
|
||||
Err _ -> 0
|
||||
|
||||
"#
|
||||
Str.toI8 "1"
|
||||
"#
|
||||
),
|
||||
1,
|
||||
i8
|
||||
RocResult::ok(1),
|
||||
RocResult<i8, ()>
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1520,14 +1514,11 @@ fn str_to_u8() {
|
|||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
when Str.toU8 "1" is
|
||||
Ok n -> n
|
||||
Err _ -> 0
|
||||
|
||||
"#
|
||||
Str.toU8 "1"
|
||||
"#
|
||||
),
|
||||
1,
|
||||
u8
|
||||
RocResult::ok(1),
|
||||
RocResult<u8, ()>
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1585,7 +1576,7 @@ fn str_to_dec() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn issue_2811() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
|
@ -1601,7 +1592,7 @@ fn issue_2811() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn to_scalar_1_byte() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
|
@ -1625,7 +1616,7 @@ fn to_scalar_1_byte() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn to_scalar_2_byte() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
|
@ -1649,7 +1640,7 @@ fn to_scalar_2_byte() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn to_scalar_3_byte() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
|
@ -1673,7 +1664,7 @@ fn to_scalar_3_byte() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn to_scalar_4_byte() {
|
||||
// from https://design215.com/toolbox/utf8-4byte-characters.php
|
||||
assert_evals_to!(
|
||||
|
@ -1698,7 +1689,7 @@ fn to_scalar_4_byte() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_split_first_one_char() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
|
@ -1714,7 +1705,7 @@ fn str_split_first_one_char() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_split_first_multiple_chars() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
|
@ -1728,7 +1719,7 @@ fn str_split_first_multiple_chars() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_split_first_entire_input() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
|
@ -1742,7 +1733,7 @@ fn str_split_first_entire_input() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_split_first_not_found() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
|
@ -1756,7 +1747,7 @@ fn str_split_first_not_found() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_split_last_one_char() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
|
@ -1770,7 +1761,7 @@ fn str_split_last_one_char() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_split_last_multiple_chars() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
|
@ -1784,7 +1775,7 @@ fn str_split_last_multiple_chars() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_split_last_entire_input() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
|
@ -1798,12 +1789,12 @@ fn str_split_last_entire_input() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_split_last_not_found() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
Str.splitFirst "foo" "bar"
|
||||
Str.splitLast "foo" "bar"
|
||||
"#
|
||||
),
|
||||
RocResult::err(()),
|
||||
|
@ -1812,7 +1803,7 @@ fn str_split_last_not_found() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_split_overlapping_substring_1() {
|
||||
assert_evals_to!(
|
||||
r#"Str.split "aaa" "aa""#,
|
||||
|
@ -1822,7 +1813,7 @@ fn str_split_overlapping_substring_1() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_split_overlapping_substring_2() {
|
||||
assert_evals_to!(
|
||||
r#"Str.split "aaaa" "aa""#,
|
||||
|
@ -1832,7 +1823,7 @@ fn str_split_overlapping_substring_2() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_walk_utf8_with_index() {
|
||||
#[cfg(not(feature = "gen-llvm-wasm"))]
|
||||
assert_evals_to!(
|
||||
|
@ -1872,7 +1863,7 @@ fn str_append_scalar() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_walk_scalars() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
|
@ -1951,7 +1942,7 @@ fn when_on_strings() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn with_capacity() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
|
@ -1965,7 +1956,7 @@ fn with_capacity() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn with_capacity_concat() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
|
@ -1979,7 +1970,7 @@ fn with_capacity_concat() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn str_with_prefix() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
|
@ -2003,7 +1994,7 @@ fn str_with_prefix() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn destructure_pattern_assigned_from_thunk_opaque() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
|
@ -2025,7 +2016,7 @@ fn destructure_pattern_assigned_from_thunk_opaque() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn destructure_pattern_assigned_from_thunk_tag() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue