versionomy 0.4.1 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.rdoc +4 -0
- data/Version +1 -1
- data/lib/versionomy.rb +19 -25
- data/lib/versionomy/conversion.rb +41 -41
- data/lib/versionomy/conversion/base.rb +31 -31
- data/lib/versionomy/conversion/parsing.rb +49 -49
- data/lib/versionomy/errors.rb +63 -63
- data/lib/versionomy/format.rb +51 -51
- data/lib/versionomy/format/base.rb +44 -44
- data/lib/versionomy/format/delimiter.rb +205 -205
- data/lib/versionomy/format_definitions/rubygems.rb +85 -85
- data/lib/versionomy/format_definitions/semver.rb +78 -78
- data/lib/versionomy/format_definitions/standard.rb +68 -68
- data/lib/versionomy/interface.rb +46 -46
- data/lib/versionomy/schema.rb +21 -21
- data/lib/versionomy/schema/field.rb +112 -112
- data/lib/versionomy/schema/wrapper.rb +91 -91
- data/lib/versionomy/value.rb +224 -180
- data/lib/versionomy/version.rb +9 -9
- data/test/tc_custom_format.rb +14 -14
- data/test/tc_readme_examples.rb +24 -24
- data/test/tc_rubygems_basic.rb +68 -68
- data/test/tc_rubygems_conversions.rb +46 -46
- data/test/tc_semver_basic.rb +62 -62
- data/test/tc_semver_conversions.rb +52 -52
- data/test/tc_standard_basic.rb +35 -35
- data/test/tc_standard_bump.rb +35 -35
- data/test/tc_standard_change.rb +20 -20
- data/test/tc_standard_comparison.rb +38 -38
- data/test/tc_standard_misc.rb +23 -23
- data/test/tc_standard_parse.rb +77 -77
- data/test/tc_standard_reset.rb +29 -29
- data/test/tc_version_of.rb +15 -15
- metadata +30 -34
data/test/tc_standard_change.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
# -----------------------------------------------------------------------------
|
2
|
-
#
|
2
|
+
#
|
3
3
|
# Versionomy change tests on standard schema
|
4
|
-
#
|
4
|
+
#
|
5
5
|
# This file contains tests for the change function on the standard schema
|
6
|
-
#
|
6
|
+
#
|
7
7
|
# -----------------------------------------------------------------------------
|
8
8
|
# Copyright 2008-2009 Daniel Azuma
|
9
|
-
#
|
9
|
+
#
|
10
10
|
# All rights reserved.
|
11
|
-
#
|
11
|
+
#
|
12
12
|
# Redistribution and use in source and binary forms, with or without
|
13
13
|
# modification, are permitted provided that the following conditions are met:
|
14
|
-
#
|
14
|
+
#
|
15
15
|
# * Redistributions of source code must retain the above copyright notice,
|
16
16
|
# this list of conditions and the following disclaimer.
|
17
17
|
# * Redistributions in binary form must reproduce the above copyright notice,
|
@@ -20,7 +20,7 @@
|
|
20
20
|
# * Neither the name of the copyright holder, nor the names of any other
|
21
21
|
# contributors to this software, may be used to endorse or promote products
|
22
22
|
# derived from this software without specific prior written permission.
|
23
|
-
#
|
23
|
+
#
|
24
24
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
25
25
|
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
26
26
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
@@ -41,12 +41,12 @@ require 'versionomy'
|
|
41
41
|
|
42
42
|
module Versionomy
|
43
43
|
module Tests # :nodoc:
|
44
|
-
|
44
|
+
|
45
45
|
class TestStandardChange < ::Test::Unit::TestCase # :nodoc:
|
46
|
-
|
47
|
-
|
46
|
+
|
47
|
+
|
48
48
|
# Test with a changed tiny
|
49
|
-
|
49
|
+
|
50
50
|
def test_change_tiny
|
51
51
|
value_ = ::Versionomy.create(:major => 2, :tiny => 1, :tiny2 => 3, :release_type => :release_candidate, :release_candidate_version => 2)
|
52
52
|
value_ = value_.change(:tiny => 4)
|
@@ -58,10 +58,10 @@ module Versionomy
|
|
58
58
|
assert_equal(2, value_.release_candidate_version)
|
59
59
|
assert_equal(0, value_.release_candidate_minor)
|
60
60
|
end
|
61
|
-
|
62
|
-
|
61
|
+
|
62
|
+
|
63
63
|
# Test with several changed fields
|
64
|
-
|
64
|
+
|
65
65
|
def test_change_several
|
66
66
|
value_ = ::Versionomy.create(:major => 2, :tiny => 1, :tiny2 => 3, :release_type => :release_candidate, :release_candidate_version => 2)
|
67
67
|
value_ = value_.change(:tiny => 4, :release_candidate_version => 5)
|
@@ -73,10 +73,10 @@ module Versionomy
|
|
73
73
|
assert_equal(5, value_.release_candidate_version)
|
74
74
|
assert_equal(0, value_.release_candidate_minor)
|
75
75
|
end
|
76
|
-
|
77
|
-
|
76
|
+
|
77
|
+
|
78
78
|
# Test with a changed release type
|
79
|
-
|
79
|
+
|
80
80
|
def test_change_release_type
|
81
81
|
value_ = ::Versionomy.create(:major => 2, :tiny => 1, :tiny2 => 3, :release_type => :release_candidate, :release_candidate_version => 2)
|
82
82
|
value_ = value_.change(:release_type => :beta)
|
@@ -90,9 +90,9 @@ module Versionomy
|
|
90
90
|
assert_equal(false, value_.has_field?(:release_candidate_version))
|
91
91
|
assert_equal(false, value_.has_field?(:release_candidate_minor))
|
92
92
|
end
|
93
|
-
|
94
|
-
|
93
|
+
|
94
|
+
|
95
95
|
end
|
96
|
-
|
96
|
+
|
97
97
|
end
|
98
98
|
end
|
@@ -1,17 +1,17 @@
|
|
1
1
|
# -----------------------------------------------------------------------------
|
2
|
-
#
|
2
|
+
#
|
3
3
|
# Versionomy comparison tests on standard schema
|
4
|
-
#
|
4
|
+
#
|
5
5
|
# This file contains tests for comparisons on the standard schema
|
6
|
-
#
|
6
|
+
#
|
7
7
|
# -----------------------------------------------------------------------------
|
8
8
|
# Copyright 2008-2009 Daniel Azuma
|
9
|
-
#
|
9
|
+
#
|
10
10
|
# All rights reserved.
|
11
|
-
#
|
11
|
+
#
|
12
12
|
# Redistribution and use in source and binary forms, with or without
|
13
13
|
# modification, are permitted provided that the following conditions are met:
|
14
|
-
#
|
14
|
+
#
|
15
15
|
# * Redistributions of source code must retain the above copyright notice,
|
16
16
|
# this list of conditions and the following disclaimer.
|
17
17
|
# * Redistributions in binary form must reproduce the above copyright notice,
|
@@ -20,7 +20,7 @@
|
|
20
20
|
# * Neither the name of the copyright holder, nor the names of any other
|
21
21
|
# contributors to this software, may be used to endorse or promote products
|
22
22
|
# derived from this software without specific prior written permission.
|
23
|
-
#
|
23
|
+
#
|
24
24
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
25
25
|
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
26
26
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
@@ -41,78 +41,78 @@ require 'versionomy'
|
|
41
41
|
|
42
42
|
module Versionomy
|
43
43
|
module Tests # :nodoc:
|
44
|
-
|
44
|
+
|
45
45
|
class TestStandardComparison < ::Test::Unit::TestCase # :nodoc:
|
46
|
-
|
47
|
-
|
46
|
+
|
47
|
+
|
48
48
|
# Test comparisons with difference in major.
|
49
|
-
|
49
|
+
|
50
50
|
def test_comparison_major
|
51
51
|
value1_ = ::Versionomy.create(:major => 2, :tiny => 1, :tiny2 => 3, :release_type => :release_candidate, :release_candidate_version => 2)
|
52
52
|
value2_ = ::Versionomy.create(:major => 3, :release_type => :alpha)
|
53
53
|
assert(value2_ > value1_)
|
54
54
|
end
|
55
|
-
|
56
|
-
|
55
|
+
|
56
|
+
|
57
57
|
# Test comparisons with difference in minor.
|
58
|
-
|
58
|
+
|
59
59
|
def test_comparison_minor
|
60
60
|
value1_ = ::Versionomy.create(:major => 2, :tiny => 1, :tiny2 => 3, :release_type => :release_candidate, :release_candidate_version => 2)
|
61
61
|
value2_ = ::Versionomy.create(:major => 2, :minor => 1, :release_type => :alpha)
|
62
62
|
assert(value2_ > value1_)
|
63
63
|
end
|
64
|
-
|
65
|
-
|
64
|
+
|
65
|
+
|
66
66
|
# Test comparisons with difference in release type.
|
67
|
-
|
67
|
+
|
68
68
|
def test_comparison_release_type
|
69
69
|
value1_ = ::Versionomy.create(:major => 2, :release_type => :alpha, :alpha_version => 5)
|
70
70
|
value2_ = ::Versionomy.create(:major => 2, :release_type => :release_candidate, :release_candidate_version => 2)
|
71
71
|
assert(value2_ > value1_)
|
72
72
|
end
|
73
|
-
|
74
|
-
|
73
|
+
|
74
|
+
|
75
75
|
# Test equality for a simple case.
|
76
|
-
|
76
|
+
|
77
77
|
def test_equality_simple
|
78
78
|
value1_ = ::Versionomy.create(:major => 2, :minor => 0, :release_type => :alpha, :alpha_version => 5)
|
79
79
|
value2_ = ::Versionomy.create(:major => 2, :release_type => :alpha, :alpha_version => 5)
|
80
80
|
assert_equal(value2_, value1_)
|
81
81
|
assert_equal(value2_.hash, value1_.hash)
|
82
82
|
end
|
83
|
-
|
84
|
-
|
83
|
+
|
84
|
+
|
85
85
|
# Test equality from parsed values.
|
86
|
-
|
86
|
+
|
87
87
|
def test_equality_parsed
|
88
88
|
value1_ = ::Versionomy.parse("1.8.7p72")
|
89
89
|
value2_ = ::Versionomy.parse("1.8.7.0-72.0")
|
90
90
|
assert_equal(value2_, value1_)
|
91
91
|
assert_equal(value2_.hash, value1_.hash)
|
92
92
|
end
|
93
|
-
|
94
|
-
|
93
|
+
|
94
|
+
|
95
95
|
# Test non-equality from parsed values.
|
96
|
-
|
96
|
+
|
97
97
|
def test_nonequality_parsed
|
98
98
|
value1_ = ::Versionomy.parse("1.8.7b7")
|
99
99
|
value2_ = ::Versionomy.parse("1.8.7a7")
|
100
100
|
assert_not_equal(value2_, value1_)
|
101
101
|
assert_not_equal(value2_.hash, value1_.hash)
|
102
102
|
end
|
103
|
-
|
104
|
-
|
103
|
+
|
104
|
+
|
105
105
|
# Test equality with string.
|
106
|
-
|
106
|
+
|
107
107
|
def test_equality_string
|
108
108
|
value1_ = ::Versionomy.parse("1.8.7p72")
|
109
109
|
assert_operator(value1_, :==, "1.8.7p72")
|
110
110
|
assert_operator(value1_, :==, "1.8.7.0-72.0")
|
111
111
|
end
|
112
|
-
|
113
|
-
|
112
|
+
|
113
|
+
|
114
114
|
# Test comparison with string.
|
115
|
-
|
115
|
+
|
116
116
|
def test_comparison_string
|
117
117
|
value1_ = ::Versionomy.parse("1.8.7p72")
|
118
118
|
assert_operator(value1_, :<, "1.8.7p73")
|
@@ -121,10 +121,10 @@ module Versionomy
|
|
121
121
|
assert_operator(value1_, :>, "1.8.7rc2")
|
122
122
|
assert_operator(value1_, :>, "1.8.7.0")
|
123
123
|
end
|
124
|
-
|
125
|
-
|
124
|
+
|
125
|
+
|
126
126
|
# Test sorting.
|
127
|
-
|
127
|
+
|
128
128
|
def test_sort
|
129
129
|
value1_ = ::Versionomy.parse("1.8.7p73")
|
130
130
|
value2_ = ::Versionomy.parse("1.8.7p72")
|
@@ -134,9 +134,9 @@ module Versionomy
|
|
134
134
|
assert_equal([value5_, value4_, value2_, value1_, value3_],
|
135
135
|
[value1_, value2_, value3_, value4_, value5_].sort)
|
136
136
|
end
|
137
|
-
|
138
|
-
|
137
|
+
|
138
|
+
|
139
139
|
end
|
140
|
-
|
140
|
+
|
141
141
|
end
|
142
142
|
end
|
data/test/tc_standard_misc.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
# -----------------------------------------------------------------------------
|
2
|
-
#
|
2
|
+
#
|
3
3
|
# Versionomy basic tests on standard schema
|
4
|
-
#
|
4
|
+
#
|
5
5
|
# This file contains tests for the basic use cases on the standard schema
|
6
|
-
#
|
6
|
+
#
|
7
7
|
# -----------------------------------------------------------------------------
|
8
8
|
# Copyright 2008-2009 Daniel Azuma
|
9
|
-
#
|
9
|
+
#
|
10
10
|
# All rights reserved.
|
11
|
-
#
|
11
|
+
#
|
12
12
|
# Redistribution and use in source and binary forms, with or without
|
13
13
|
# modification, are permitted provided that the following conditions are met:
|
14
|
-
#
|
14
|
+
#
|
15
15
|
# * Redistributions of source code must retain the above copyright notice,
|
16
16
|
# this list of conditions and the following disclaimer.
|
17
17
|
# * Redistributions in binary form must reproduce the above copyright notice,
|
@@ -20,7 +20,7 @@
|
|
20
20
|
# * Neither the name of the copyright holder, nor the names of any other
|
21
21
|
# contributors to this software, may be used to endorse or promote products
|
22
22
|
# derived from this software without specific prior written permission.
|
23
|
-
#
|
23
|
+
#
|
24
24
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
25
25
|
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
26
26
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
@@ -41,12 +41,12 @@ require 'versionomy'
|
|
41
41
|
|
42
42
|
module Versionomy
|
43
43
|
module Tests # :nodoc:
|
44
|
-
|
44
|
+
|
45
45
|
class TestStandardMisc < ::Test::Unit::TestCase # :nodoc:
|
46
|
-
|
47
|
-
|
46
|
+
|
47
|
+
|
48
48
|
# Test "prerelase?" custom method
|
49
|
-
|
49
|
+
|
50
50
|
def test_method_prereleasep
|
51
51
|
value_ = ::Versionomy.create(:major => 2, :tiny => 1, :release_type => :beta, :beta_version => 3)
|
52
52
|
assert_equal(true, value_.prerelease?)
|
@@ -55,10 +55,10 @@ module Versionomy
|
|
55
55
|
value_ = ::Versionomy.create(:major => 2, :tiny => 1)
|
56
56
|
assert_equal(false, value_.prerelease?)
|
57
57
|
end
|
58
|
-
|
59
|
-
|
58
|
+
|
59
|
+
|
60
60
|
# Test "relase" custom method
|
61
|
-
|
61
|
+
|
62
62
|
def test_method_release
|
63
63
|
value_ = ::Versionomy.create(:major => 1, :minor => 9, :tiny => 2, :release_type => :alpha, :alpha_version => 4)
|
64
64
|
value2_ = value_.release
|
@@ -67,29 +67,29 @@ module Versionomy
|
|
67
67
|
value2_ = value_.release
|
68
68
|
assert_equal(value_, value2_)
|
69
69
|
end
|
70
|
-
|
71
|
-
|
70
|
+
|
71
|
+
|
72
72
|
# Test marshalling
|
73
|
-
|
73
|
+
|
74
74
|
def test_marshal
|
75
75
|
value_ = ::Versionomy.create(:major => 1, :minor => 9, :tiny => 2, :release_type => :alpha, :alpha_version => 4)
|
76
76
|
str_ = ::Marshal.dump(value_)
|
77
77
|
value2_ = ::Marshal.load(str_)
|
78
78
|
assert_equal(value_, value2_)
|
79
79
|
end
|
80
|
-
|
81
|
-
|
80
|
+
|
81
|
+
|
82
82
|
# Test YAML
|
83
|
-
|
83
|
+
|
84
84
|
def test_yaml
|
85
85
|
value_ = ::Versionomy.create(:major => 1, :minor => 9, :tiny => 2, :release_type => :alpha, :alpha_version => 4)
|
86
86
|
str_ = ::YAML.dump(value_)
|
87
87
|
value2_ = ::YAML.load(str_)
|
88
88
|
assert_equal(value_, value2_)
|
89
89
|
end
|
90
|
-
|
91
|
-
|
90
|
+
|
91
|
+
|
92
92
|
end
|
93
|
-
|
93
|
+
|
94
94
|
end
|
95
95
|
end
|
data/test/tc_standard_parse.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
# -----------------------------------------------------------------------------
|
2
|
-
#
|
2
|
+
#
|
3
3
|
# Versionomy parsing tests on standard schema
|
4
|
-
#
|
4
|
+
#
|
5
5
|
# This file contains tests for parsing on the standard schema
|
6
|
-
#
|
6
|
+
#
|
7
7
|
# -----------------------------------------------------------------------------
|
8
8
|
# Copyright 2008-2009 Daniel Azuma
|
9
|
-
#
|
9
|
+
#
|
10
10
|
# All rights reserved.
|
11
|
-
#
|
11
|
+
#
|
12
12
|
# Redistribution and use in source and binary forms, with or without
|
13
13
|
# modification, are permitted provided that the following conditions are met:
|
14
|
-
#
|
14
|
+
#
|
15
15
|
# * Redistributions of source code must retain the above copyright notice,
|
16
16
|
# this list of conditions and the following disclaimer.
|
17
17
|
# * Redistributions in binary form must reproduce the above copyright notice,
|
@@ -20,7 +20,7 @@
|
|
20
20
|
# * Neither the name of the copyright holder, nor the names of any other
|
21
21
|
# contributors to this software, may be used to endorse or promote products
|
22
22
|
# derived from this software without specific prior written permission.
|
23
|
-
#
|
23
|
+
#
|
24
24
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
25
25
|
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
26
26
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
@@ -41,12 +41,12 @@ require 'versionomy'
|
|
41
41
|
|
42
42
|
module Versionomy
|
43
43
|
module Tests # :nodoc:
|
44
|
-
|
44
|
+
|
45
45
|
class TestStandardParse < ::Test::Unit::TestCase # :nodoc:
|
46
|
-
|
47
|
-
|
46
|
+
|
47
|
+
|
48
48
|
# Test parsing full.
|
49
|
-
|
49
|
+
|
50
50
|
def test_parsing_full_release
|
51
51
|
value_ = ::Versionomy.parse('2.0.1.1-4.6')
|
52
52
|
assert_equal(2, value_.major)
|
@@ -58,10 +58,10 @@ module Versionomy
|
|
58
58
|
assert_equal(6, value_.patchlevel_minor)
|
59
59
|
assert_equal('2.0.1.1-4.6', value_.unparse)
|
60
60
|
end
|
61
|
-
|
62
|
-
|
61
|
+
|
62
|
+
|
63
63
|
# Test parsing abbreviated.
|
64
|
-
|
64
|
+
|
65
65
|
def test_parsing_abbrev_release
|
66
66
|
value_ = ::Versionomy.parse('2.0.1')
|
67
67
|
assert_equal(2, value_.major)
|
@@ -75,10 +75,10 @@ module Versionomy
|
|
75
75
|
assert_equal('2.0.1-0', value_.unparse(:required_fields => [:minor, :patchlevel]))
|
76
76
|
assert_equal('2.0.1', value_.unparse)
|
77
77
|
end
|
78
|
-
|
79
|
-
|
78
|
+
|
79
|
+
|
80
80
|
# Test parsing with trailing zeros.
|
81
|
-
|
81
|
+
|
82
82
|
def test_parsing_trailing_zeros
|
83
83
|
value_ = ::Versionomy.parse('2.0.0')
|
84
84
|
assert_equal(2, value_.major)
|
@@ -90,10 +90,10 @@ module Versionomy
|
|
90
90
|
assert_equal(0, value_.patchlevel_minor)
|
91
91
|
assert_equal('2.0.0', value_.unparse)
|
92
92
|
end
|
93
|
-
|
94
|
-
|
93
|
+
|
94
|
+
|
95
95
|
# Test parsing with leading zeros on a field.
|
96
|
-
|
96
|
+
|
97
97
|
def test_parsing_field_leading_zeros
|
98
98
|
value_ = ::Versionomy.parse('2.09')
|
99
99
|
assert_equal(2, value_.major)
|
@@ -113,10 +113,10 @@ module Versionomy
|
|
113
113
|
assert_equal(0, value_.minor)
|
114
114
|
assert_equal('2.00', value_.unparse)
|
115
115
|
end
|
116
|
-
|
117
|
-
|
116
|
+
|
117
|
+
|
118
118
|
# Test unparsing with a minimum width.
|
119
|
-
|
119
|
+
|
120
120
|
def test_unparsing_minimum_width_field
|
121
121
|
value_ = ::Versionomy.parse('2.0')
|
122
122
|
assert_equal('2.0', value_.unparse)
|
@@ -129,10 +129,10 @@ module Versionomy
|
|
129
129
|
assert_equal('2.12', value_.unparse)
|
130
130
|
assert_equal('2.12', value_.unparse(:minor_width => 1))
|
131
131
|
end
|
132
|
-
|
133
|
-
|
132
|
+
|
133
|
+
|
134
134
|
# Test parsing major version only.
|
135
|
-
|
135
|
+
|
136
136
|
def test_parsing_major_only
|
137
137
|
value_ = ::Versionomy.parse('2')
|
138
138
|
assert_equal(2, value_.major)
|
@@ -144,10 +144,10 @@ module Versionomy
|
|
144
144
|
assert_equal(0, value_.patchlevel_minor)
|
145
145
|
assert_equal('2', value_.unparse)
|
146
146
|
end
|
147
|
-
|
148
|
-
|
147
|
+
|
148
|
+
|
149
149
|
# Test parsing preview.
|
150
|
-
|
150
|
+
|
151
151
|
def test_parsing_preview
|
152
152
|
value_ = ::Versionomy.parse('2.0.1pre4')
|
153
153
|
assert_equal(2, value_.major)
|
@@ -160,10 +160,10 @@ module Versionomy
|
|
160
160
|
assert_equal('2.0.1pre4', value_.unparse)
|
161
161
|
assert_equal('2.0.1pre4.0', value_.unparse(:required_fields => [:preview_minor]))
|
162
162
|
end
|
163
|
-
|
164
|
-
|
163
|
+
|
164
|
+
|
165
165
|
# Test parsing alpha.
|
166
|
-
|
166
|
+
|
167
167
|
def test_parsing_alpha
|
168
168
|
value_ = ::Versionomy.parse('2.0.1a4.1')
|
169
169
|
assert_equal(2, value_.major)
|
@@ -176,10 +176,10 @@ module Versionomy
|
|
176
176
|
assert_equal('2.0.1a4.1', value_.unparse)
|
177
177
|
assert_equal('2.0.1a4.1', value_.unparse(:optional_fields => [:alpha_minor]))
|
178
178
|
end
|
179
|
-
|
180
|
-
|
179
|
+
|
180
|
+
|
181
181
|
# Test parsing beta.
|
182
|
-
|
182
|
+
|
183
183
|
def test_parsing_beta
|
184
184
|
value_ = ::Versionomy.parse('2.52.1b4.0')
|
185
185
|
assert_equal(2, value_.major)
|
@@ -192,10 +192,10 @@ module Versionomy
|
|
192
192
|
assert_equal('2.52.1b4.0', value_.unparse)
|
193
193
|
assert_equal('2.52.1b4', value_.unparse(:optional_fields => [:beta_minor]))
|
194
194
|
end
|
195
|
-
|
196
|
-
|
195
|
+
|
196
|
+
|
197
197
|
# Test parsing beta alternates
|
198
|
-
|
198
|
+
|
199
199
|
def test_parsing_beta_alternates
|
200
200
|
assert_equal(::Versionomy.parse('2.52.1 beta4'), '2.52.1b4')
|
201
201
|
assert_equal(::Versionomy.parse('2.52.1-b4'), '2.52.1b4')
|
@@ -207,10 +207,10 @@ module Versionomy
|
|
207
207
|
assert_equal(::Versionomy.parse('2.52.1 eta4', :extra_characters => :ignore), '2.52.1')
|
208
208
|
assert_equal(::Versionomy.parse('2.52.1 Beta'), '2.52.1b0')
|
209
209
|
end
|
210
|
-
|
211
|
-
|
210
|
+
|
211
|
+
|
212
212
|
# Test parsing release candidate.
|
213
|
-
|
213
|
+
|
214
214
|
def test_parsing_release_candidate
|
215
215
|
value_ = ::Versionomy.parse('0.2rc0')
|
216
216
|
assert_equal(0, value_.major)
|
@@ -224,11 +224,11 @@ module Versionomy
|
|
224
224
|
assert_equal('0.2rc0.0', value_.unparse(:required_fields => [:release_candidate_minor]))
|
225
225
|
assert_equal('0.2rc', value_.unparse(:optional_fields => [:release_candidate_version]))
|
226
226
|
end
|
227
|
-
|
228
|
-
|
227
|
+
|
228
|
+
|
229
229
|
# Test parsing release candidate changing to other prerelease.
|
230
230
|
# Ensures that :short style takes precedence over :long for parsing "rc".
|
231
|
-
|
231
|
+
|
232
232
|
def test_parsing_release_candidate_type_change
|
233
233
|
value_ = ::Versionomy.parse('0.2rc1')
|
234
234
|
assert_equal(:release_candidate, value_.release_type)
|
@@ -243,10 +243,10 @@ module Versionomy
|
|
243
243
|
assert_equal(1, value_.beta_version)
|
244
244
|
assert_equal('0.2beta1', value_.unparse)
|
245
245
|
end
|
246
|
-
|
247
|
-
|
246
|
+
|
247
|
+
|
248
248
|
# Test parsing forms without a prerelease version
|
249
|
-
|
249
|
+
|
250
250
|
def test_parsing_without_prerelease_version
|
251
251
|
value_ = ::Versionomy.parse('1.9.2dev')
|
252
252
|
assert_equal(value_.release_type, :development)
|
@@ -255,11 +255,11 @@ module Versionomy
|
|
255
255
|
value_ = value_.bump(:development_version)
|
256
256
|
assert_equal('1.9.2dev1', value_.to_s)
|
257
257
|
end
|
258
|
-
|
259
|
-
|
258
|
+
|
259
|
+
|
260
260
|
# Test parsing forms without a prerelease version.
|
261
261
|
# Ensures that :development_version prefers to be required.
|
262
|
-
|
262
|
+
|
263
263
|
def test_unparsing_prerelease_version_0
|
264
264
|
value_ = ::Versionomy.parse('1.9.2dev1')
|
265
265
|
assert_equal(value_.release_type, :development)
|
@@ -270,10 +270,10 @@ module Versionomy
|
|
270
270
|
value2_ = value_.change({:development_version => 0}, :optional_fields => [:development_version])
|
271
271
|
assert_equal('1.9.2dev', value2_.to_s)
|
272
272
|
end
|
273
|
-
|
274
|
-
|
273
|
+
|
274
|
+
|
275
275
|
# Test unparsing a value that requires lookback.
|
276
|
-
|
276
|
+
|
277
277
|
def test_unparsing_with_lookback
|
278
278
|
value_ = ::Versionomy.parse('2.0')
|
279
279
|
value2_ = value_.change(:tiny2 => 1)
|
@@ -283,10 +283,10 @@ module Versionomy
|
|
283
283
|
assert_equal(0, value3_.tiny2)
|
284
284
|
assert_equal('2.0', value3_.unparse)
|
285
285
|
end
|
286
|
-
|
287
|
-
|
286
|
+
|
287
|
+
|
288
288
|
# Test delimiter changes in a multi-form field.
|
289
|
-
|
289
|
+
|
290
290
|
def test_multi_form_delimiter_changes
|
291
291
|
value_ = ::Versionomy.parse('2.0 preview 1')
|
292
292
|
assert_equal('2.0 preview 1', value_.to_s)
|
@@ -295,10 +295,10 @@ module Versionomy
|
|
295
295
|
value3_ = value2_.change(:release_type => :preview, :preview_version => 1)
|
296
296
|
assert_equal('2.0 preview 1', value3_.to_s)
|
297
297
|
end
|
298
|
-
|
299
|
-
|
298
|
+
|
299
|
+
|
300
300
|
# Test different patchlevel separators.
|
301
|
-
|
301
|
+
|
302
302
|
def test_patchlevel_separators
|
303
303
|
expected_ = [1,9,1,0,:final,243,0]
|
304
304
|
assert_equal(expected_, ::Versionomy.parse('1.9.1-p243').values_array)
|
@@ -310,12 +310,12 @@ module Versionomy
|
|
310
310
|
assert_equal(expected_, ::Versionomy.parse('1.9.1-243').values_array)
|
311
311
|
assert_equal(expected_, ::Versionomy.parse('1.9.1_243').values_array)
|
312
312
|
end
|
313
|
-
|
314
|
-
|
313
|
+
|
314
|
+
|
315
315
|
# Test alphabetic patchlevels.
|
316
316
|
# In particular, make sure the parser can distinguish between these
|
317
317
|
# and the markers for prereleases.
|
318
|
-
|
318
|
+
|
319
319
|
def test_patchlevel_alphabetic
|
320
320
|
value_ = ::Versionomy.parse('1.9a')
|
321
321
|
assert_equal([1, 9, 0, 0, :final, 1, 0], value_.values_array)
|
@@ -336,10 +336,10 @@ module Versionomy
|
|
336
336
|
assert_equal([1, 9, 0, 0, :final, 21, 0], value_.values_array)
|
337
337
|
assert_equal('1.9u', value_.to_s)
|
338
338
|
end
|
339
|
-
|
340
|
-
|
339
|
+
|
340
|
+
|
341
341
|
# Test setting delimiters on unparse, including testing for illegal delimiters
|
342
|
-
|
342
|
+
|
343
343
|
def test_unparse_with_custom_delimiters
|
344
344
|
value_ = ::Versionomy.parse('1.2b3')
|
345
345
|
assert_equal('1.2.b.3', value_.unparse(:release_type_delim => '.', :beta_version_delim => '.'))
|
@@ -347,10 +347,10 @@ module Versionomy
|
|
347
347
|
value_ = ::Versionomy.parse('1.2-4')
|
348
348
|
assert_equal('1.2-4', value_.unparse(:release_type_delim => '.'))
|
349
349
|
end
|
350
|
-
|
351
|
-
|
350
|
+
|
351
|
+
|
352
352
|
# Test java version formats
|
353
|
-
|
353
|
+
|
354
354
|
def test_java_formats
|
355
355
|
value_ = ::Versionomy.parse('1.6.0_17')
|
356
356
|
assert_equal([1, 6, 0, 0, :final, 17, 0], value_.values_array)
|
@@ -359,10 +359,10 @@ module Versionomy
|
|
359
359
|
assert_equal([6, 0, 0, 0, :final, 17, 0], value_.values_array)
|
360
360
|
assert_equal('6u17', value_.to_s)
|
361
361
|
end
|
362
|
-
|
363
|
-
|
362
|
+
|
363
|
+
|
364
364
|
# Test formats prefixed with "v"
|
365
|
-
|
365
|
+
|
366
366
|
def test_v_prefix
|
367
367
|
value_ = ::Versionomy.parse('v1.2')
|
368
368
|
assert_equal([1, 2, 0, 0, :final, 0, 0], value_.values_array)
|
@@ -371,18 +371,18 @@ module Versionomy
|
|
371
371
|
assert_equal([2, 3, 0, 0, :final, 0, 0], value_.values_array)
|
372
372
|
assert_equal('V 2.3', value_.to_s)
|
373
373
|
end
|
374
|
-
|
375
|
-
|
374
|
+
|
375
|
+
|
376
376
|
# Test parse errors
|
377
|
-
|
377
|
+
|
378
378
|
def test_parsing_errors
|
379
379
|
assert_raise(::Versionomy::Errors::ParseError) do
|
380
380
|
::Versionomy.parse('2.52.1 eta4')
|
381
381
|
end
|
382
382
|
end
|
383
|
-
|
384
|
-
|
383
|
+
|
384
|
+
|
385
385
|
end
|
386
|
-
|
386
|
+
|
387
387
|
end
|
388
388
|
end
|