From 8c99b1a8e7b889b64cd1e5f378d000651a932a62 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sun, 10 Dec 2023 10:59:13 -0800 Subject: [PATCH] Rewrite explanation of test_precedence --- tests/test_precedence.rs | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/tests/test_precedence.rs b/tests/test_precedence.rs index 36e2e51c6b..ce834e2e22 100644 --- a/tests/test_precedence.rs +++ b/tests/test_precedence.rs @@ -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))]