Skip to content

Commit

Permalink
test(semantic): add a test for UpdateExpression (#7495)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dunqing committed Nov 27, 2024
1 parent 4b0720a commit fed8327
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Read | Write
let num = 0;

num ++;
num --
++ num;
-- num;

// Read
let obj = { num: 0 };

obj.num ++;
obj.num --;
++ obj.num;
-- obj.num;
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
---
source: crates/oxc_semantic/tests/main.rs
input_file: crates/oxc_semantic/tests/fixtures/oxc/js/assignments/update-expression.js
---
[
{
"children": [],
"flags": "ScopeFlags(StrictMode | Top)",
"id": 0,
"node": "Program",
"symbols": [
{
"flags": "SymbolFlags(BlockScopedVariable)",
"id": 0,
"name": "num",
"node": "VariableDeclarator(num)",
"references": [
{
"flags": "ReferenceFlags(Read | Write)",
"id": 0,
"name": "num",
"node_id": 8
},
{
"flags": "ReferenceFlags(Read | Write)",
"id": 1,
"name": "num",
"node_id": 12
},
{
"flags": "ReferenceFlags(Read | Write)",
"id": 2,
"name": "num",
"node_id": 16
},
{
"flags": "ReferenceFlags(Read | Write)",
"id": 3,
"name": "num",
"node_id": 20
}
]
},
{
"flags": "SymbolFlags(BlockScopedVariable)",
"id": 1,
"name": "obj",
"node": "VariableDeclarator(obj)",
"references": [
{
"flags": "ReferenceFlags(Read)",
"id": 4,
"name": "obj",
"node_id": 33
},
{
"flags": "ReferenceFlags(Read)",
"id": 5,
"name": "obj",
"node_id": 39
},
{
"flags": "ReferenceFlags(Read)",
"id": 6,
"name": "obj",
"node_id": 45
},
{
"flags": "ReferenceFlags(Read)",
"id": 7,
"name": "obj",
"node_id": 51
}
]
}
]
}
]

0 comments on commit fed8327

Please sign in to comment.