Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a simple way to manually generate Pair #469

Open
gjvnq opened this issue Jul 24, 2020 · 0 comments
Open

Add a simple way to manually generate Pair #469

gjvnq opened this issue Jul 24, 2020 · 0 comments

Comments

@gjvnq
Copy link

gjvnq commented Jul 24, 2020

Hi, I am writing some unit tests for a function that takes Pair<'_, Rule> as an input. The problem is that I am forced to call the parser to generate those pairs, thus making my unit tests not that independent.

Example: I have

let input = EbolParser::parse(Rule::Integer, "42").unwrap();
println!("{:?}", input); // Prints: [Pair { rule: Integer, span: Span { str: "42", start: 0, end: 2 }, inner: [] }]
my_function(input.peek());

But I would like to have something like:

let input = Pair { rule: Rule::Integer, span: Span { str: "42", start: 0, end: 2 }, inner: [] };
my_function(input);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants