Skip to content

Conversation

@natecook1000
Copy link
Member

What's in this pull request?

This updates the tests for substrings to include sharing indices with string view slices. The tests are currently xfail'd for CharacterView, UnicodeScalarView, and UTF16View.

Current test output:

[ RUN      ] SubstringTests.String
[       OK ] SubstringTests.String
[ RUN      ] SubstringTests.CharacterView (XFAIL: [Always(reason: CharacterView slices don't share indices)])
stdout>>> check failed at ...swift/test/1_stdlib/subString.swift, line 16
stdout>>> expected: "a" (of type Swift.Character)
stdout>>> actual: "c" (of type Swift.Character)
stdout>>> check failed at ...swift/test/1_stdlib/subString.swift, line 16
stdout>>> expected: "b" (of type Swift.Character)
stdout>>> actual: "d" (of type Swift.Character)
stdout>>> check failed at ...swift/test/1_stdlib/subString.swift, line 16
stdout>>> expected: "e" (of type Swift.Character)
stdout>>> actual: "g" (of type Swift.Character)
stdout>>> check failed at ...swift/test/1_stdlib/subString.swift, line 16
stdout>>> expected: "a" (of type Swift.Character)
stdout>>> actual: "C" (of type Swift.Character)
stdout>>> check failed at ...swift/test/1_stdlib/subString.swift, line 16
stdout>>> expected: "C" (of type Swift.Character)
stdout>>> actual: "e" (of type Swift.Character)
stdout>>> check failed at ...swift/test/1_stdlib/subString.swift, line 16
stdout>>> expected: "d" (of type Swift.Character)
stdout>>> actual: "f" (of type Swift.Character)
stdout>>> check failed at ...swift/test/1_stdlib/subString.swift, line 16
stdout>>> expected: "e" (of type Swift.Character)
stdout>>> actual: "g" (of type Swift.Character)
[    XFAIL ] SubstringTests.CharacterView
[ RUN      ] SubstringTests.UnicodeScalars (XFAIL: [Always(reason: UnicodeScalarsView slices don't share indices)])
stdout>>> check failed at ...swift/test/1_stdlib/subString.swift, line 16
stdout>>> expected: "a" (of type Swift.UnicodeScalar)
stdout>>> actual: "c" (of type Swift.UnicodeScalar)
stdout>>> check failed at ...swift/test/1_stdlib/subString.swift, line 16
stdout>>> expected: "b" (of type Swift.UnicodeScalar)
stdout>>> actual: "d" (of type Swift.UnicodeScalar)
stdout>>> check failed at ...swift/test/1_stdlib/subString.swift, line 16
stdout>>> expected: "e" (of type Swift.UnicodeScalar)
stdout>>> actual: "g" (of type Swift.UnicodeScalar)
stdout>>> check failed at ...swift/test/1_stdlib/subString.swift, line 16
stdout>>> expected: "a" (of type Swift.UnicodeScalar)
stdout>>> actual: "C" (of type Swift.UnicodeScalar)
stdout>>> check failed at ...swift/test/1_stdlib/subString.swift, line 16
stdout>>> expected: "C" (of type Swift.UnicodeScalar)
stdout>>> actual: "e" (of type Swift.UnicodeScalar)
stdout>>> check failed at ...swift/test/1_stdlib/subString.swift, line 16
stdout>>> expected: "d" (of type Swift.UnicodeScalar)
stdout>>> actual: "f" (of type Swift.UnicodeScalar)
stdout>>> check failed at ...swift/test/1_stdlib/subString.swift, line 16
stdout>>> expected: "e" (of type Swift.UnicodeScalar)
stdout>>> actual: "g" (of type Swift.UnicodeScalar)
[    XFAIL ] SubstringTests.UnicodeScalars
[ RUN      ] SubstringTests.UTF16View (XFAIL: [Always(reason: UTF16View slices don't share indices)])
stdout>>> check failed at ...swift/test/1_stdlib/subString.swift, line 16
stdout>>> expected: 97 (of type Swift.UInt16)
stdout>>> actual: 99 (of type Swift.UInt16)
stdout>>> check failed at ...swift/test/1_stdlib/subString.swift, line 16
stdout>>> expected: 98 (of type Swift.UInt16)
stdout>>> actual: 100 (of type Swift.UInt16)
stdout>>> check failed at ...swift/test/1_stdlib/subString.swift, line 16
stdout>>> expected: 101 (of type Swift.UInt16)
stdout>>> actual: 103 (of type Swift.UInt16)
stdout>>> check failed at ...swift/test/1_stdlib/subString.swift, line 16
stdout>>> expected: 97 (of type Swift.UInt16)
stdout>>> actual: 99 (of type Swift.UInt16)
stdout>>> check failed at ...swift/test/1_stdlib/subString.swift, line 16
stdout>>> expected: 99 (of type Swift.UInt16)
stdout>>> actual: 101 (of type Swift.UInt16)
stdout>>> check failed at ...swift/test/1_stdlib/subString.swift, line 16
stdout>>> expected: 100 (of type Swift.UInt16)
stdout>>> actual: 102 (of type Swift.UInt16)
stdout>>> check failed at ...swift/test/1_stdlib/subString.swift, line 16
stdout>>> expected: 101 (of type Swift.UInt16)
stdout>>> actual: 103 (of type Swift.UInt16)
[    XFAIL ] SubstringTests.UTF16View
[ RUN      ] SubstringTests.UTF8View
[       OK ] SubstringTests.UTF8View
SubstringTests: All tests passed
#### Resolved bug number: n/a

Before merging this pull request to apple/swift repository:

  • Test pull request on Swift continuous integration.

Triggering Swift CI

The swift-ci is triggered by writing a comment on this PR addressed to the GitHub user @swift-ci. Different tests will run depending on the specific comment that you use. The currently available comments are:

Smoke Testing

Platform Comment
All supported platforms @swift-ci Please smoke test
OS X platform @swift-ci Please smoke test OS X platform
Linux platform @swift-ci Please smoke test Linux platform

Validation Testing

Platform Comment
All supported platforms @swift-ci Please test
OS X platform @swift-ci Please test OS X platform
Linux platform @swift-ci Please test Linux platform

Note: Only members of the Apple organization can trigger swift-ci.

expectEqual(x[i], y[i])
}

let s = "abcdefg"
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you move this variable into each test that uses it? This would make tests standalone.

@gribozavr
Copy link
Contributor

Thanks @natecook1000!

expectEqual(String(t), "Cdefg")
expectEqual(s, "abcdefg")

checkMatch(s.characters, t, u.startIndex)
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this is a valid assertion. t has been mutated before the position referenced by u.startIndex

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point—I'll change it so it only tests string equality after a mutation. The mutations are there to ensure value semantics post-fix; those all pass today.

Copy link
Contributor

@gribozavr gribozavr May 2, 2016

Choose a reason for hiding this comment

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

Checking that indices are interchangeable after mutation is a valid thing to do, we just need to mutate the tail part of the string that occurs after the index position.

expectEqual(String(t), "Cdefg")
expectEqual(s, "abcdefg")

checkMatch(s.unicodeScalars, t, u.startIndex)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above?

Copy link
Member Author

Choose a reason for hiding this comment

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

Both groups should be fixed now.

@gribozavr
Copy link
Contributor

@swift-ci Please test and merge

1 similar comment
@natecook1000
Copy link
Member Author

@swift-ci Please test and merge

@tkremenek
Copy link
Member

@swift-ci test

@gribozavr
Copy link
Contributor

CI issues are unrelated.

@gribozavr gribozavr merged commit e4614ee into swiftlang:master May 5, 2016
@natecook1000 natecook1000 deleted the nc-string-test branch January 5, 2017 06:46
MaxDesiatov pushed a commit that referenced this pull request Apr 19, 2021
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.

3 participants