()
| 248 | |
| 249 | #[test] |
| 250 | fn trailing_comma() { |
| 251 | bind_context!(let context = "[1, 2,]"); |
| 252 | bind_state!(let mut state from context); |
| 253 | |
| 254 | let token = state |
| 255 | .advance(SyntaxKind::LBracket) |
| 256 | .expect("should have at least one token"); |
| 257 | |
| 258 | let mut callback_count = 0; |
| 259 | let result: Result<_, ArrayDiagnostic> = visit_array(&mut state, token, |state| { |
| 260 | state |
| 261 | .advance(SyntaxKindSet::COMPLETE) |
| 262 | .expect("should have at least one token"); |
| 263 | |
| 264 | callback_count += 1; |
| 265 | Ok(()) |
| 266 | }); |
| 267 | |
| 268 | let diagnostic = result.expect_err("should not be able to parse array with trailing comma"); |
| 269 | let report = render_diagnostic(context.input, &diagnostic, &context.spans); |
| 270 | |
| 271 | with_settings!({ |
| 272 | description => "Array with trailing comma should fail" |
| 273 | }, { |
| 274 | assert_snapshot!(insta::_macro_support::AutoName, report, &context.input); |
| 275 | }); |
| 276 | |
| 277 | assert_eq!(callback_count, 2); |
| 278 | } |
| 279 | |
| 280 | #[test] |
| 281 | fn missing_comma() { |
nothing calls this directly
no test coverage detected