@@ -41,7 +41,10 @@ ruleTester.run("no-cond-assign", rule, {
41
41
{ code : "if (function(node) { return node = parentNode; }) { }" , options : [ "except-parens" ] } ,
42
42
{ code : "if (function(node) { return node = parentNode; }) { }" , options : [ "always" ] } ,
43
43
{ code : "x = 0;" , options : [ "always" ] } ,
44
- "var x; var b = (x === 0) ? 1 : 0;"
44
+ "var x; var b = (x === 0) ? 1 : 0;" ,
45
+ { code : "switch (foo) { case a = b: bar(); }" , options : [ "except-parens" ] } ,
46
+ { code : "switch (foo) { case a = b: bar(); }" , options : [ "always" ] } ,
47
+ { code : "switch (foo) { case baz + (a = b): bar(); }" , options : [ "always" ] }
45
48
] ,
46
49
invalid : [
47
50
{ code : "var x; if (x = 0) { var b = 1; }" , errors : [ { messageId : "missing" , type : "IfStatement" , line : 1 , column : 12 } ] } ,
@@ -62,6 +65,7 @@ ruleTester.run("no-cond-assign", rule, {
62
65
{ code : "do { } while ((x = x + 1));" , options : [ "always" ] , errors : [ { messageId : "unexpected" , data : { type : "a 'do...while' statement" } , type : "DoWhileStatement" } ] } ,
63
66
{ code : "for(; (x = y); ) { }" , options : [ "always" ] , errors : [ { messageId : "unexpected" , data : { type : "a 'for' statement" } , type : "ForStatement" } ] } ,
64
67
{ code : "var x; var b = (x = 0) ? 1 : 0;" , errors : [ { messageId : "missing" , type : "ConditionalExpression" } ] } ,
68
+ { code : "var x; var b = x && (y = 0) ? 1 : 0;" , options : [ "always" ] , errors : [ { messageId : "unexpected" , type : "ConditionalExpression" } ] } ,
65
69
{ code : "(((3496.29)).bkufyydt = 2e308) ? foo : bar;" , errors : [ { messageId : "missing" , type : "ConditionalExpression" } ] }
66
70
]
67
71
} ) ;
0 commit comments