File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change
1
+ // RUN: %empty-directory(%t)
2
+ // RUN: %target-build-swift %s -o %t/a.out3 -swift-version 3 && %target-run %t/a.out3
3
+ // RUN: %target-build-swift %s -o %t/a.out4 -swift-version 4 && %target-run %t/a.out4
4
+ // RUN: %target-build-swift %s -o %t/a.out5 -swift-version 5 && %target-run %t/a.out5
5
+ // REQUIRES: executable_test
6
+
7
+ import StdlibUnittest
8
+
9
+ #if swift(>=4.2)
10
+ let swiftVersion = " >=4.2 "
11
+ #else
12
+ let swiftVersion = " <4.2 "
13
+ #endif
14
+
15
+ let tests = TestSuite ( " ReverseCompatibility " )
16
+
17
+ tests. test ( " Double reverse type/Collection/ \( swiftVersion) " ) {
18
+ func reverse< C : BidirectionalCollection > ( _ xs: C ) {
19
+ var result = xs. reversed ( ) . reversed ( )
20
+ #if swift(>=4.2)
21
+ expectType ( C . self, & result)
22
+ #else
23
+ expectType ( ReversedCollection< ReversedCollection< C>>. self , & result)
24
+ #endif
25
+ }
26
+ reverse ( Array ( 0 ..< 10 ) )
27
+
28
+ func backwardCompatible< C : BidirectionalCollection > ( _ xs: C ) {
29
+ typealias ExpectedType = ReversedCollection < ReversedCollection < C > >
30
+ var result : ExpectedType = xs. reversed ( ) . reversed ( )
31
+ expectType ( ExpectedType . self, & result)
32
+ }
33
+ backwardCompatible ( Array ( 0 ..< 10 ) )
34
+ }
You can’t perform that action at this time.
0 commit comments