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

Function empty_array

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

Source from the content-addressed store, hash-verified

140
141 #[test]
142 fn empty_array() {
143 bind_context!(let context = "[]");
144 bind_state!(let mut state from context);
145
146 // Get the first token which should be the opening bracket
147 let token = state
148 .advance(SyntaxKind::LBracket)
149 .expect("should have at least one token");
150
151 let mut items_count = 0;
152 let result: Result<_, ArrayDiagnostic> = visit_array(&mut state, token, |_| {
153 // This callback should not be called for an empty array
154 items_count += 1;
155 Ok(())
156 });
157
158 let range = result.expect("should be able to parse empty array");
159 assert_eq!(range.start(), TextSize::new(0));
160 assert_eq!(range.end(), TextSize::new(2));
161
162 assert_eq!(items_count, 0);
163 }
164
165 #[test]
166 fn single_item_array() {

Callers

nothing calls this directly

Calls 4

visit_arrayFunction · 0.85
OkInterface · 0.85
expectMethod · 0.45
advanceMethod · 0.45

Tested by

no test coverage detected