2 # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
4 # See LICENSE.txt for permissions.
8 require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
9 require 'rubygems/version'
11 class TestGemDependency < RubyGemTestCase
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']
25 assert_equal "pkg", @pkg1_0.name
26 assert_equal @r1_0, @pkg1_0.version_requirements
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
36 def test_initialize_empty
37 dep = Gem::Dependency.new("pkg", [])
48 @version_requirement = req
49 @version_requirements = nil
52 assert_equal Gem::Requirement.new([">= 1.0"]), dep.version_requirements
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
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
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"