mirror of
https://github.com/roc-lang/roc.git
synced 2025-11-01 21:40:58 +00:00
wasm: fix Str.fromUtf8Range
This commit is contained in:
parent
e1d8d09472
commit
fdc0851883
2 changed files with 109 additions and 109 deletions
|
|
@ -281,9 +281,9 @@ impl<'a> LowLevelCall<'a> {
|
||||||
backend.code_builder.i32_const(UPDATE_MODE_IMMUTABLE);
|
backend.code_builder.i32_const(UPDATE_MODE_IMMUTABLE);
|
||||||
backend.call_host_fn_after_loading_args(bitcode::STR_FROM_UTF8, 4, false);
|
backend.call_host_fn_after_loading_args(bitcode::STR_FROM_UTF8, 4, false);
|
||||||
}
|
}
|
||||||
|
StrFromUtf8Range => self.load_args_and_call_zig(backend, bitcode::STR_FROM_UTF8_RANGE),
|
||||||
StrTrimLeft => self.load_args_and_call_zig(backend, bitcode::STR_TRIM_LEFT),
|
StrTrimLeft => self.load_args_and_call_zig(backend, bitcode::STR_TRIM_LEFT),
|
||||||
StrTrimRight => self.load_args_and_call_zig(backend, bitcode::STR_TRIM_RIGHT),
|
StrTrimRight => self.load_args_and_call_zig(backend, bitcode::STR_TRIM_RIGHT),
|
||||||
StrFromUtf8Range => self.load_args_and_call_zig(backend, bitcode::STR_FROM_UTF8_RANGE),
|
|
||||||
StrToUtf8 => self.load_args_and_call_zig(backend, bitcode::STR_TO_UTF8),
|
StrToUtf8 => self.load_args_and_call_zig(backend, bitcode::STR_TO_UTF8),
|
||||||
StrRepeat => self.load_args_and_call_zig(backend, bitcode::STR_REPEAT),
|
StrRepeat => self.load_args_and_call_zig(backend, bitcode::STR_REPEAT),
|
||||||
StrTrim => self.load_args_and_call_zig(backend, bitcode::STR_TRIM),
|
StrTrim => self.load_args_and_call_zig(backend, bitcode::STR_TRIM),
|
||||||
|
|
|
||||||
|
|
@ -757,120 +757,120 @@ fn str_to_utf8() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// #[test]
|
#[test]
|
||||||
// fn str_from_utf8_range() {
|
fn str_from_utf8_range() {
|
||||||
// assert_evals_to!(
|
assert_evals_to!(
|
||||||
// indoc!(
|
indoc!(
|
||||||
// r#"
|
r#"
|
||||||
// bytes = Str.toUtf8 "hello"
|
bytes = Str.toUtf8 "hello"
|
||||||
// when Str.fromUtf8Range bytes { count: 5, start: 0 } is
|
when Str.fromUtf8Range bytes { count: 5, start: 0 } is
|
||||||
// Ok utf8String -> utf8String
|
Ok utf8String -> utf8String
|
||||||
// _ -> ""
|
_ -> ""
|
||||||
// "#
|
"#
|
||||||
// ),
|
),
|
||||||
// RocStr::from("hello"),
|
RocStr::from("hello"),
|
||||||
// RocStr
|
RocStr
|
||||||
// );
|
);
|
||||||
// }
|
}
|
||||||
|
|
||||||
// #[test]
|
#[test]
|
||||||
// fn str_from_utf8_range_slice() {
|
fn str_from_utf8_range_slice() {
|
||||||
// assert_evals_to!(
|
assert_evals_to!(
|
||||||
// indoc!(
|
indoc!(
|
||||||
// r#"
|
r#"
|
||||||
// bytes = Str.toUtf8 "hello"
|
bytes = Str.toUtf8 "hello"
|
||||||
// when Str.fromUtf8Range bytes { count: 4, start: 1 } is
|
when Str.fromUtf8Range bytes { count: 4, start: 1 } is
|
||||||
// Ok utf8String -> utf8String
|
Ok utf8String -> utf8String
|
||||||
// _ -> ""
|
_ -> ""
|
||||||
// "#
|
"#
|
||||||
// ),
|
),
|
||||||
// RocStr::from("ello"),
|
RocStr::from("ello"),
|
||||||
// RocStr
|
RocStr
|
||||||
// );
|
);
|
||||||
// }
|
}
|
||||||
|
|
||||||
// #[test]
|
#[test]
|
||||||
// fn str_from_utf8_range_slice_not_end() {
|
fn str_from_utf8_range_slice_not_end() {
|
||||||
// assert_evals_to!(
|
assert_evals_to!(
|
||||||
// indoc!(
|
indoc!(
|
||||||
// r#"
|
r#"
|
||||||
// bytes = Str.toUtf8 "hello"
|
bytes = Str.toUtf8 "hello"
|
||||||
// when Str.fromUtf8Range bytes { count: 3, start: 1 } is
|
when Str.fromUtf8Range bytes { count: 3, start: 1 } is
|
||||||
// Ok utf8String -> utf8String
|
Ok utf8String -> utf8String
|
||||||
// _ -> ""
|
_ -> ""
|
||||||
// "#
|
"#
|
||||||
// ),
|
),
|
||||||
// RocStr::from("ell"),
|
RocStr::from("ell"),
|
||||||
// RocStr
|
RocStr
|
||||||
// );
|
);
|
||||||
// }
|
}
|
||||||
|
|
||||||
// #[test]
|
#[test]
|
||||||
// fn str_from_utf8_range_order_does_not_matter() {
|
fn str_from_utf8_range_order_does_not_matter() {
|
||||||
// assert_evals_to!(
|
assert_evals_to!(
|
||||||
// indoc!(
|
indoc!(
|
||||||
// r#"
|
r#"
|
||||||
// bytes = Str.toUtf8 "hello"
|
bytes = Str.toUtf8 "hello"
|
||||||
// when Str.fromUtf8Range bytes { start: 1, count: 3 } is
|
when Str.fromUtf8Range bytes { start: 1, count: 3 } is
|
||||||
// Ok utf8String -> utf8String
|
Ok utf8String -> utf8String
|
||||||
// _ -> ""
|
_ -> ""
|
||||||
// "#
|
"#
|
||||||
// ),
|
),
|
||||||
// RocStr::from("ell"),
|
RocStr::from("ell"),
|
||||||
// RocStr
|
RocStr
|
||||||
// );
|
);
|
||||||
// }
|
}
|
||||||
|
|
||||||
// #[test]
|
#[test]
|
||||||
// fn str_from_utf8_range_out_of_bounds_start_value() {
|
fn str_from_utf8_range_out_of_bounds_start_value() {
|
||||||
// assert_evals_to!(
|
assert_evals_to!(
|
||||||
// indoc!(
|
indoc!(
|
||||||
// r#"
|
r#"
|
||||||
// bytes = Str.toUtf8 "hello"
|
bytes = Str.toUtf8 "hello"
|
||||||
// when Str.fromUtf8Range bytes { start: 7, count: 3 } is
|
when Str.fromUtf8Range bytes { start: 7, count: 3 } is
|
||||||
// Ok _ -> ""
|
Ok _ -> ""
|
||||||
// Err (BadUtf8 _ _) -> ""
|
Err (BadUtf8 _ _) -> ""
|
||||||
// Err OutOfBounds -> "out of bounds"
|
Err OutOfBounds -> "out of bounds"
|
||||||
// "#
|
"#
|
||||||
// ),
|
),
|
||||||
// RocStr::from("out of bounds"),
|
RocStr::from("out of bounds"),
|
||||||
// RocStr
|
RocStr
|
||||||
// );
|
);
|
||||||
// }
|
}
|
||||||
|
|
||||||
// #[test]
|
#[test]
|
||||||
// fn str_from_utf8_range_count_too_high() {
|
fn str_from_utf8_range_count_too_high() {
|
||||||
// assert_evals_to!(
|
assert_evals_to!(
|
||||||
// indoc!(
|
indoc!(
|
||||||
// r#"
|
r#"
|
||||||
// bytes = Str.toUtf8 "hello"
|
bytes = Str.toUtf8 "hello"
|
||||||
// when Str.fromUtf8Range bytes { start: 0, count: 6 } is
|
when Str.fromUtf8Range bytes { start: 0, count: 6 } is
|
||||||
// Ok _ -> ""
|
Ok _ -> ""
|
||||||
// Err (BadUtf8 _ _) -> ""
|
Err (BadUtf8 _ _) -> ""
|
||||||
// Err OutOfBounds -> "out of bounds"
|
Err OutOfBounds -> "out of bounds"
|
||||||
// "#
|
"#
|
||||||
// ),
|
),
|
||||||
// RocStr::from("out of bounds"),
|
RocStr::from("out of bounds"),
|
||||||
// RocStr
|
RocStr
|
||||||
// );
|
);
|
||||||
// }
|
}
|
||||||
|
|
||||||
// #[test]
|
#[test]
|
||||||
// fn str_from_utf8_range_count_too_high_for_start() {
|
fn str_from_utf8_range_count_too_high_for_start() {
|
||||||
// assert_evals_to!(
|
assert_evals_to!(
|
||||||
// indoc!(
|
indoc!(
|
||||||
// r#"
|
r#"
|
||||||
// bytes = Str.toUtf8 "hello"
|
bytes = Str.toUtf8 "hello"
|
||||||
// when Str.fromUtf8Range bytes { start: 4, count: 3 } is
|
when Str.fromUtf8Range bytes { start: 4, count: 3 } is
|
||||||
// Ok _ -> ""
|
Ok _ -> ""
|
||||||
// Err (BadUtf8 _ _) -> ""
|
Err (BadUtf8 _ _) -> ""
|
||||||
// Err OutOfBounds -> "out of bounds"
|
Err OutOfBounds -> "out of bounds"
|
||||||
// "#
|
"#
|
||||||
// ),
|
),
|
||||||
// RocStr::from("out of bounds"),
|
RocStr::from("out of bounds"),
|
||||||
// RocStr
|
RocStr
|
||||||
// );
|
);
|
||||||
// }
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn str_repeat_small() {
|
fn str_repeat_small() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue