Skip to content

Commit

Permalink
Add a stress test to the parser to parser multi-millions tokens (#4086)
Browse files Browse the repository at this point in the history
  • Loading branch information
hansl authored Dec 14, 2024
1 parent 6f2dca8 commit e529d70
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions core/parser/src/parser/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -623,3 +623,14 @@ fn deny_unicode_escape_in_true_expression() {
fn deny_unicode_escape_in_null_expression() {
check_invalid_script(r"let x = n\u{75}ll;");
}

#[test]
fn stress_test_operations() {
let src = ("1 * 2 + /* comment why not */ 3 / 4 % 5 + ".repeat(1_000)
+ "1; // end of line\n\n")
.repeat(1_000);

assert!(Parser::new(Source::from_bytes(&src))
.parse_script(&Scope::new_global(), &mut Interner::default())
.is_ok());
}

0 comments on commit e529d70

Please sign in to comment.