version_sorter 1.1.1 → 2.0.0

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.
@@ -1,37 +0,0 @@
1
- require 'test/unit'
2
- $LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
3
- require 'version_sorter'
4
-
5
- class VersionSorterTest < Test::Unit::TestCase
6
- include VersionSorter
7
-
8
- def test_sorts_verisons_correctly
9
- versions = %w(1.0.9 1.0.10 2.0 3.1.4.2 1.0.9a)
10
- sorted_versions = %w( 1.0.9 1.0.9a 1.0.10 2.0 3.1.4.2 )
11
-
12
- assert_equal sorted_versions, sort(versions)
13
- end
14
-
15
- def test_returns_same_object
16
- versions = %w( 2.0 1.0 0.5 )
17
- sorted = sort(versions)
18
-
19
- assert_equal versions[2].object_id, sorted[0].object_id
20
- end
21
-
22
- def test_reverse_sorts_verisons_correctly
23
- versions = %w(1.0.9 1.0.10 2.0 3.1.4.2 1.0.9a)
24
- sorted_versions = %w( 3.1.4.2 2.0 1.0.10 1.0.9a 1.0.9 )
25
-
26
- assert_equal sorted_versions, rsort(versions)
27
- end
28
- end
29
-
30
- require 'benchmark'
31
- versions = IO.read(File.dirname(__FILE__) + '/tags.txt').split("\n")
32
- count = 10
33
- Benchmark.bm(20) do |x|
34
- x.report("sort") { count.times { VersionSorter.sort(versions) } }
35
- x.report("rsot") { count.times { VersionSorter.rsort(versions) } }
36
- end
37
- puts