<commit_before>#!/usr/bin/env ruby

require 'test/unit'
require 'rake'

class TaskManager
  include Rake::TaskManager
end

class TestTaskManager < Test::Unit::TestCase
  def setup
    @tm = TaskManager.new
  end

  def test_create_task_manager
    assert_not_nil @tm
    assert_equal [], @tm.tasks
  end

  def test_define_task
    t = @tm.define_task(Rake::Task, :t)
    assert_equal "t", t.name
    assert_equal @tm, t.application
  end

  def test_name_lookup
    t = @tm.define_task(Rake::Task, :t)
    assert_equal t, @tm[:t]
  end

  def test_namespace_task_create
    @tm.in_namespace("x") do
      t = @tm.define_task(Rake::Task, :t)
      assert_equal "x:t", t.name
    end
    assert_equal ["x:t"], @tm.tasks.collect { |t| t.name }
  end

  def test_anonymous_namespace
    anon_ns = @tm.in_namespace(nil) do
      t = @tm.define_task(Rake::Task, :t)
      assert_equal "_anon_1:t", t.name
    end
    task = anon_ns[:t]
    assert_equal "_anon_1:t", task.name
  end

  def test_create_filetask_in_namespace
    @tm.in_namespace("x") do
      t = @tm.define_task(Rake::FileTask, "fn")
      assert_equal "fn", t.name
    end
    assert_equal ["fn"], @tm.tasks.collect { |t| t.name }
  end

  def test_name_lookup_with_implicit_file_tasks
    t = @tm["README"]
    assert_equal "README", t.name
    assert Rake::FileTask === t
  end<commit_msg>added tests for yielded namespace argument<commit_after>#!/usr/bin/env ruby

require 'test/unit'
require 'rake'

class TaskManager
  include Rake::TaskManager
end

class TestTaskManager < Test::Unit::TestCase
  def setup
    @tm = TaskManager.new
  end

  def test_create_task_manager
    assert_not_nil @tm
    assert_equal [], @tm.tasks
  end

  def test_define_task
    t = @tm.define_task(Rake::Task, :t)
    assert_equal "t", t.name
    assert_equal @tm, t.application
  end

  def test_name_lookup
    t = @tm.define_task(Rake::Task, :t)
    assert_equal t, @tm[:t]
  end

  def test_namespace_task_create
    @tm.in_namespace("x") do
      t = @tm.define_task(Rake::Task, :t)
      assert_equal "x:t", t.name
    end
    assert_equal ["x:t"], @tm.tasks.collect { |t| t.name }
  end

  def test_anonymous_namespace
    anon_ns = @tm.in_namespace(nil) do
      t = @tm.define_task(Rake::Task, :t)
      assert_equal "_anon_1:t", t.name
    end
    task = anon_ns[:t]
    assert_equal "_anon_1:t", task.name
  end

  def test_create_filetask_in_namespace
    @tm.in_namespace("x") do
      t = @tm.define_task(Rake::FileTask, "fn")
      assert_equal "fn", t.name
    end
    assert_equal ["fn"], @tm.tasks.collect { |t| t.name }
  end

  def testS_namespace_yields_same_namespace_as_returned
    yielded_namespace = nil
    returned_namespace = @tm.in_namespace("x") do |ns|
      yielded_namespace = ns
    end
    assert_equal returned_namespace, yielded_namespace
  end

  def test_name_lookup_with_implicit_file_tasks
    t = @tm["README"]
    assert_equal "README", t.name
    assert Rake::FileTask === t
  end
{'fraction_non_alphanumeric': 0.11772620248906829, 'fraction_numerical': 0.0013454423141607804, 'mean_word_length': 3.347953216374269, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7533132', 'n_tokens_mistral': 1120, 'n_tokens_neox': 1096, 'n_words': 239}