Removed obsolete bin scripts.
[rbx.git] / test / rubygems / test_gem_dependency.rb
blobf280221a008c7822719fcebf9161cb53537bfeed
1 #--
2 # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
3 # All rights reserved.
4 # See LICENSE.txt for permissions.
5 #++
7 require 'test/unit'
8 require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
9 require 'rubygems/version'
11 class TestGemDependency < RubyGemTestCase
13   def setup
14     super
16     @pkg1_0 = Gem::Dependency.new 'pkg', ['> 1.0']
17     @pkg1_1 = Gem::Dependency.new 'pkg', ['> 1.1']
19     @oth1_0 = Gem::Dependency.new 'other', ['> 1.0']
21     @r1_0 = Gem::Requirement.new ['> 1.0']
22   end
24   def test_initialize
25     assert_equal "pkg", @pkg1_0.name
26     assert_equal @r1_0, @pkg1_0.version_requirements
27   end
29   def test_initialize_double
30     dep = Gem::Dependency.new("pkg", ["> 1.0", "< 2.0"])
32     assert_equal Gem::Requirement.new(["> 1.0", "< 2.0"]),
33                  dep.version_requirements
34   end
36   def test_initialize_empty
37     dep = Gem::Dependency.new("pkg", [])
38     req = @r1_0
40     req.instance_eval do
41       @version = ">= 1.0"
42       @op = ">="
43       @nums = [1,0]
44       @requirements = nil
45     end
47     dep.instance_eval do
48       @version_requirement = req
49       @version_requirements = nil
50     end
52     assert_equal Gem::Requirement.new([">= 1.0"]), dep.version_requirements
53   end
55   def test_initialize_version
56     dep = Gem::Dependency.new 'pkg', Gem::Version.new('2')
58     assert_equal 'pkg', dep.name
60     assert_equal Gem::Requirement.new('= 2'), dep.version_requirements
61   end
63   def test_equals2
64     assert_equal @pkg1_0, @pkg1_0.dup
65     assert_equal @pkg1_0.dup, @pkg1_0
67     assert_not_equal @pkg1_0, @pkg1_1, "requirements different"
68     assert_not_equal @pkg1_1, @pkg1_0, "requirements different"
70     assert_not_equal @pkg1_0, @oth1_0, "names different"
71     assert_not_equal @oth1_0, @pkg1_0, "names different"
73     assert_not_equal @pkg1_0, Object.new
74     assert_not_equal Object.new, @pkg1_0
75   end
77   def test_hash
78     assert_equal @pkg1_0.hash, @pkg1_0.dup.hash
79     assert_equal @pkg1_0.dup.hash, @pkg1_0.hash
81     assert_not_equal @pkg1_0.hash, @pkg1_1.hash, "requirements different"
82     assert_not_equal @pkg1_1.hash, @pkg1_0.hash, "requirements different"
84     assert_not_equal @pkg1_0.hash, @oth1_0.hash, "names different"
85     assert_not_equal @oth1_0.hash, @pkg1_0.hash, "names different"
86   end
88 end