diff options
| author | Jack Nagel | 2013-08-22 11:34:23 -0500 |
|---|---|---|
| committer | Jack Nagel | 2013-08-22 11:35:00 -0500 |
| commit | 5770f9bbf8e93cfc444451b97d8c957b2a7ca085 (patch) | |
| tree | bbf66c66710103d4e0de71180a451bc5b9b44068 /Library | |
| parent | 98f6486212941abf569e73df37a701ea9dc9fdb1 (diff) | |
| download | homebrew-5770f9bbf8e93cfc444451b97d8c957b2a7ca085.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" |
