MCPcopy Create free account
hub / github.com/hashintel/hash / trailing_comma

Function trailing_comma

libs/@local/hashql/syntax-jexpr/src/parser/array/visit.rs:250–278  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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() {

Callers

nothing calls this directly

Calls 5

visit_arrayFunction · 0.85
OkInterface · 0.85
render_diagnosticFunction · 0.50
expectMethod · 0.45
advanceMethod · 0.45

Tested by

no test coverage detected