@@ -36,33 +36,32 @@ module.exports = {
36
36
*compare two test cases despite of properties order.
37
37
*@returns {boolean } if eq, return true, else return false.
38
38
*/
39
- function eq ( ta , tb ) {
40
- if ( ta . type !== tb . type ) {
39
+ function eq ( testA , testB ) {
40
+ if ( testA . type !== testB . type ) {
41
41
return false ;
42
42
}
43
43
44
- if ( ta . type !== 'ObjectExpression' ) {
45
- return sourceCode . getText ( ta ) === sourceCode . getText ( tb ) ;
44
+ if ( testA . type !== 'ObjectExpression' ) {
45
+ return sourceCode . getText ( testA ) === sourceCode . getText ( testB ) ;
46
46
}
47
47
48
- const pa = ta . properties || [ ] ;
49
- const pb = tb . properties || [ ] ;
48
+ const propertiesA = testA . properties || [ ] ;
49
+ const propertiesB = testB . properties || [ ] ;
50
50
51
51
// if properties length not eq; return false;
52
- if ( pa . length !== pb . length ) {
52
+ if ( propertiesA . length !== propertiesB . length ) {
53
53
return false ;
54
54
}
55
55
56
- // convert array to object
57
- const paObj = Object . create ( null ) ;
58
- pa . forEach ( item => {
56
+ const propertiesSetA = new Set ( ) ;
57
+ propertiesA . forEach ( item => {
59
58
const code = sourceCode . getText ( item ) ;
60
- paObj [ code ] = true ;
59
+ propertiesSetA . add ( code ) ;
61
60
} ) ;
62
61
63
- for ( let i = 0 ; i < pb . length ; i ++ ) {
64
- const code = sourceCode . getText ( pb [ i ] ) ;
65
- if ( ! paObj [ code ] ) {
62
+ for ( let i = 0 ; i < propertiesB . length ; i ++ ) {
63
+ const code = sourceCode . getText ( propertiesB [ i ] ) ;
64
+ if ( ! propertiesSetA . has ( code ) ) {
66
65
return false ;
67
66
}
68
67
}
0 commit comments