<commit_before>require 'setup_tests'

class TestHierarchical < Minitest::Test
  def setup
    @fsm = Hifsm::FSM.new do
      sync_fsm = proc do
        state :pending, :initial => true
        state :sync

        event :sync, :from => :pending, :to => :sync
      end

      state :off, :initial => true, &sync_fsm
      state :on, &sync_fsm

      event :toggle, :from => 'off.sync', :to => :on
      event :toggle, :from => 'on.sync', :to => 'off.sync'
    end
  end

  def test_initial_state_is_off_pending_by_default
    machine = @fsm.instantiate
    assert_equal 'off.pending', machine.state
  end

  def test_explicit_initial_state
    machine2 = @fsm.instantiate(nil, 'on.sync')
    assert_equal 'on.sync', machine2.state
    # assert_nothing_raised
    machine2.toggle
    pass
  end

  def test_toggle_raises_an_error_in_pending_state
    machine = @fsm.instantiate
    assert_raises(Hifsm::MissingTransition) do
      machine.toggle
    end<commit_msg>tiny tweaks<commit_after>require 'setup_tests'

class TestHierarchical < Minitest::Test
  def setup
    @fsm = Hifsm::FSM.new do
      async = proc do
        state :pending, :initial => true
        state :sync

        event :sync, :from => :pending, :to => :sync
      end

      state :off, :initial => true, &async
      state :on, &async

      event :toggle, :from => 'off.sync', :to => :on
      event :toggle, :from => 'on.sync', :to => 'off.sync'
    end
  end

  def test_initial_state_is_off_pending_by_default
    machine = @fsm.instantiate
    assert_equal 'off.pending', machine.state
  end

  def test_explicit_initial_state
    machine2 = @fsm.instantiate(nil, 'on.sync')
    assert_equal 'on.sync', machine2.state
    machine2.toggle
    pass # assert_nothing_raised
  end

  def test_toggle_raises_an_error_in_pending_state
    machine = @fsm.instantiate
    assert_raises(Hifsm::MissingTransition) do
      machine.toggle
    end
{'fraction_non_alphanumeric': 0.10559330893883952, 'fraction_numerical': 0.0031364349189754314, 'mean_word_length': 3.0210084033613445, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, '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': '1277546', 'n_tokens_mistral': 664, 'n_tokens_neox': 641, 'n_words': 152}