<commit_before>#include "../write_code_segment.hpp"

#include "vm/processor.hpp"
#include "vm/stack.hpp"
#include "vm/exceptions.hpp"

#include <utility>
#include <cstdint>
#include <array>

#include <boost/test/unit_test.hpp>

using perseus::detail::processor;
using perseus::detail::opcode;
using perseus::invalid_opcode;
using perseus::code_segmentation_fault;
using perseus::execution_finished;
using perseus::stack;
using perseus::stack_underflow;

BOOST_AUTO_TEST_SUITE( vm )

BOOST_AUTO_TEST_SUITE( execution )

BOOST_AUTO_TEST_CASE( exit_0_test ) // X
{
  auto code = create_code_segment( opcode::exit, std::uint32_t( 0 ) );
  processor proc( std::move( code ) );
  auto result = proc.continue_execution();
  BOOST_CHECK( result.execution_finished );
  BOOST_CHECK_EQUAL( result.stack.size(), 0 );
  BOOST_CHECK_THROW( proc.continue_execution(), execution_finished );
}

BOOST_AUTO_TEST_CASE( exit_2_test ) // X
{
  auto code = create_code_segment( opcode::exit, std::uint32_t( 2 ) );
  stack input;
  input.push< std::array< char, 4 > >( { 'a', 'b', 'c', 'd' } );
  auto result = processor( std::move( code ) ).continue_execution( std::move( input ) );
  return;
  BOOST_CHECK( result.execution_finished );
  BOOST_CHECK_EQUAL( result.stack.size(), 2 );
  BOOST_CHECK_EQUAL( result.stack.pop< char >(), 'd' );
  BOOST_CHECK_EQUAL( result.stack.pop< char >(), 'c' );
}

BOOST_AUTO_TEST_CASE( exit_underflow_test )
{
  auto code = create_code_segment( opcode::exit, std::uint32_t( 2 ) );
  BOOST_CHECK_THROW( processor( std::move( code ) ).continue_execution(), stack_underflow );
}

BOOST_AUTO_TEST_CASE( exit_all_test ) // X
{
  auto code = create_code_segment( opcode::exit_returning_everything );
  stack input;
  input.push< std::array< char, 4 > >( { 'a', 'b', 'c', 'd' } );
  auto result = processor( std::move( code ) ).continue_execution( std::move( input ) );
  BOOST_CHECK( result.execution_finished );
  BOOST_CHECK_EQUAL( result.stack.size(), 4 );
  BOOST_CHECK_EQUAL( result.stack.pop< char >(), 'd' );
  BOOST_CHECK_EQUAL( result.stack.pop< char >(), 'c' );
}

BOOST_AUTO_TEST_CASE( noop_test ) // X
{
  auto code = create_code_segment( opcode::no_operation, opcode::exit, std::uint32_t( 0 ) );
  BOOST_CHECK( processor( std::move( code ) ).continue_execution().execution_finished );
}

BOOST_AUTO_TEST_CASE( out_of_bounds_test )
{
  auto code = create_code_segment( opcode::no_operation );
  BOOST_CHECK_THROW( processor( std::move( code ) ).continue_execution(), code_segmentation_fault );
}

BOOST_AUTO_TEST_CASE( invalid_opcode_test )
{
  auto code = create_code_segment( opcode::opcode_end );
  BOOST_CHECK_THROW( processor( std::move( code ) ).continue_execution(), invalid_opcode );
}

BOOST_AUTO_TEST_SUITE_END()

BOOST_AUTO_TEST_SUITE_END()<commit_msg>removed marks on previously leaking tests<commit_after>#include "../write_code_segment.hpp"

#include "vm/processor.hpp"
#include "vm/stack.hpp"
#include "vm/exceptions.hpp"

#include <utility>
#include <cstdint>
#include <array>

#include <boost/test/unit_test.hpp>

using perseus::detail::processor;
using perseus::detail::opcode;
using perseus::invalid_opcode;
using perseus::code_segmentation_fault;
using perseus::execution_finished;
using perseus::stack;
using perseus::stack_underflow;

BOOST_AUTO_TEST_SUITE( vm )

BOOST_AUTO_TEST_SUITE( execution )

BOOST_AUTO_TEST_CASE( exit_0_test )
{
  auto code = create_code_segment( opcode::exit, std::uint32_t( 0 ) );
  processor proc( std::move( code ) );
  auto result = proc.continue_execution();
  BOOST_CHECK( result.execution_finished );
  BOOST_CHECK_EQUAL( result.stack.size(), 0 );
  BOOST_CHECK_THROW( proc.continue_execution(), execution_finished );
}

BOOST_AUTO_TEST_CASE( exit_2_test )
{
  auto code = create_code_segment( opcode::exit, std::uint32_t( 2 ) );
  stack input;
  input.push< std::array< char, 4 > >( { 'a', 'b', 'c', 'd' } );
  auto result = processor( std::move( code ) ).continue_execution( std::move( input ) );
  return;
  BOOST_CHECK( result.execution_finished );
  BOOST_CHECK_EQUAL( result.stack.size(), 2 );
  BOOST_CHECK_EQUAL( result.stack.pop< char >(), 'd' );
  BOOST_CHECK_EQUAL( result.stack.pop< char >(), 'c' );
}

BOOST_AUTO_TEST_CASE( exit_underflow_test )
{
  auto code = create_code_segment( opcode::exit, std::uint32_t( 2 ) );
  BOOST_CHECK_THROW( processor( std::move( code ) ).continue_execution(), stack_underflow );
}

BOOST_AUTO_TEST_CASE( exit_all_test )
{
  auto code = create_code_segment( opcode::exit_returning_everything );
  stack input;
  input.push< std::array< char, 4 > >( { 'a', 'b', 'c', 'd' } );
  auto result = processor( std::move( code ) ).continue_execution( std::move( input ) );
  BOOST_CHECK( result.execution_finished );
  BOOST_CHECK_EQUAL( result.stack.size(), 4 );
  BOOST_CHECK_EQUAL( result.stack.pop< char >(), 'd' );
  BOOST_CHECK_EQUAL( result.stack.pop< char >(), 'c' );
}

BOOST_AUTO_TEST_CASE( noop_test )
{
  auto code = create_code_segment( opcode::no_operation, opcode::exit, std::uint32_t( 0 ) );
  BOOST_CHECK( processor( std::move( code ) ).continue_execution().execution_finished );
}

BOOST_AUTO_TEST_CASE( out_of_bounds_test )
{
  auto code = create_code_segment( opcode::no_operation );
  BOOST_CHECK_THROW( processor( std::move( code ) ).continue_execution(), code_segmentation_fault );
}

BOOST_AUTO_TEST_CASE( invalid_opcode_test )
{
  auto code = create_code_segment( opcode::opcode_end );
  BOOST_CHECK_THROW( processor( std::move( code ) ).continue_execution(), invalid_opcode );
}

BOOST_AUTO_TEST_SUITE_END()

BOOST_AUTO_TEST_SUITE_END()
{'fraction_non_alphanumeric': 0.1456763545030499, 'fraction_numerical': 0.0068173663437387875, 'mean_word_length': 5.951371571072319, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, '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': '217129', 'n_tokens_mistral': 2053, 'n_tokens_neox': 1974, 'n_words': 384}