<commit_before>require File.join(File.dirname(__FILE__), "..", "test_helper")

require 'mocha/state_machine'

class StateMachineTest < Test::Unit::TestCase
  
  include Mocha
  
  def test_should_initially_be_in_no_state
    state_machine = StateMachine.new('name')
    any_state.each do |state|
      assert !state_machine.is(state).active?
      assert state_machine.is_not(state).active?
    end
  end
  
  def test_should_be_able_to_enter_a_state
    state_machine = StateMachine.new('name')
    state = 'A'
    other_states = any_state.reject { |s| s == state }
    
    state_machine.is(state).activate
    
    assert state_machine.is(state).active?
    assert !state_machine.is_not(state).active?
    other_states.each do |state|
      assert !state_machine.is(state).active?
      assert state_machine.is_not(state).active?
    end
  end
  
  def test_should_be_able_to_change_state
    state_machine = StateMachine.new('name')
    state = 'B'
    other_states = any_state.reject { |s| s == state }
    
    state_machine.is('A').activate
    state_machine.is(state).activate
    
    assert state_machine.is(state).active?
    assert !state_machine.is_not(state).active?
    other_states.each do |state|
      assert !state_machine.is(state).active?
      assert state_machine.is_not(state).active?
    end
  end
  
  def test_should_be_put_into_an_initial_state
    state_machine = StateMachine.new('name')
    initial_state = 'A'
    other_states = any_state.reject { |s| s == initial_state }<commit_msg>Fix ruby 1.9 warning caused by test.<commit_after>require File.join(File.dirname(__FILE__), "..", "test_helper")

require 'mocha/state_machine'

class StateMachineTest < Test::Unit::TestCase
  
  include Mocha
  
  def test_should_initially_be_in_no_state
    state_machine = StateMachine.new('name')
    any_state.each do |state|
      assert !state_machine.is(state).active?
      assert state_machine.is_not(state).active?
    end
  end
  
  def test_should_be_able_to_enter_a_state
    state_machine = StateMachine.new('name')
    state = 'A'
    other_states = any_state.reject { |s| s == state }
    
    state_machine.is(state).activate
    
    assert state_machine.is(state).active?
    assert !state_machine.is_not(state).active?
    other_states.each do |s|
      assert !state_machine.is(s).active?
      assert state_machine.is_not(s).active?
    end
  end
  
  def test_should_be_able_to_change_state
    state_machine = StateMachine.new('name')
    state = 'B'
    other_states = any_state.reject { |s| s == state }
    
    state_machine.is('A').activate
    state_machine.is(state).activate
    
    assert state_machine.is(state).active?
    assert !state_machine.is_not(state).active?
    other_states.each do |s|
      assert !state_machine.is(s).active?
      assert state_machine.is_not(s).active?
    end
  end
  
  def test_should_be_put_into_an_initial_state
    state_machine = StateMachine.new('name')
    initial_state = 'A'
    other_states = any_state.reject { |s| s == initial_state }
{'fraction_non_alphanumeric': 0.10623556581986143, 'fraction_numerical': 0.0006598482349059716, 'mean_word_length': 3.5731523378582204, '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': '1859882', 'n_tokens_mistral': 1027, 'n_tokens_neox': 1018, 'n_words': 176}