summaryrefslogtreecommitdiff
path: root/test/rake/test_rake_task_arguments.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/rake/test_rake_task_arguments.rb')
-rw-r--r--test/rake/test_rake_task_arguments.rb37
1 files changed, 35 insertions, 2 deletions
diff --git a/test/rake/test_rake_task_arguments.rb b/test/rake/test_rake_task_arguments.rb
index 7001a4a..061178e 100644
--- a/test/rake/test_rake_task_arguments.rb
+++ b/test/rake/test_rake_task_arguments.rb
@@ -26,8 +26,8 @@ class TestRakeTaskArguments < Rake::TestCase
end
def test_enumerable_behavior
- ta = Rake::TaskArguments.new([:a, :b, :c], [1, 2 ,3])
- assert_equal [10, 20, 30], ta.collect { |k,v| v * 10 }.sort
+ ta = Rake::TaskArguments.new([:a, :b, :c], [1, 2, 3])
+ assert_equal [10, 20, 30], ta.map { |k, v| v * 10 }.sort
end
def test_named_args
@@ -85,4 +85,37 @@ class TestRakeTaskArguments < Rake::TestCase
ta.with_defaults({ "cc" => "default_val" })
assert_nil ta[:cc]
end
+
+ def test_all_and_extra_arguments_without_named_arguments
+ app = Rake::Application.new
+ _, args = app.parse_task_string("task[1,two,more]")
+ ta = Rake::TaskArguments.new([], args)
+ assert_equal [], ta.names
+ assert_equal ['1', 'two', 'more'], ta.to_a
+ assert_equal ['1', 'two', 'more'], ta.extras
+ end
+
+ def test_all_and_extra_arguments_with_named_arguments
+ app = Rake::Application.new
+ _, args = app.parse_task_string("task[1,two,more,still more]")
+ ta = Rake::TaskArguments.new([:first, :second], args)
+ assert_equal [:first, :second], ta.names
+ assert_equal "1", ta[:first]
+ assert_equal "two", ta[:second]
+ assert_equal ['1', 'two', 'more', 'still more'], ta.to_a
+ assert_equal ['more', 'still more'], ta.extras
+ end
+
+ def test_extra_args_with_less_than_named_arguments
+ app = Rake::Application.new
+ _, args = app.parse_task_string("task[1,two]")
+ ta = Rake::TaskArguments.new([:first, :second, :third], args)
+ assert_equal [:first, :second, :third], ta.names
+ assert_equal "1", ta[:first]
+ assert_equal "two", ta[:second]
+ assert_equal nil, ta[:third]
+ assert_equal ['1', 'two'], ta.to_a
+ assert_equal [], ta.extras
+ end
+
end