-
-
Notifications
You must be signed in to change notification settings - Fork 932
Closed
Labels
C-enhancementCategory - New feature or requestCategory - New feature or request
Description
This issue is follow-up of #1227 and #2498.
Status quo
oxc currently rely on test262 and manual testing.
manual testing:
oxc/tasks/coverage/src/test262.rs
Lines 212 to 235 in e2d2ce3
| fn are_all_identifiers_resolved(semantic: &oxc_semantic::Semantic<'_>) -> bool { | |
| use oxc_ast::AstKind; | |
| use oxc_semantic::AstNode; | |
| let ast_nodes = semantic.nodes(); | |
| let has_non_resolved = ast_nodes.iter().any(|node| { | |
| match node.kind() { | |
| AstKind::BindingIdentifier(id) => { | |
| let mut parents = ast_nodes.iter_parents(node.id()).map(AstNode::kind); | |
| parents.next(); // Exclude BindingIdentifier itself | |
| if let (Some(AstKind::Function(_)), Some(AstKind::IfStatement(_))) = | |
| (parents.next(), parents.next()) | |
| { | |
| return false; | |
| } | |
| id.symbol_id.get().is_none() | |
| } | |
| AstKind::IdentifierReference(ref_id) => ref_id.reference_id.get().is_none(), | |
| _ => false, | |
| } | |
| }); | |
| !has_non_resolved | |
| } |
- test262 only ensure the all indentifier are resolved, doesn't ensure correctness.
- Manual testing ensure correctness but only have a few cases.
Problems
With the above summary, the current scope analysis is running in half dark.
- Can't not detect effects/changes. If someone changes scope analysis code, we could only rely on the few manual tests to ensure the correctness.
- Dx of writing Manual tests is bad. The API could handle simple cases well. But we have to admit that, as much as we want to try make the test case simple, there's a bigger chance we need to handle complicated code. Writing manual tests for them seems impossible with current test API.
Solutions
- We assume the current scope analysis behaviors are correct and visualize them in snapshot testing.
- Visualize scope information of tests262 and also manual tests.
If someone change scope analysis code, we could review if it is correct by review changes of snapshot.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
C-enhancementCategory - New feature or requestCategory - New feature or request
Type
Fields
Give feedbackPriority
None yet