TestGenerator

Struct TestGenerator 

Source
pub struct TestGenerator { /* private fields */ }
Expand description

Test generator for transpiled Rust functions.

Generates comprehensive test suites including unit tests, property tests, doc tests, and mutation test configurations.

Implementations§

Source§

impl TestGenerator

Source

pub fn new(config: TestGenConfig) -> Self

Create a new test generator with the given configuration.

§Examples
use decy_codegen::test_generator::{TestGenerator, TestGenConfig};

let config = TestGenConfig::default();
let generator = TestGenerator::new(config);
Source

pub fn config(&self) -> &TestGenConfig

Get the test generator configuration.

Source

pub fn generate_tests(&self, hir_func: &HirFunction) -> GeneratedTests

Generate a complete test suite for a HIR function.

§Arguments
  • hir_func - The HIR function to generate tests for
§Returns

A GeneratedTests struct containing all generated test code.

§Examples
use decy_codegen::test_generator::{TestGenerator, TestGenConfig};
use decy_hir::{HirFunction, HirType, HirParameter};

let generator = TestGenerator::new(TestGenConfig::default());

let func = HirFunction::new(
    "add".to_string(),
    HirType::Int,
    vec![
        HirParameter::new("a".to_string(), HirType::Int),
        HirParameter::new("b".to_string(), HirType::Int),
    ],
);

let tests = generator.generate_tests(&func);
assert!(tests.unit_tests.len() >= 5);

Trait Implementations§

Source§

impl Debug for TestGenerator

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.