mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 15:21:12 +00:00
Revise some tests
This commit is contained in:
parent
39249f3905
commit
db502fe2e7
3 changed files with 18 additions and 18 deletions
|
@ -1234,7 +1234,7 @@ fn clone_list<'a, 'ctx, 'env>(
|
||||||
|
|
||||||
// Allocate space for the new array that we'll copy into.
|
// Allocate space for the new array that we'll copy into.
|
||||||
let elem_type = basic_type_from_layout(env.arena, ctx, elem_layout, env.ptr_bytes);
|
let elem_type = basic_type_from_layout(env.arena, ctx, elem_layout, env.ptr_bytes);
|
||||||
let ptr_val = builder
|
let clone_ptr = builder
|
||||||
.build_array_malloc(elem_type, list_len, "list_ptr")
|
.build_array_malloc(elem_type, list_len, "list_ptr")
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
@ -1247,7 +1247,7 @@ fn clone_list<'a, 'ctx, 'env>(
|
||||||
//
|
//
|
||||||
// TODO how do we decide when to do the small memcpy vs the normal one?
|
// TODO how do we decide when to do the small memcpy vs the normal one?
|
||||||
builder
|
builder
|
||||||
.build_memcpy(ptr_val, ptr_bytes, elems_ptr, ptr_bytes, size)
|
.build_memcpy(clone_ptr, ptr_bytes, elems_ptr, ptr_bytes, size)
|
||||||
.unwrap_or_else(|err| {
|
.unwrap_or_else(|err| {
|
||||||
panic!("Error while attempting LLVM memcpy: {:?}", err);
|
panic!("Error while attempting LLVM memcpy: {:?}", err);
|
||||||
});
|
});
|
||||||
|
@ -1256,14 +1256,14 @@ fn clone_list<'a, 'ctx, 'env>(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a fresh wrapper struct for the newly populated array
|
// Create a fresh wrapper struct for the newly populated array
|
||||||
let struct_type = collection_wrapper(ctx, ptr_val.get_type(), env.ptr_bytes);
|
let struct_type = collection_wrapper(ctx, clone_ptr.get_type(), env.ptr_bytes);
|
||||||
let mut struct_val;
|
let mut struct_val;
|
||||||
|
|
||||||
// Store the pointer
|
// Store the pointer
|
||||||
struct_val = builder
|
struct_val = builder
|
||||||
.build_insert_value(
|
.build_insert_value(
|
||||||
struct_type.get_undef(),
|
struct_type.get_undef(),
|
||||||
ptr_val,
|
clone_ptr,
|
||||||
Builtin::WRAPPER_PTR,
|
Builtin::WRAPPER_PTR,
|
||||||
"insert_ptr",
|
"insert_ptr",
|
||||||
)
|
)
|
||||||
|
@ -1274,7 +1274,7 @@ fn clone_list<'a, 'ctx, 'env>(
|
||||||
.build_insert_value(struct_val, list_len, Builtin::WRAPPER_LEN, "insert_len")
|
.build_insert_value(struct_val, list_len, Builtin::WRAPPER_LEN, "insert_len")
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
(struct_val.into_struct_value(), ptr_val)
|
(struct_val.into_struct_value(), clone_ptr)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn bounds_check_comparison<'ctx>(
|
fn bounds_check_comparison<'ctx>(
|
||||||
|
|
|
@ -564,7 +564,7 @@ mod test_gen {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn set_unique_int_list() {
|
fn set_unique_int_list() {
|
||||||
assert_llvm_evals_to!(
|
assert_opt_evals_to!(
|
||||||
"List.set [ 12, 9, 7, 1, 5 ] 2 33",
|
"List.set [ 12, 9, 7, 1, 5 ] 2 33",
|
||||||
&[12, 9, 33, 1, 5],
|
&[12, 9, 33, 1, 5],
|
||||||
&'static [i64],
|
&'static [i64],
|
||||||
|
@ -574,42 +574,42 @@ mod test_gen {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn set_unique_list_oob() {
|
fn set_unique_list_oob() {
|
||||||
assert_llvm_evals_to!(
|
assert_opt_evals_to!(
|
||||||
"List.set [ 3, 17, 4 ] 1337 42",
|
"List.set [ 3, 17, 4.1 ] 1337 9.25",
|
||||||
&[3, 17, 4],
|
&[3.0, 17.0, 4.1],
|
||||||
&'static [i64],
|
&'static [f64],
|
||||||
|x| x
|
|x| x
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn set_shared_int_list() {
|
fn set_shared_int_list() {
|
||||||
assert_llvm_evals_to!(
|
assert_opt_evals_to!(
|
||||||
indoc!(
|
indoc!(
|
||||||
r#"
|
r#"
|
||||||
shared = [ 2, 4 ]
|
shared = [ 2.1, 4.3 ]
|
||||||
|
|
||||||
# This should not mutate the original
|
# This should not mutate the original
|
||||||
x = List.getUnsafe (List.set shared 1 77) 1
|
x = List.getUnsafe (List.set shared 1 7.7) 1
|
||||||
|
|
||||||
{ x, y: List.getUnsafe shared 1 }
|
{ x, y: List.getUnsafe shared 1 }
|
||||||
"#
|
"#
|
||||||
),
|
),
|
||||||
(77, 4),
|
(7.7, 4.3),
|
||||||
(i64, i64),
|
(f64, f64),
|
||||||
|x| x
|
|x| x
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn set_shared_list_oob() {
|
fn set_shared_list_oob() {
|
||||||
assert_llvm_evals_to!(
|
assert_opt_evals_to!(
|
||||||
indoc!(
|
indoc!(
|
||||||
r#"
|
r#"
|
||||||
shared = [ 2, 4 ]
|
shared = [ 2, 4 ]
|
||||||
|
|
||||||
# This should not mutate the original
|
# This should not mutate the original
|
||||||
x = List.getUnsafe (List.set shared 9000 77) 1
|
x = List.set shared 1 0
|
||||||
|
|
||||||
{ x, y: List.getUnsafe shared 1 }
|
{ x, y: List.getUnsafe shared 1 }
|
||||||
"#
|
"#
|
||||||
|
|
|
@ -276,7 +276,7 @@ mod test_opt {
|
||||||
shared = [ 2, 4 ]
|
shared = [ 2, 4 ]
|
||||||
|
|
||||||
# This should not mutate the original
|
# This should not mutate the original
|
||||||
x = List.set shared 1 77
|
x = List.set shared 1 0
|
||||||
|
|
||||||
{ x, y: List.getUnsafe shared 1 }
|
{ x, y: List.getUnsafe shared 1 }
|
||||||
"#,
|
"#,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue