Skip to content

Commit

Permalink
updates for new parser module
Browse files Browse the repository at this point in the history
  • Loading branch information
addisoncrump committed Nov 6, 2022
1 parent 6d4d6ff commit a5350f9
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
18 changes: 18 additions & 0 deletions fuzz/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions fuzz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ libfuzzer-sys = "0.4"
boa_ast = { path = "../boa_ast", features = ["fuzz"] }
boa_engine = { path = "../boa_engine", features = ["fuzz"] }
boa_interner = { path = "../boa_interner", features = ["fuzz"] }
boa_parser = { path = "../boa_parser" }

# Prevent this from interfering with workspaces
[workspace]
Expand Down
6 changes: 3 additions & 3 deletions fuzz/fuzz_targets/parser-idempotency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
mod common;

use crate::common::FuzzData;
use boa_engine::syntax::Parser;
use boa_interner::ToInternedString;
use boa_parser::Parser;
use libfuzzer_sys::fuzz_target;
use libfuzzer_sys::Corpus;
use std::error::Error;
Expand All @@ -21,7 +21,7 @@ fn do_fuzz(mut data: FuzzData) -> Result<(), Box<dyn Error>> {
let before = data.context.interner().len();
// For a variety of reasons, we may not actually produce valid code here (e.g., nameless function).
// Fail fast and only make the next checks if we were valid.
if let Ok(first) = parser.parse_all(&mut data.context) {
if let Ok(first) = parser.parse_all(data.context.interner_mut()) {
let after_first = data.context.interner().len();
let first_interned = first.to_interned_string(data.context.interner());

Expand All @@ -38,7 +38,7 @@ fn do_fuzz(mut data: FuzzData) -> Result<(), Box<dyn Error>> {

// Now, we most assuredly should produce valid code. It has already gone through a first pass.
let second = parser
.parse_all(&mut data.context)
.parse_all(data.context.interner_mut())
.expect("Could not parse the first-pass interned copy.");
let second_interned = second.to_interned_string(data.context.interner());
let after_second = data.context.interner().len();
Expand Down

0 comments on commit a5350f9

Please sign in to comment.