Permalink
Browse files

Fix a regression in parsing alphabetic patchlevels

  • Loading branch information...
dazuma committed Nov 20, 2009
1 parent 54a3608 commit 2ac4091d90df11c1d82f85fcf245dabf773589fa
Showing with 32 additions and 2 deletions.
  1. +4 −0 History.rdoc
  2. +1 −1 lib/versionomy/format/delimiter.rb
  3. +1 −1 lib/versionomy/version.rb
  4. +26 −0 tests/tc_standard_parse.rb
View
@@ -1,3 +1,7 @@
+=== 0.2.4 / 2009-11-19
+
+* Fixed a regression introduced in 0.2.2 where "1.0a" was being recognized as an alpha version rather than a patchlevel of 1, and similar for "1.0b" and "1.0d".
+
=== 0.2.3 / 2009-11-19
* Recognize "_" and "u" as patchlevel delimiters, to support Sun's Java version numbers (e.g. "1.6.0_17", "6u17").
@@ -158,7 +158,6 @@ def parse(string_, params_=nil)
if parse_data_
parse_state_[:previous_field_missing] = false
if recognizer_.requires_next_field
- parse_state_[:next_field_required] = true
parse_state_ = {
:backtrack => parse_state_,
:string => parse_state_[:string],
@@ -167,6 +166,7 @@ def parse(string_, params_=nil)
:field => parse_state_[:field],
:recognizer_index => 0,
:previous_field_missing => false,
+ :next_field_required => true,
}
else
parse_state_[:next_field_required] = false
@@ -37,7 +37,7 @@
module Versionomy
# Current gem version, as a frozen string.
- VERSION_STRING = '0.2.3'.freeze
+ VERSION_STRING = '0.2.4'.freeze
# Current gem version, as a Versionomy::Value.
VERSION = ::Versionomy.parse(VERSION_STRING, :standard)
View
@@ -270,6 +270,32 @@ def test_patchlevel_separators
end
+ # Test alphabetic patchlevels.
+ # In particular, make sure the parser can distinguish between these
+ # and the markers for prereleases.
+
+ def test_patchlevel_alphabetic
+ value_ = ::Versionomy.parse('1.9a')
+ assert_equal([1, 9, 0, 0, :final, 1, 0], value_.values_array)
+ assert_equal('1.9a', value_.to_s)
+ value_ = ::Versionomy.parse('1.9b')
+ assert_equal([1, 9, 0, 0, :final, 2, 0], value_.values_array)
+ assert_equal('1.9b', value_.to_s)
+ value_ = ::Versionomy.parse('1.9d')
+ assert_equal([1, 9, 0, 0, :final, 4, 0], value_.values_array)
+ assert_equal('1.9d', value_.to_s)
+ value_ = ::Versionomy.parse('1.9p')
+ assert_equal([1, 9, 0, 0, :final, 16, 0], value_.values_array)
+ assert_equal('1.9p', value_.to_s)
+ value_ = ::Versionomy.parse('1.9r')
+ assert_equal([1, 9, 0, 0, :final, 18, 0], value_.values_array)
+ assert_equal('1.9r', value_.to_s)
+ value_ = ::Versionomy.parse('1.9u')
+ assert_equal([1, 9, 0, 0, :final, 21, 0], value_.values_array)
+ assert_equal('1.9u', value_.to_s)
+ end
+
+
# Test setting delimiters on unparse, including testing for illegal delimiters
def test_unparse_with_custom_delimiters

0 comments on commit 2ac4091

Please sign in to comment.