Skip to content

Commit

Permalink
Add regression test for igordejanovic#16, subtract overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Baxter committed Oct 15, 2024
1 parent 139c99d commit 228d118
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tests/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,10 @@ fn main() {
"glr/special/farshi_g8",
Box::new(|s| s.parser_algo(ParserAlgo::GLR)),
),
(
"glr/regressions/issue_16_subtract_overflow_panic",
Box::new(|s| s.parser_algo(ParserAlgo::GLR)),
),
];

for (test, config) in tests {
Expand Down
1 change: 1 addition & 0 deletions tests/src/glr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ mod errors;
mod evaluate;
mod forest;
mod lexical_ambiguity;
mod regressions;
mod special;
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
Inline: InlineEl*;
InlineEl: prefix=StrongDelim children=Inline suffix=StrongDelim? {Strong, 11, left}
| prefix=EmphasisDelim children=Inline suffix=EmphasisDelim? {Emphasis, 11, left}
| title_prefix=LinkTitlePrefix title=Inline continuation=Link1? {Link , 11, left}
| prefix=CodeDelim text=CodeChar* suffix=CodeDelim? {Code, 11, left}
| text=TextChar+ {Text, 9, left};

StrongDelim: StrongT;

EmphasisDelim: EmphasisT;

LinkTitlePrefix: LinkTitlePrefixT;
LinkTitleSuffix: LinkTitleSuffixT;
LinkAddressPrefix: LinkAddressPrefixT;
LinkAddressSuffix: LinkAddressSuffixT;
Link1: title_suffix=LinkTitleSuffix address=LinkAddress?;
LinkAddress: prefix=LinkAddressPrefix address=LinkAddressChar* suffix=LinkAddressSuffix?;
LinkAddressChar: LinkAddressCharT | EscapedChar;

CodeDelim: CodeDelimT;
CodeChar: CodeCharT | EscapedChar;

TextChar: TextCharT | EscapedChar;

EscapeChar: EscapeT;
EscapedChar: prefix=EscapeChar text=AnyCharT;

Layout: Empty;

terminals
Empty: "";
EscapeT: "\\";
AnyCharT: /./;
TextCharT: /[^*_`\\]/;
CodeDelimT: "`";
CodeCharT: /[^`\\]/;
LinkTitlePrefixT: "[";
LinkTitleSuffixT: "](";
LinkAddressPrefixT: "(";
LinkAddressSuffixT: ")";
LinkAddressCharT: /[^)\\]/;
StrongT: "*";
EmphasisT: "_";
22 changes: 22 additions & 0 deletions tests/src/glr/regressions/issue_16_subtract_overflow_panic/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
use rustemo::{rustemo_mod, Parser};

rustemo_mod!(
inline,
"/src/glr/regressions/issue_16_subtract_overflow_panic"
);
rustemo_mod!(
inline_actions,
"/src/glr/regressions/issue_16_subtract_overflow_panic"
);

use self::inline::{DefaultBuilder, InlineParser};

#[test]
fn subtract_overflow() {
InlineParser::new()
.parse("*ld 2")
.unwrap()
.get_first_tree()
.unwrap()
.build(&mut DefaultBuilder::new());
}
1 change: 1 addition & 0 deletions tests/src/glr/regressions/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mod issue_16_subtract_overflow_panic;

0 comments on commit 228d118

Please sign in to comment.