From fcbf63e62c627deae76c1b8cb8c0876c536ed811 Mon Sep 17 00:00:00 2001 From: Jari Vetoniemi Date: Mon, 16 Mar 2020 18:49:26 +0900 Subject: Fresh start --- jni/ruby/test/rake/test_rake_name_space.rb | 57 ++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 jni/ruby/test/rake/test_rake_name_space.rb (limited to 'jni/ruby/test/rake/test_rake_name_space.rb') diff --git a/jni/ruby/test/rake/test_rake_name_space.rb b/jni/ruby/test/rake/test_rake_name_space.rb new file mode 100644 index 0000000..d35e70e --- /dev/null +++ b/jni/ruby/test/rake/test_rake_name_space.rb @@ -0,0 +1,57 @@ +require File.expand_path('../helper', __FILE__) + +class TestRakeNameSpace < Rake::TestCase + + class TM + include Rake::TaskManager + end + + def test_namespace_creation + mgr = TM.new + ns = Rake::NameSpace.new(mgr, []) + refute_nil ns + end + + def test_namespace_lookup + mgr = TM.new + ns = mgr.in_namespace("n") do + mgr.define_task(Rake::Task, "t") + end + + refute_nil ns["t"] + assert_equal mgr["n:t"], ns["t"] + end + + def test_namespace_reports_tasks_it_owns + mgr = TM.new + nns = nil + ns = mgr.in_namespace("n") do + mgr.define_task(Rake::Task, :x) + mgr.define_task(Rake::Task, :y) + nns = mgr.in_namespace("nn") do + mgr.define_task(Rake::Task, :z) + end + end + mgr.in_namespace("m") do + mgr.define_task(Rake::Task, :x) + end + + assert_equal ["n:nn:z", "n:x", "n:y"], + ns.tasks.map { |tsk| tsk.name } + assert_equal ["n:nn:z"], nns.tasks.map { |t| t.name } + end + + def test_scope + mgr = TM.new + + scope = Rake::LinkedList.new 'b' + scope = scope.conj 'a' + + ns = Rake::NameSpace.new mgr, scope + + assert_equal scope, ns.scope + + refute_same scope, ns.scope + end + +end -- cgit v1.2.3