diff options
| author | Jack Nagel | 2013-08-22 11:34:23 -0500 |
|---|---|---|
| committer | Jack Nagel | 2013-08-22 11:35:00 -0500 |
| commit | 7654077752b1a43f034aca907cb23ee98dc80c2c (patch) | |
| tree | d26c364875db8de83d29a2196ea8d1e2988b7cbc /Library | |
| parent | 1abb8cdf819f0bc264df2805398076726300ee7c (diff) | |
| download | brew-7654077752b1a43f034aca907cb23ee98dc80c2c.tar.bz2 | |
Demonstrate the Set-like nature of Options collections
Options collections are backed by Sets, and thus trying to push a new
option with a name that duplicates an existing option cannot succeed.
Later, we can exploit this behavior and remove some conditionals.
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/test/test_options.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Library/Homebrew/test/test_options.rb b/Library/Homebrew/test/test_options.rb index 0cc16ff2e..b0f560354 100644 --- a/Library/Homebrew/test/test_options.rb +++ b/Library/Homebrew/test/test_options.rb @@ -54,6 +54,15 @@ class OptionsTests < Test::Unit::TestCase assert_equal 1, @options.count end + def test_preserves_existing_member_when_pushing_duplicate + a = Option.new("foo", "bar") + b = Option.new("foo", "qux") + @options << a << b + assert_equal 1, @options.count + assert_same a, @options.first + assert_equal a.description, @options.first.description + end + def test_include @options << Option.new("foo") assert @options.include? "--foo" |
