Skip to content

Commit d2176d4

Browse files
committed
test: improve the test case.
1 parent a9d3840 commit d2176d4

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

crates/oxc_cfg/tests/builder.rs

+10-6
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,36 @@
11
use oxc_cfg::{ControlFlowGraphBuilder, CtxCursor};
2+
use oxc_syntax::node::AstNodeId;
23
/// same as but just the skeleton
34
/// ```js
45
/// A: {
56
/// do {} while (a);
67
/// do {} while (b);
8+
/// break A;
79
/// }
810
/// ```
911
#[test]
10-
fn labeled_statement_with_multiple_loops_and_continue() {
12+
fn labeled_statement_with_multiple_loops_continue_and_break() {
1113
const A: Option<&str> = Some("A");
1214

1315
let mut cfg = ControlFlowGraphBuilder::default();
1416
cfg.attach_error_harness(oxc_cfg::ErrorEdgeKind::Implicit);
1517

1618
// labeled block start
17-
let _ = cfg.new_basic_block_normal();
18-
cfg.ctx(A).default().allow_continue();
19+
let labeled = cfg.new_basic_block_normal();
20+
cfg.ctx(A).default().allow_break().allow_continue();
1921

2022
// loop context 1
2123
let c1 = cfg.new_basic_block_normal();
2224
cfg.ctx(None).default().allow_break().allow_continue();
23-
cfg.ctx(None).mark_continue(c1).resolve_with_upper_label();
25+
cfg.ctx(None).mark_break(c1).mark_continue(c1).resolve_with_upper_label();
2426

2527
// loop context 2
2628
let c2 = cfg.new_basic_block_normal();
2729
cfg.ctx(None).default().allow_break().allow_continue();
28-
cfg.ctx(None).mark_continue(c2).resolve_with_upper_label();
30+
cfg.ctx(None).mark_break(c2).mark_continue(c2).resolve_with_upper_label();
31+
32+
cfg.append_break(AstNodeId::dummy(), A);
2933

3034
// labeled block end
31-
cfg.ctx(A).resolve();
35+
cfg.ctx(A).mark_break(labeled).resolve();
3236
}

0 commit comments

Comments
 (0)