<commit_before>#--
# SES Core Unit Tests
# ==============================================================================
# 
# Summary
# ------------------------------------------------------------------------------
#   This file provides unit tests for the SES Core script. These tests are
# provided in order to ensure that the SES Core script continues to function
# properly in the case of script updates or modifications from external sources
# (such as third-party scripts or scripters).
# 
#++
module SES::TestCases
  # ============================================================================
  # CoreScriptTest - Unit tests for the SES::Script class.
  # ============================================================================
  class CoreScriptTest < SES::Test::Spec
    describe 'Script' do SES::Script end
    
    it 'initializes with given name' do
      subject.new(:Example).name.must_be_same_as :Example
    end
    
    it 'defines #authors, #name, and #version methods' do
      script = subject.new(:Example)
      [:authors, :name, :version].each do |instance_method|
        script.must_respond_to(instance_method)
      end
    end
    
    it '#authors, #name, and #version return expected values' do
      script = subject.new(:Example)
      [:authors, :name, :version].each do |ivar|
        expectation = script.instance_variable_get('@data')[ivar]
        script.send(ivar).must_equal expectation
      end
    end
    
    it 'initializes with default author and version' do
      script = subject.new(:Example)
      script.authors.must_equal [:Solistra, :Enelvon]
      script.version.must_equal 1.0
    end
    
    it 'initializes with given version and authors' do
      script = subject.new(:Example, 0.1, :Nobody)
      script.authors.must_equal [:Nobody]
      script.version.must_equal 0.1
    end
    
    it '.format appropriately formats symbols' do
      subject.format(:Example_Script).must_be_same_as :"Example Script"
    end
    
    it '.format appropriately formats descriptive symbols' do
      subject.format(:"Example Script").must_be_same_as :Example_Script
    end
    
    it '.format appropriately formats descriptive strings' do
      subject.format('Example Script').must_be_same_as :Example_Script
    end
  end
  
  # ============================================================================
  # CoreRegisterTest - Unit tests for the SES::Register module.
  # ============================================================================
  class CoreRegisterTest < SES::Test::Spec
    describe 'Register' do SES::Register end
    let :script do SES::Script.new(:Example) end
    
    # Cleans the SES::Register entries and entries in the $imported global
    # variable so these tests do not contaminate either.
    def clean_register(key)
      subject.scripts.delete(key)
      $imported.delete("SES_#{key}".to_sym)
    end
    
    it '.enter adds the passed script to the register' do
      subject.enter(script)
      subject.scripts.values.must_include(script)
      clean_register(script.name)
    end
    
    it '.enter adds a default script to the register if none given' do
      subject.enter
      subject.scripts.keys.must_include(:Undefined_Script)
      clean_register(:Undefined_Script)
    end
    
    it '.enter adds formatted script information to $imported' do
      subject.enter(script)
      $imported.keys.must_include(:SES_Example)
      $imported[:SES_Example].must_equal 1.0
      clean_register(script.name)
    end
    
    it '.entries_for finds SES scripts given script name' do
      subject.entries_for(:Core).first.name.must_be_same_as :Core
    end
    
    it '.entries_for finds SES scripts given single author' do
      subject.enter(example_script = SES::Script.new(:Example, 1.0, :Solistra))
      subject.entries_for(:Solistra).must_include example_script<commit_msg>Remove test for deprecated SES::Register.enter feature.<commit_after>#--
# SES Core Unit Tests
# ==============================================================================
# 
# Summary
# ------------------------------------------------------------------------------
#   This file provides unit tests for the SES Core script. These tests are
# provided in order to ensure that the SES Core script continues to function
# properly in the case of script updates or modifications from external sources
# (such as third-party scripts or scripters).
# 
#++
module SES::TestCases
  # ============================================================================
  # CoreScriptTest - Unit tests for the SES::Script class.
  # ============================================================================
  class CoreScriptTest < SES::Test::Spec
    describe 'Script' do SES::Script end
    
    it 'initializes with given name' do
      subject.new(:Example).name.must_be_same_as :Example
    end
    
    it 'defines #authors, #name, and #version methods' do
      script = subject.new(:Example)
      [:authors, :name, :version].each do |instance_method|
        script.must_respond_to(instance_method)
      end
    end
    
    it '#authors, #name, and #version return expected values' do
      script = subject.new(:Example)
      [:authors, :name, :version].each do |ivar|
        expectation = script.instance_variable_get('@data')[ivar]
        script.send(ivar).must_equal expectation
      end
    end
    
    it 'initializes with default author and version' do
      script = subject.new(:Example)
      script.authors.must_equal [:Solistra, :Enelvon]
      script.version.must_equal 1.0
    end
    
    it 'initializes with given version and authors' do
      script = subject.new(:Example, 0.1, :Nobody)
      script.authors.must_equal [:Nobody]
      script.version.must_equal 0.1
    end
    
    it '.format appropriately formats symbols' do
      subject.format(:Example_Script).must_be_same_as :"Example Script"
    end
    
    it '.format appropriately formats descriptive symbols' do
      subject.format(:"Example Script").must_be_same_as :Example_Script
    end
    
    it '.format appropriately formats descriptive strings' do
      subject.format('Example Script').must_be_same_as :Example_Script
    end
  end
  
  # ============================================================================
  # CoreRegisterTest - Unit tests for the SES::Register module.
  # ============================================================================
  class CoreRegisterTest < SES::Test::Spec
    describe 'Register' do SES::Register end
    let :script do SES::Script.new(:Example) end
    
    # Cleans the SES::Register entries and entries in the $imported global
    # variable so these tests do not contaminate either.
    def clean_register(key)
      subject.scripts.delete(key)
      $imported.delete("SES_#{key}".to_sym)
    end
    
    it '.enter adds the passed script to the register' do
      subject.enter(script)
      subject.scripts.values.must_include(script)
      clean_register(script.name)
    end
    
    it '.enter adds formatted script information to $imported' do
      subject.enter(script)
      $imported.keys.must_include(:SES_Example)
      $imported[:SES_Example].must_equal 1.0
      clean_register(script.name)
    end
    
    it '.entries_for finds SES scripts given script name' do
      subject.entries_for(:Core).first.name.must_be_same_as :Core
    end
    
    it '.entries_for finds SES scripts given single author' do
      subject.enter(example_script = SES::Script.new(:Example, 1.0, :Solistra))
      subject.entries_for(:Solistra).must_include example_script
{'fraction_non_alphanumeric': 0.20042110804053165, 'fraction_numerical': 0.0026319252533228057, 'mean_word_length': 3.233983286908078, 'pattern_counts': {'":': 0, '<': 7, '<?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': '3052354', 'n_tokens_mistral': 2085, 'n_tokens_neox': 1948, 'n_words': 583}