ParserTester

Struct ParserTester 

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

A concurrent parser testing utility that can run tests against multiple files with timeout support.

The ParserTester provides functionality to test parsers against a directory of files with specific extensions, comparing actual output against expected results stored in JSON files, with configurable timeout protection.

Implementations§

Source§

impl ParserTester

Source

pub fn new<P: AsRef<Path>>(root: P) -> Self

Creates a new parser tester with the specified root directory and default 10-second timeout.

Source

pub fn with_extension(self, extension: impl ToString) -> Self

Adds a file extension to test against.

Source

pub fn with_timeout(self, timeout: Duration) -> Self

Sets the timeout for parsing operations.

§Arguments
  • timeout - The maximum duration to wait for parsing to complete
§Returns

A new ParserTester with the specified timeout

Source

pub fn run_tests<L, P>(self, parser: &P) -> Result<(), OakError>
where P: Parser<L> + Send + Sync, L: Language + Send + Sync, L::SyntaxKind: Serialize + Debug + Sync + Send,

Run tests for the given parser against all files in the root directory with the specified extensions.

§Arguments
  • parser: The parser to test.
§Examples
use oak_core::helpers::parsing::ParserTester;

let tester = ParserTester::new("tests/parser").with_extension("tex");
tester.run_tests(my_parser)?;

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.
Source§

impl<T> ErasedDestructor for T
where T: 'static,