Skip to content

Commit

Permalink
Rewrite explanation of test_precedence
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Dec 10, 2023
1 parent 4237624 commit 8c99b1a
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions tests/test_precedence.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
//! The tests in this module do the following:
//! This test does the following for every file in the rust-lang/rust repo:
//!
//! 1. Parse a given expression in both `syn` and `librustc`.
//! 2. Fold over the expression adding brackets around each subexpression (with
//! some complications - see the `syn_brackets` and `librustc_brackets`
//! methods).
//! 3. Serialize the `syn` expression back into a string, and re-parse it with
//! `librustc`.
//! 4. Respan all of the expressions, replacing the spans with the default
//! spans.
//! 5. Compare the expressions with one another, if they are not equal fail.
//! 1. Parse the file using syn into a syn::File.
//! 2. Extract every syn::Expr from the file.
//! 3. Print each expr to a string of source code.
//! 4. Parse the source code using librustc_parse into a rustc_ast::Expr.
//! 5. For both the syn::Expr and rustc_ast::Expr, crawl the syntax tree to
//! insert parentheses surrounding every subexpression.
//! 6. Serialize the fully parenthesized syn::Expr to a string of source code.
//! 7. Parse the fully parenthesized source code using librustc_parse.
//! 8. Compare the rustc_ast::Expr resulting from parenthesizing using rustc
//! data structures vs syn data structures, ignoring spans. If they agree,
//! rustc's parser and syn's parser have identical handling of expression
//! precedence.
#![cfg(not(syn_disable_nightly_tests))]
#![cfg(not(miri))]
Expand Down

0 comments on commit 8c99b1a

Please sign in to comment.