File tree Expand file tree Collapse file tree 2 files changed +58
-8
lines changed Expand file tree Collapse file tree 2 files changed +58
-8
lines changed Original file line number Diff line number Diff line change @@ -68,6 +68,8 @@ extension SemanticVersion {
68
68
69
69
// Source: https://regex101.com/r/Ly7O1x/3/
70
70
// Linked from https://semver.org
71
+ #if swift(>=5)
72
+
71
73
let semVerRegex = NSRegularExpression ( #"""
72
74
^
73
75
v? # SPI extension: allow leading 'v'
@@ -91,3 +93,31 @@ v? # SPI extension: allow leading 'v'
91
93
)?
92
94
$
93
95
"""# , options: [ . allowCommentsAndWhitespace] )
96
+
97
+ #else
98
+
99
+ let semVerRegex = NSRegularExpression ( """
100
+ ^
101
+ v? # SPI extension: allow leading 'v'
102
+ (?<major>0|[1-9] \\ d*)
103
+ \\ .
104
+ (?<minor>0|[1-9] \\ d*)
105
+ \\ .
106
+ (?<patch>0|[1-9] \\ d*)
107
+ (?:-
108
+ (?<prerelease>
109
+ (?:0|[1-9] \\ d*| \\ d*[a-zA-Z-][0-9a-zA-Z-]*)
110
+ (?: \\ .
111
+ (?:0|[1-9] \\ d*| \\ d*[a-zA-Z-][0-9a-zA-Z-]*)
112
+ )
113
+ *)
114
+ )?
115
+ (?: \\ +
116
+ (?<buildmetadata>[0-9a-zA-Z-]+
117
+ (?: \\ .[0-9a-zA-Z-]+)
118
+ *)
119
+ )?
120
+ $
121
+ """ , options: [ . allowCommentsAndWhitespace] )
122
+
123
+ #endif
Original file line number Diff line number Diff line change 1
- //
2
- // File.swift
3
- //
4
- //
5
- // Created by Sven A. Schmidt on 01/09/2020.
6
- //
7
-
8
- import Foundation
1
+ #if swift(>=5)
2
+
3
+ #else
4
+
5
+ import XCTest
6
+
7
+ @testable import SemanticVersionTests
8
+
9
+ extension SemanticVersionTests {
10
+ static var allTests : [ ( String , ( SemanticVersionTests ) -> ( ) throws -> Void ) ] = [
11
+ ( " test_semVerRegex_valid " , test_semVerRegex_valid) ,
12
+ ( " test_allow_leading_v " , test_allow_leading_v) ,
13
+ ( " test_semVerRegex_invalid " , test_semVerRegex_invalid) ,
14
+ ( " test_init " , test_init) ,
15
+ ( " test_description " , test_description) ,
16
+ ( " test_Comparable " , test_Comparable) ,
17
+ ( " test_isStable " , test_isStable) ,
18
+ ( " test_isMajorRelease " , test_isMajorRelease) ,
19
+ ( " test_isMinorRelease " , test_isMinorRelease) ,
20
+ ( " test_isPatchRelease " , test_isPatchRelease) ,
21
+ ]
22
+ }
23
+
24
+ XCTMain ( [
25
+ testCase ( SemanticVersionTests . allTests)
26
+ ] )
27
+
28
+ #endif
You can’t perform that action at this time.
0 commit comments