Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cca38a6

Browse files
committed
JS: Add test for flow to a closure body under a type guard
1 parent 53def60 commit cca38a6

2 files changed

Lines changed: 47 additions & 33 deletions

File tree

javascript/ql/test/library-tests/frameworks/Redux/react-redux.jsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ function manualReducer(state, action) {
3838
if (action.type === 'manualAction') {
3939
return { ...state, manualValue2: action.payload };
4040
}
41+
if (action.type === 'manualAction') {
42+
return {
43+
...state,
44+
manualValue3: [1, 2, 3].map(x => {
45+
return action.payload + x;
46+
})
47+
};
48+
}
4149
return state;
4250
}
4351
const asyncAction = rt.createAsyncThunk('asyncAction', (x) => {
@@ -65,6 +73,7 @@ function MyComponent(props) {
6573
sink(props.propFromToolkitAction); // NOT OK
6674
sink(props.propFromManualAction); // NOT OK
6775
sink(props.propFromManualAction2); // NOT OK
76+
sink(props.propFromManualAction3); // NOT OK
6877
sink(props.propFromAsync); // NOT OK
6978

7079
return <button onClick={{clickHandler}}/>
@@ -75,7 +84,8 @@ function mapStateToProps(state) {
7584
propFromToolkitAction: state.toolkit.value,
7685
propFromAsync: state.toolkit.asyncValue,
7786
propFromManualAction: state.manual.manualValue,
78-
propFromManualAction2: state.manual.manualValue2
87+
propFromManualAction2: state.manual.manualValue2,
88+
propFromManualAction3: state.manual.manualValue3,
7989
}
8090
}
8191

javascript/ql/test/library-tests/frameworks/Redux/test.expected

Lines changed: 36 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ reducerArg
22
| exportedReducer.js:12:12:12:35 | (state, ... > state |
33
| react-redux.jsx:12:33:17:9 | (state, ... } |
44
| react-redux.jsx:18:41:23:9 | (state, ... } |
5-
| react-redux.jsx:51:30:54:2 | rt.comb ... cer,\\n}) |
6-
| react-redux.jsx:52:14:52:27 | toolkitReducer |
7-
| react-redux.jsx:53:13:53:25 | manualReducer |
5+
| react-redux.jsx:59:30:62:2 | rt.comb ... cer,\\n}) |
6+
| react-redux.jsx:60:14:60:27 | toolkitReducer |
7+
| react-redux.jsx:61:13:61:25 | manualReducer |
88
| trivial.js:10:10:10:33 | (state, ... > state |
99
| trivial.js:11:10:13:5 | {\\n ... ,\\n } |
1010
| trivial.js:12:14:12:37 | (state, ... > state |
@@ -37,14 +37,14 @@ isTypeTagHandler
3737
| fooAction | trivial.js:32:73:32:96 | (state, ... > state |
3838
| toolkitAction | react-redux.jsx:12:33:17:9 | (state, ... } |
3939
isRootStateHandler
40-
| react-redux.jsx:51:30:54:2 | rt.comb ... cer,\\n}) |
40+
| react-redux.jsx:59:30:62:2 | rt.comb ... cer,\\n}) |
4141
| trivial.js:133:45:133:66 | combine ... Reducer |
4242
| trivial.js:134:56:134:79 | (state, ... > state |
4343
| trivial.js:136:14:136:37 | (state, ... > state |
4444
delegatingReducer
4545
| exportedReducer.js:11:30:13:2 | combine ... tate\\n}) |
4646
| react-redux.jsx:10:24:24:2 | rt.crea ... });\\n}) |
47-
| react-redux.jsx:51:30:54:2 | rt.comb ... cer,\\n}) |
47+
| react-redux.jsx:59:30:62:2 | rt.comb ... cer,\\n}) |
4848
| trivial.js:9:22:14:2 | require ... }\\n}) |
4949
| trivial.js:11:10:13:5 | {\\n ... ,\\n } |
5050
| trivial.js:15:26:20:2 | require ... }\\n}) |
@@ -64,8 +64,8 @@ delegatingReducer
6464
| trivial.js:129:32:131:2 | require ... te),\\n}) |
6565
getStateHandlerArg
6666
| exportedReducer.js:11:30:13:2 | combine ... tate\\n}) | inner | exportedReducer.js:12:12:12:35 | (state, ... > state |
67-
| react-redux.jsx:51:30:54:2 | rt.comb ... cer,\\n}) | manual | react-redux.jsx:53:13:53:25 | manualReducer |
68-
| react-redux.jsx:51:30:54:2 | rt.comb ... cer,\\n}) | toolkit | react-redux.jsx:52:14:52:27 | toolkitReducer |
67+
| react-redux.jsx:59:30:62:2 | rt.comb ... cer,\\n}) | manual | react-redux.jsx:61:13:61:25 | manualReducer |
68+
| react-redux.jsx:59:30:62:2 | rt.comb ... cer,\\n}) | toolkit | react-redux.jsx:60:14:60:27 | toolkitReducer |
6969
| trivial.js:9:22:14:2 | require ... }\\n}) | bar | trivial.js:11:10:13:5 | {\\n ... ,\\n } |
7070
| trivial.js:9:22:14:2 | require ... }\\n}) | foo | trivial.js:10:10:10:33 | (state, ... > state |
7171
| trivial.js:11:10:13:5 | {\\n ... ,\\n } | baz | trivial.js:12:14:12:37 | (state, ... > state |
@@ -95,35 +95,36 @@ getAPlainHandlerArg
9595
| trivial.js:42:25:42:109 | require ... cers1]) | trivial.js:42:66:42:89 | (state, ... > state |
9696
| trivial.js:42:25:42:109 | require ... cers1]) | trivial.js:42:92:42:107 | reducerReducers1 |
9797
getUseSite
98-
| react-redux.jsx:10:24:24:2 | rt.crea ... });\\n}) | react-redux.jsx:52:14:52:27 | toolkitReducer |
99-
| react-redux.jsx:51:30:54:2 | rt.comb ... cer,\\n}) | react-redux.jsx:51:30:54:2 | rt.comb ... cer,\\n}) |
98+
| react-redux.jsx:10:24:24:2 | rt.crea ... });\\n}) | react-redux.jsx:60:14:60:27 | toolkitReducer |
99+
| react-redux.jsx:59:30:62:2 | rt.comb ... cer,\\n}) | react-redux.jsx:59:30:62:2 | rt.comb ... cer,\\n}) |
100100
| trivial.js:11:10:13:5 | {\\n ... ,\\n } | trivial.js:11:10:13:5 | {\\n ... ,\\n } |
101101
| trivial.js:17:10:19:5 | {\\n ... ,\\n } | trivial.js:17:10:19:5 | {\\n ... ,\\n } |
102102
| trivial.js:23:10:25:5 | {\\n ... ,\\n } | trivial.js:23:10:25:5 | {\\n ... ,\\n } |
103103
| trivial.js:129:32:131:2 | require ... te),\\n}) | trivial.js:133:45:133:66 | combine ... Reducer |
104104
storeCreation
105-
| react-redux.jsx:51:15:54:3 | rt.crea ... er,\\n})) |
105+
| react-redux.jsx:59:15:62:3 | rt.crea ... er,\\n})) |
106106
| trivial.js:133:16:133:67 | require ... educer) |
107107
| trivial.js:134:16:134:80 | require ... state) |
108108
| trivial.js:135:16:137:2 | require ... tate\\n}) |
109109
taintFlow
110-
| react-redux.jsx:59:29:59:36 | source() | react-redux.jsx:65:10:65:36 | props.p ... tAction |
111-
| react-redux.jsx:61:31:61:38 | source() | react-redux.jsx:66:10:66:35 | props.p ... lAction |
112-
| react-redux.jsx:61:31:61:38 | source() | react-redux.jsx:67:10:67:36 | props.p ... Action2 |
113-
| react-redux.jsx:62:30:62:37 | source() | react-redux.jsx:68:10:68:28 | props.propFromAsync |
110+
| react-redux.jsx:67:29:67:36 | source() | react-redux.jsx:73:10:73:36 | props.p ... tAction |
111+
| react-redux.jsx:69:31:69:38 | source() | react-redux.jsx:74:10:74:35 | props.p ... lAction |
112+
| react-redux.jsx:69:31:69:38 | source() | react-redux.jsx:75:10:75:36 | props.p ... Action2 |
113+
| react-redux.jsx:69:31:69:38 | source() | react-redux.jsx:76:10:76:36 | props.p ... Action3 |
114+
| react-redux.jsx:70:30:70:37 | source() | react-redux.jsx:77:10:77:28 | props.propFromAsync |
114115
getAffectedStateAccessPath
115116
| react-redux.jsx:12:33:17:9 | (state, ... } | toolkit |
116117
| react-redux.jsx:18:41:23:9 | (state, ... } | toolkit |
117-
| react-redux.jsx:52:14:52:27 | toolkitReducer | toolkit |
118-
| react-redux.jsx:53:13:53:25 | manualReducer | manual |
118+
| react-redux.jsx:60:14:60:27 | toolkitReducer | toolkit |
119+
| react-redux.jsx:61:13:61:25 | manualReducer | manual |
119120
| trivial.js:130:14:130:46 | wrapper ... state) | wrapped |
120121
getADispatchFunctionReference
121-
| react-redux.jsx:57:20:57:32 | useDispatch() |
122+
| react-redux.jsx:65:20:65:32 | useDispatch() |
122123
getADispatchedValueSource
123124
| react-redux.jsx:26:1:31:1 | return of function manualAction |
124125
| react-redux.jsx:27:12:30:5 | {\\n ... x\\n } |
125-
| react-redux.jsx:61:18:61:39 | manualA ... urce()) |
126-
| react-redux.jsx:62:18:62:38 | asyncAc ... urce()) |
126+
| react-redux.jsx:69:18:69:39 | manualA ... urce()) |
127+
| react-redux.jsx:70:18:70:38 | asyncAc ... urce()) |
127128
getAnUntypedActionInReducer
128129
| exportedReducer.js:12:20:12:25 | action |
129130
| react-redux.jsx:32:31:32:36 | action |
@@ -141,18 +142,21 @@ actionToReducerStep
141142
| react-redux.jsx:5:56:9:1 | return of anonymous function | react-redux.jsx:14:24:14:37 | action.payload |
142143
| react-redux.jsx:29:18:29:18 | x | react-redux.jsx:35:45:35:58 | action.payload |
143144
| react-redux.jsx:29:18:29:18 | x | react-redux.jsx:39:42:39:55 | action.payload |
144-
| react-redux.jsx:59:29:59:36 | source() | react-redux.jsx:5:57:5:57 | x |
145-
| react-redux.jsx:62:30:62:37 | source() | react-redux.jsx:43:57:43:57 | x |
145+
| react-redux.jsx:29:18:29:18 | x | react-redux.jsx:45:24:45:37 | action.payload |
146+
| react-redux.jsx:67:29:67:36 | source() | react-redux.jsx:5:57:5:57 | x |
147+
| react-redux.jsx:70:30:70:37 | source() | react-redux.jsx:51:57:51:57 | x |
146148
actionToReducerPromiseStep
147-
| react-redux.jsx:43:56:49:1 | return of anonymous function | react-redux.jsx:20:29:20:42 | action.payload |
149+
| react-redux.jsx:51:56:57:1 | return of anonymous function | react-redux.jsx:20:29:20:42 | action.payload |
148150
reducerToStateStep
149-
| react-redux.jsx:12:33:17:9 | return of anonymous function | react-redux.jsx:75:32:75:44 | state.toolkit |
150-
| react-redux.jsx:12:33:17:9 | return of anonymous function | react-redux.jsx:76:24:76:36 | state.toolkit |
151-
| react-redux.jsx:14:24:14:50 | action. ... itValue | react-redux.jsx:75:32:75:50 | state.toolkit.value |
152-
| react-redux.jsx:18:41:23:9 | return of anonymous function | react-redux.jsx:75:32:75:44 | state.toolkit |
153-
| react-redux.jsx:18:41:23:9 | return of anonymous function | react-redux.jsx:76:24:76:36 | state.toolkit |
154-
| react-redux.jsx:20:29:20:44 | action.payload.x | react-redux.jsx:76:24:76:47 | state.t ... ncValue |
155-
| react-redux.jsx:32:1:42:1 | return of function manualReducer | react-redux.jsx:77:31:77:42 | state.manual |
156-
| react-redux.jsx:32:1:42:1 | return of function manualReducer | react-redux.jsx:78:32:78:43 | state.manual |
157-
| react-redux.jsx:35:45:35:58 | action.payload | react-redux.jsx:77:31:77:54 | state.m ... alValue |
158-
| react-redux.jsx:39:42:39:55 | action.payload | react-redux.jsx:78:32:78:56 | state.m ... lValue2 |
151+
| react-redux.jsx:12:33:17:9 | return of anonymous function | react-redux.jsx:84:32:84:44 | state.toolkit |
152+
| react-redux.jsx:12:33:17:9 | return of anonymous function | react-redux.jsx:85:24:85:36 | state.toolkit |
153+
| react-redux.jsx:14:24:14:50 | action. ... itValue | react-redux.jsx:84:32:84:50 | state.toolkit.value |
154+
| react-redux.jsx:18:41:23:9 | return of anonymous function | react-redux.jsx:84:32:84:44 | state.toolkit |
155+
| react-redux.jsx:18:41:23:9 | return of anonymous function | react-redux.jsx:85:24:85:36 | state.toolkit |
156+
| react-redux.jsx:20:29:20:44 | action.payload.x | react-redux.jsx:85:24:85:47 | state.t ... ncValue |
157+
| react-redux.jsx:32:1:50:1 | return of function manualReducer | react-redux.jsx:86:31:86:42 | state.manual |
158+
| react-redux.jsx:32:1:50:1 | return of function manualReducer | react-redux.jsx:87:32:87:43 | state.manual |
159+
| react-redux.jsx:32:1:50:1 | return of function manualReducer | react-redux.jsx:88:32:88:43 | state.manual |
160+
| react-redux.jsx:35:45:35:58 | action.payload | react-redux.jsx:86:31:86:54 | state.m ... alValue |
161+
| react-redux.jsx:39:42:39:55 | action.payload | react-redux.jsx:87:32:87:56 | state.m ... lValue2 |
162+
| react-redux.jsx:44:27:46:14 | [1, 2, ... }) | react-redux.jsx:88:32:88:56 | state.m ... lValue3 |

0 commit comments

Comments
 (0)