Skip to content
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

Merged
merged 10 commits into from
Apr 14, 2022

Conversation

adpaco-aws
Copy link
Contributor

@adpaco-aws adpaco-aws commented Apr 13, 2022

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 a u64 value that comes from the typing context.

Testing:

  • How is this change tested? Adds 5 new tests.

  • Is this a refactor change? No.

Checklist

  • Each commit message has a non-empty body, explaining why the change was made
  • Methods or procedures are documented
  • Regression or unit tests are included, or existing tests cover the modified code
  • My PR is restricted to a single feature or bugfix

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.

@adpaco-aws adpaco-aws requested a review from a team as a code owner April 13, 2022 21:37
fn main() {
// Scalar types
let _ = type_id::<i8>();
let _ = type_id::<i16>();
Copy link
Contributor

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]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@adpaco-aws adpaco-aws merged commit b6a9a33 into model-checking:main Apr 14, 2022
@adpaco-aws adpaco-aws mentioned this pull request Apr 15, 2022
tedinski pushed a commit to tedinski/rmc that referenced this pull request Apr 22, 2022
* 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
tedinski pushed a commit to tedinski/rmc that referenced this pull request Apr 25, 2022
* 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
tedinski pushed a commit to tedinski/rmc that referenced this pull request Apr 26, 2022
* 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
tedinski pushed a commit that referenced this pull request Apr 27, 2022
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants