diff --git a/tests/fixtures/code-path-analysis/class-field--conditional.js b/tests/fixtures/code-path-analysis/class-field--conditional.js new file mode 100644 index 00000000000..e39be7ee065 --- /dev/null +++ b/tests/fixtures/code-path-analysis/class-field--conditional.js @@ -0,0 +1,20 @@ +/*expected +initial->s1_1->s1_2->s1_4; +s1_1->s1_3->s1_4->final; +*/ + +class x { a = b ? c : d } + +/*DOT +digraph { + node[shape=box,style="rounded,filled",fillcolor=white]; + initial[label="",shape=circle,style=filled,fillcolor=black,width=0.25,height=0.25]; + final[label="",shape=doublecircle,style=filled,fillcolor=black,width=0.25,height=0.25]; + s1_1[label="Program:enter\nClassDeclaration:enter\nIdentifier (x)\nClassBody:enter\nPropertyDefinition:enter\nIdentifier (a)\nConditionalExpression:enter\nIdentifier (b)"]; + s1_2[label="Identifier (c)"]; + s1_4[label="ConditionalExpression:exit\nPropertyDefinition:exit\nClassBody:exit\nClassDeclaration:exit\nProgram:exit"]; + s1_3[label="Identifier (d)"]; + initial->s1_1->s1_2->s1_4; + s1_1->s1_3->s1_4->final; +} +*/ diff --git a/tests/fixtures/code-path-analysis/object-literal--conditional.js b/tests/fixtures/code-path-analysis/object-literal--conditional.js new file mode 100644 index 00000000000..c5a4145a8be --- /dev/null +++ b/tests/fixtures/code-path-analysis/object-literal--conditional.js @@ -0,0 +1,20 @@ +/*expected +initial->s1_1->s1_2->s1_4; +s1_1->s1_3->s1_4->final; +*/ + +x = { a: b ? c : d } + +/*DOT +digraph { + node[shape=box,style="rounded,filled",fillcolor=white]; + initial[label="",shape=circle,style=filled,fillcolor=black,width=0.25,height=0.25]; + final[label="",shape=doublecircle,style=filled,fillcolor=black,width=0.25,height=0.25]; + s1_1[label="Program:enter\nExpressionStatement:enter\nAssignmentExpression:enter\nIdentifier (x)\nObjectExpression:enter\nProperty:enter\nIdentifier (a)\nConditionalExpression:enter\nIdentifier + (b)"]; + s1_2[label="Identifier (c)"]; + s1_4[label="ConditionalExpression:exit\nProperty:exit\nObjectExpression:exit\nAssignmentExpression:exit\nExpressionStatement:exit\nProgram:exit"]; + s1_3[label="Identifier (d)"]; + initial->s1_1->s1_2->s1_4; + s1_1->s1_3->s1_4->final; +}*/ diff --git a/tests/lib/linter/code-path-analysis/code-path-analyzer.js b/tests/lib/linter/code-path-analysis/code-path-analyzer.js index b2356f24691..0b5dd33aab8 100644 --- a/tests/lib/linter/code-path-analysis/code-path-analyzer.js +++ b/tests/lib/linter/code-path-analysis/code-path-analyzer.js @@ -561,11 +561,11 @@ describe("CodePathAnalyzer", () => { } })); const messages = linter.verify(source, { - parserOptions: { ecmaVersion: 2021 }, + parserOptions: { ecmaVersion: 2022 }, rules: { test: 2 } }); - assert.strictEqual(messages.length, 0); + assert.strictEqual(messages.length, 0, "Unexpected linting error in code."); assert.strictEqual(actual.length, expected.length, "a count of code paths is wrong."); for (let i = 0; i < actual.length; ++i) {