Skip to content

Organize and improve testing: math.zig #10930

@matu3ba

Description

@matu3ba

Background: Tests are separated in test/behavior/math.zig, lib/std/math.zig and (to mention for completeness) now for implementing stage2 also test/behaviror/int_div.zig.
This is not documented and it would be nice to be consistent with "tests to show usage" with "extensive tests for edge cases" per file.

Thus there are 3 solutions, if math.zig should remain like it is:

  1. Move all "extensive tests for edge cases" to test/behavior/math.zig and document it somewhere
  2. Move all "extensive tests for edge cases" to lib/std/math/ and document it somewhere
  3. Allow accurate control which test to run inside a file and have a convention how to prefix/name tests (requires additional implementation)

Aside of that, the following (reoccuring) possibly incomplete list of problems exist regarding test coverage:
general edge cases for division:

  • 0/1,-0/1, 1/1,-1/-1
  • max/max,min/min,max/min,min/max
  • 0/0, anynumber/0

div:

  • 15,14,13,12 / 3

divExact, edge cases not tested:

  • 55/-11

divFloor

  • divFloor(i32, -0x80000000, 1) == -0x80000000); -0x is unnecessary complex and unfortunately the default output of std.fmt
  • 2/-12, 0/12,0/-12,-0/12,-0/12 ?

similar problems exist for rem and mod

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementSolving this issue will likely involve adding new logic or components to the codebase.standard libraryThis issue involves writing Zig code for the standard library.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions