-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add tests for constant-evaluated intrinsics #1042
Conversation
fn main() { | ||
// Scalar types | ||
let _ = type_id::<i8>(); | ||
let _ = type_id::<i16>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would adding some asserts make sense, e.g.
let i8_tid = type_id::<i8>();
let i16_tid = type_id::<i16>();
assert_ne!(i8_tid, i16_tid)
?
If so, perhaps add one assert for every two consecutive types (one for (i8, i16), one for (i16, i32), etc.).
kani::assume(i < type_ids.len()); | ||
kani::assume(j < type_ids.len()); | ||
if i != j { | ||
assert_ne!(type_ids[i], type_ids[j]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
* Move test for `needs_drop` * Minor change to description in `needs_drop` test * Add test for `type_name` * Add test for `type_id` * Add test for `size_of` * Add test for `pref_align_of` * Add test for `min_align_of` * Include a comment for `codegen_intrinsic_const` * In `type_id` test, assert no duplicates
* Move test for `needs_drop` * Minor change to description in `needs_drop` test * Add test for `type_name` * Add test for `type_id` * Add test for `size_of` * Add test for `pref_align_of` * Add test for `min_align_of` * Include a comment for `codegen_intrinsic_const` * In `type_id` test, assert no duplicates
* Move test for `needs_drop` * Minor change to description in `needs_drop` test * Add test for `type_name` * Add test for `type_id` * Add test for `size_of` * Add test for `pref_align_of` * Add test for `min_align_of` * Include a comment for `codegen_intrinsic_const` * In `type_id` test, assert no duplicates
* Move test for `needs_drop` * Minor change to description in `needs_drop` test * Add test for `type_name` * Add test for `type_id` * Add test for `size_of` * Add test for `pref_align_of` * Add test for `min_align_of` * Include a comment for `codegen_intrinsic_const` * In `type_id` test, assert no duplicates
Description of changes:
Adds 6 tests (5 added, 1 moved) to the
ConstEval
folder for constant-evaluated intrinsics, which are the following:size_of
type_id
type_name
min_align_of
needs_drop
pref_align_of
The tests cover common data types. A comment for the macro that produces these values is also included.
Resolved issues:
Part of #727
Call-outs:
The test for
type_id
is not very strong. This is because the result is au64
value that comes from the typing context.Testing:
How is this change tested? Adds 5 new tests.
Is this a refactor change? No.
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.