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

[stdlib] Add array_tester with Tester and Testee for lists #3565

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

rd4com
Copy link
Contributor

@rd4com rd4com commented Sep 29, 2024

Introducing two new types for testing lists and datastructures.
(Tester and Testee)

Testee can be used as the element type of an array or a similar datastructure.
Tester holds Int fields to count the amount of moves, copy, init, del.

Multiple instances of Testee contains an UnsafePointer to an instance of Tester.
Assertions can be created on the current amount of init, copy, del, moves a list does.

Additionally, Testee have an Int field to store a value.
That value can be used to check the equality of the elements of two lists.

Example:

def main():
    var _tester = Tester()
    var x = List[Testee]()
    for i in range(10):
        x.append(Testee(_tester, i))
    for i in x: print(i[].value)
    assert_equal(_tester.oninit, 10)
    assert_equal(_tester.ondelete, 0)
    assert_equal(_tester.oncopy, 0)
    y = x[0]
    assert_equal(y.value, 0)
    assert_equal(_tester.oncopy, 1)
    _ = x.pop()
    assert_equal(_tester.ondelete, 2)
    __type_of(x).__del__(x^)
    assert_equal(_tester.ondelete, 11)
    assert_equal(_tester.oncopy, 1)

@rd4com rd4com requested a review from a team as a code owner September 29, 2024 16:05
Copy link
Collaborator

@JoeLoser JoeLoser left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution! Can this be actively applied to any existing stdlib tests, or what's the motivation compared to some of the other test utils we have?

@JoeLoser JoeLoser added the waiting for response Needs action/response from contributor before a PR can proceed label Nov 22, 2024
@skongum02 skongum02 deleted the branch modular:main January 29, 2025 18:58
@skongum02 skongum02 closed this Jan 29, 2025
@skongum02 skongum02 reopened this Jan 29, 2025
@skongum02 skongum02 changed the base branch from nightly to main January 29, 2025 20:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting for response Needs action/response from contributor before a PR can proceed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants