Skip to content

Improve tests in scolapasta-fixable #2602

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

Merged
merged 1 commit into from
Jun 11, 2023
Merged

Conversation

lopopolo
Copy link
Member

@lopopolo lopopolo commented Jun 11, 2023

Test more boundary conditions, add comments, remove expensive u32 and i32 exhaustive tests.

As described by ChatGPT:

The code provided contains several test cases. Here is a summary of each test case:

  1. test_all_i8_are_fixable(): This test iterates over all values of type i8 and asserts that each value can be converted to a fixnum representation and is considered fixable.
  2. test_all_i16_are_fixable(): Similar to the previous test case, but for i16 values.
  3. test_i32_are_fixable(): This test verifies the fixability of specific i32 values, including the minimum and maximum values.
  4. test_i64_are_fixable(): This test covers a range of i64 values, including those below and above the range of fixable values.
  5. test_i128_are_fixable(): Similar to the previous test case, but for i128 values.
  6. all_u8_are_fixable(): This test ensures that all values of type u8 can be converted to a fixnum representation and are considered fixable.
  7. all_u16_are_fixable(): Similar to the previous test case, but for u16 values.
  8. test_u32_are_fixable(): This test verifies the fixability of specific u32 values, including the minimum and maximum values.
  9. test_u64_are_fixable(): This test covers a range of u64 values, including those within and outside the range of fixable values.
  10. test_u128_are_fixable(): Similar to the previous test case, but for u128 values.
  11. test_f32_are_fixable(): This test checks the fixability of various f32 values, including those within and outside the range of fixable values.
  12. test_f64_are_fixable(): Similar to the previous test case, but for f64 values.

Each test case contains assertions to verify the expected behavior of the conversion to fixnum and fixability of the values.

The tests that check for boundary conditions are important to ensure that the code handles edge cases correctly. Here are the key notes about these tests:

  • In the test_i64_are_fixable test, various test cases are provided to cover the entire range of i64 values. This includes the minimum value (i64::MIN), the maximum value (i64::MAX), and values near the boundaries of the fixable range (RUBY_FIXNUM_MIN, RUBY_FIXNUM_MAX).
  • Similarly, in the test_i128_are_fixable test, the test cases cover the entire range of i128 values. The focus is on values near the boundaries of the fixable range, including RUBY_FIXNUM_MIN and RUBY_FIXNUM_MAX.
  • The test_u64_are_fixable and test_u128_are_fixable tests also cover boundary conditions. They include values that are within the fixable range, values just above the fixable range, and values near the maximum representable unsigned integer values.
  • In the test_f32_are_fixable and test_f64_are_fixable tests, various floating-point values are used to test the behavior near the boundaries of the fixable range. This includes values close to the maximum and minimum representable floating-point values, as well as values with varying fractional parts.

These tests ensure that the code handles the boundary conditions correctly and produces the expected results for values at the limits of the fixable range.

@lopopolo lopopolo added A-core Area: Core traits and interpreter-agnostic Ruby Core and Ruby stdlib implementations. A-vm Area: Interpreter VM implementations. labels Jun 11, 2023
Test more boundary conditions, add comments, remove expensive u32 and i32 exhaustive tests.
@lopopolo lopopolo force-pushed the lopopolo/fixable-tests-boundary branch from f5d9ce1 to a592d45 Compare June 11, 2023 17:26
@lopopolo lopopolo merged commit 6f5ad40 into trunk Jun 11, 2023
@lopopolo lopopolo deleted the lopopolo/fixable-tests-boundary branch June 11, 2023 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-core Area: Core traits and interpreter-agnostic Ruby Core and Ruby stdlib implementations. A-vm Area: Interpreter VM implementations.
Development

Successfully merging this pull request may close these issues.

1 participant