mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Remove duplicates from ARGV.named
Includes test
This commit is contained in:
parent
dccc2b1923
commit
6dbdc9ab0c
@ -17,7 +17,7 @@
|
|||||||
#
|
#
|
||||||
module HomebrewArgvExtension
|
module HomebrewArgvExtension
|
||||||
def named
|
def named
|
||||||
reject {|arg| arg[0..0] == '-'}
|
reject{|arg| arg[0..0] == '-'}.collect{|arg| arg.downcase}.uniq
|
||||||
end
|
end
|
||||||
def options
|
def options
|
||||||
select {|arg| arg[0..0] == '-'}
|
select {|arg| arg[0..0] == '-'}
|
||||||
|
@ -255,4 +255,12 @@ class BeerTasting <Test::Unit::TestCase
|
|||||||
assert_raises(RuntimeError) { f.prefix }
|
assert_raises(RuntimeError) { f.prefix }
|
||||||
nostdout { assert_raises(ExecutionError) { f.brew } }
|
nostdout { assert_raises(ExecutionError) { f.brew } }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_no_ARGV_dupes
|
||||||
|
ARGV.unshift'foo'
|
||||||
|
ARGV.unshift'foo'
|
||||||
|
n=0
|
||||||
|
ARGV.named.each{|arg| n+=1 if arg == 'foo'}
|
||||||
|
assert_equal 1, n
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user