Add set union to Options
This commit is contained in:
parent
96df4fe1da
commit
b2ccbfe6af
@ -83,6 +83,10 @@ class Options
|
||||
Options.new(@options & o)
|
||||
end
|
||||
|
||||
def |(o)
|
||||
Options.new(@options | o)
|
||||
end
|
||||
|
||||
def *(arg)
|
||||
@options.to_a * arg
|
||||
end
|
||||
|
||||
@ -126,6 +126,13 @@ class OptionsTests < Test::Unit::TestCase
|
||||
assert_equal [foo], (@options & options).to_a
|
||||
end
|
||||
|
||||
def test_set_union
|
||||
foo, bar, baz = %w{foo bar baz}.map { |o| Option.new(o) }
|
||||
options = Options.new << foo << bar
|
||||
@options << foo << baz
|
||||
assert_equal [foo, bar, baz].sort, (@options | options).to_a.sort
|
||||
end
|
||||
|
||||
def test_coerce_with_options
|
||||
assert_same @options, Options.coerce(@options)
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user