Skip to content

[cxx-interop] Add tests for the available operations of std::iterator #42379

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

Conversation

cabmeurer
Copy link
Contributor

@cabmeurer cabmeurer commented Apr 14, 2022

Adding tests for the current supported operations to be used with std::iterator, which is currently just advance

@zoecarver @hyp

@cabmeurer
Copy link
Contributor Author

cabmeurer commented Apr 14, 2022

Was adding a test for std::distance however there seems to be an issue with the method import.

Test:

StdIteratorTestSuite.test("distance") {
    var vector = Vector()
    var _1: CInt = 1, _2: CInt = 2, _3: CInt = 3
    vector.push_back(&_1)
    vector.push_back(&_2)
    vector.push_back(&_3)
    let v = vector.beginMutating()
    let e = vector.endMutating()
    let d = std.__1.distance(v, e)
    expectEqual(d, 3)
}

std.__1.distance doesnt return a value, module dump output for the method:
static func distance<_InputIter>(_ __first: _InputIter, _ __last: _InputIter)

am i missing something?

@cabmeurer cabmeurer changed the title Add tests for the available operations of std::iterator [cxx-interop] Add tests for the available operations of std::iterator Apr 14, 2022
@cabmeurer cabmeurer force-pushed the cabmeurer/std-iterator-available-operations branch 3 times, most recently from 87585aa to 52c1663 Compare April 18, 2022 17:38
@cabmeurer cabmeurer requested a review from zoecarver April 18, 2022 17:38
@cabmeurer
Copy link
Contributor Author

Was adding a test for std::distance however there seems to be an issue with the method import.

Test:

StdIteratorTestSuite.test("distance") {
    var vector = Vector()
    var _1: CInt = 1, _2: CInt = 2, _3: CInt = 3
    vector.push_back(&_1)
    vector.push_back(&_2)
    vector.push_back(&_3)
    let v = vector.beginMutating()
    let e = vector.endMutating()
    let d = std.__1.distance(v, e)
    expectEqual(d, 3)
}

std.__1.distance doesnt return a value, module dump output for the method: static func distance<_InputIter>(_ __first: _InputIter, _ __last: _InputIter)

am i missing something?

Looks like a bug related to dependent return types, will investigate further after merging #42411

@cabmeurer cabmeurer force-pushed the cabmeurer/std-iterator-available-operations branch from 52c1663 to 7233635 Compare April 29, 2022 01:22
@cabmeurer
Copy link
Contributor Author

@zoecarver I spoke with @hyp about this during the office hours and added comments describing the issue with push_back.

@zoecarver
Copy link
Contributor

Looks like a bug related to dependent return types, will investigate further after merging #42411

Sounds good, thanks.

@zoecarver
Copy link
Contributor

@swift-ci please test

@zoecarver zoecarver merged commit cb76fa1 into swiftlang:main May 9, 2022
@cabmeurer cabmeurer deleted the cabmeurer/std-iterator-available-operations branch May 9, 2022 21:10
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