nimbus_fml/editing/
error_path.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

use serde_json::Value;

/// The `ErrorPath` struct is constructed in the default validator to be used
/// to derive where an error has been detected.
///
/// serde_yaml does not keep track of lines and columns so we need to be able to
/// indicate where an error takes place.
///
/// For reporting errors in the manifest on the command line, an error might have a path such as:
///
///  1. `features/messaging.messages['my-message'].MessageData#is-control` expects a boolean,
///  2. `features/homescreen.sections-enabled[HomeScreenSection#pocket]` expects a boolean
///  3. `objects/AwesomeBar.min-search-term`.
///
/// The path to an error is given by `&self.path`.
///
/// The defaults validation is exactly the same as the validation performed on the Feature Configuration
/// JSON in experimenter. Thus, `literals` is a `Vec<String>` of tokens found in JSON, which should in
/// almost all circumstances lead to the correct token being identified by line and column.
///
/// So the corresponding `literals` of a type mismatch error where an integer `1` is used instead
/// of a boolean would be:
///
///  1. `"messages"`, `{`, `"my-message"`, `"is-control"`, `1`
///  2. `"sections-enabled"`, `{`, `"pocket"`, `1`
///
/// `find_err(src: &str)` is used to find the line and column for the final `1` token.
/// Currently `find_err` exists in `inspector.rs`, but this should move (along with reduced visibility
/// of `literals`) in a future commit.
#[derive(Clone)]
pub(crate) struct ErrorPath {
    start_index: Option<usize>,
    literals: Vec<String>,
    pub(crate) path: String,
}

/// Chained Constructors
impl ErrorPath {
    fn new(path: String, literals: Vec<String>) -> Self {
        Self {
            path,
            literals,
            start_index: None,
        }
    }

    pub(crate) fn feature(name: &str) -> Self {
        Self::new(format!("features/{name}"), Default::default())
    }

    pub(crate) fn object(name: &str) -> Self {
        Self::new(format!("objects/{name}"), Default::default())
    }

    pub(crate) fn example(&self, name: &str) -> Self {
        Self::new(
            format!("{}#examples[\"{name}\"]", &self.path),
            self.literals.clone(),
        )
    }

    pub(crate) fn property(&self, prop_key: &str) -> Self {
        Self::new(
            format!("{}.{prop_key}", &self.path),
            append_quoted(&self.literals, prop_key),
        )
    }

    pub(crate) fn enum_map_key(&self, enum_: &str, key: &str) -> Self {
        Self::new(
            format!("{}[{enum_}#{key}]", &self.path),
            append(&self.literals, &["{".to_string(), format!("\"{key}\"")]),
        )
    }

    pub(crate) fn map_key(&self, key: &str) -> Self {
        Self::new(
            format!("{}['{key}']", &self.path),
            append(&self.literals, &["{".to_string(), format!("\"{key}\"")]),
        )
    }

    pub(crate) fn array_index(&self, index: usize) -> Self {
        let mut literals = append1(&self.literals, "[");
        if index > 0 {
            literals.extend_from_slice(&[",".repeat(index)]);
        }
        Self::new(format!("{}[{index}]", &self.path), literals)
    }

    pub(crate) fn object_value(&self, name: &str) -> Self {
        Self::new(
            format!("{}#{name}", &self.path),
            append1(&self.literals, "{"),
        )
    }

    pub(crate) fn open_brace(&self) -> Self {
        Self::new(self.path.clone(), append1(&self.literals, "{"))
    }

    pub(crate) fn final_error_quoted(&self, highlight: &str) -> Self {
        Self::new(self.path.clone(), append_quoted(&self.literals, highlight))
    }

    pub(crate) fn final_error_value(&self, value: &Value) -> Self {
        let len = self.literals.len();
        let mut literals = Vec::with_capacity(len * 2);
        literals.extend_from_slice(self.literals.as_slice());
        collect_path(&mut literals, value);

        Self {
            path: self.path.clone(),
            literals,
            start_index: Some(len),
        }
    }
}

fn collect_path(literals: &mut Vec<String>, value: &Value) {
    match value {
        Value::Bool(_) | Value::Number(_) | Value::Null => literals.push(value.to_string()),
        Value::String(s) => literals.push(format!("\"{s}\"")),

        Value::Array(array) => {
            literals.push(String::from("["));
            for v in array {
                collect_path(literals, v);
            }
            literals.push(String::from("]"));
        }

        Value::Object(map) => {
            literals.push(String::from("{"));
            if let Some((k, v)) = map.iter().last() {
                literals.push(format!("\"{k}\""));
                collect_path(literals, v);
            }
            literals.push(String::from("}"));
        }
    }
}

/// Accessors
impl ErrorPath {
    pub(crate) fn error_token_abbr(&self) -> String {
        match self.start_index {
            Some(index) if index < self.literals.len() - 1 => {
                let start = self
                    .literals
                    .get(index)
                    .map(String::as_str)
                    .unwrap_or_default();
                let end = self.last_error_token().unwrap();
                format!("{start}…{end}")
            }
            _ => self.last_error_token().unwrap().to_owned(),
        }
    }

    pub(crate) fn last_error_token(&self) -> Option<&str> {
        self.literals.last().map(String::as_str)
    }
}

#[cfg(feature = "client-lib")]
impl ErrorPath {
    pub(crate) fn first_error_token(&self) -> Option<&str> {
        if let Some(index) = self.start_index {
            self.literals.get(index).map(String::as_str)
        } else {
            self.last_error_token()
        }
    }

    /// Gives the span of characters within the given source code where this error
    /// was detected.
    ///
    /// Currently, this is limited to finding the last token and adding the length.
    pub(crate) fn error_span(&self, src: &str) -> crate::editing::CursorSpan {
        use crate::editing::CursorPosition;
        let mut lines = src.lines().peekable();
        let last_token = self.last_error_token().unwrap();
        if let Some(index) = self.start_index {
            let path_to_first = self.literals[..index + 1].iter().map(String::as_str);
            let rest = self.literals[index + 1..].iter().map(String::as_str);

            let pos = line_col_from_lines(&mut lines, (0, 0), path_to_first);
            let from: CursorPosition = pos.into();

            let to: CursorPosition = line_col_from_lines(&mut lines, pos, rest).into();

            from + (to + last_token)
        } else {
            let from: CursorPosition =
                line_col_from_lines(&mut lines, (0, 0), self.literals.iter().map(String::as_str))
                    .into();
            from + last_token
        }
    }
}

fn append(original: &[String], new: &[String]) -> Vec<String> {
    let mut clone = Vec::with_capacity(original.len() + new.len());
    clone.extend_from_slice(original);
    clone.extend_from_slice(new);
    clone
}

fn append1(original: &[String], new: &str) -> Vec<String> {
    let mut clone = Vec::with_capacity(original.len() + 1);
    clone.extend_from_slice(original);
    clone.push(new.to_string());
    clone
}

fn append_quoted(original: &[String], new: &str) -> Vec<String> {
    append1(original, &format!("\"{new}\""))
}

#[cfg(feature = "client-lib")]
fn line_col_from_lines<'a>(
    lines: &mut std::iter::Peekable<impl Iterator<Item = &'a str>>,
    start: (usize, usize),
    path: impl Iterator<Item = &'a str>,
) -> (usize, usize) {
    let (mut line_no, mut col_no) = start;

    // `first_match` is "are we looking for the first match of the line"
    let mut first_match = col_no == 0;

    for p in path {
        loop {
            if let Some(line) = lines.peek() {
                // If we haven't had our first match of the line, then start there at the beginning.
                // Otherwise, start one char on from where we were last time.
                //
                // We might optimize this by adding the grapheme length to col_no,
                // but we're in the "make it right" phase.
                let start = if first_match { 0 } else { col_no + 1 };

                if let Some(i) = find_index(line, p, start) {
                    col_no = i;
                    first_match = false;
                    break;
                } else if lines.next().is_some() {
                    // we try the next line!
                    line_no += 1;
                    first_match = true;
                    col_no = 0;
                }
            } else {
                // we've run out of lines, so we should return
                return (0, 0);
            }
        }
    }

    (line_no, col_no)
}

/// Find the index in `line` of the next instance of `pattern`, after `start`
///
#[cfg(feature = "client-lib")]
fn find_index(line: &str, pattern: &str, start: usize) -> Option<usize> {
    use unicode_segmentation::UnicodeSegmentation;
    let line: Vec<&str> = UnicodeSegmentation::graphemes(line, true).collect();
    let line_from_start = &line[start..];

    let pattern: Vec<&str> = UnicodeSegmentation::graphemes(pattern, true).collect();
    let pattern = pattern.as_slice();

    line_from_start
        .windows(pattern.len())
        .position(|window| window == pattern)
        .map(|i| i + start)
}

#[cfg(feature = "client-lib")]
#[cfg(test)]
mod construction_tests {
    use serde_json::json;

    use super::ErrorPath;

    #[test]
    fn test_property() {
        let path = ErrorPath::feature("my-feature").property("my-property");
        assert_eq!("features/my-feature.my-property", &path.path);
        assert_eq!(&["\"my-property\""], path.literals.as_slice());

        let path = ErrorPath::object("MyObject").property("my-property");
        assert_eq!("objects/MyObject.my-property", &path.path);
        assert_eq!(&["\"my-property\""], path.literals.as_slice());
    }

    #[test]
    fn test_map_key() {
        let path = ErrorPath::feature("my-feature")
            .property("my-map")
            .map_key("my-key");
        assert_eq!("features/my-feature.my-map['my-key']", &path.path);
        assert_eq!(&["\"my-map\"", "{", "\"my-key\""], path.literals.as_slice());
    }

    #[test]
    fn test_enum_map_key() {
        let path = ErrorPath::feature("my-feature")
            .property("my-map")
            .enum_map_key("MyEnum", "my-variant");
        assert_eq!("features/my-feature.my-map[MyEnum#my-variant]", &path.path);
        assert_eq!(
            &["\"my-map\"", "{", "\"my-variant\""],
            path.literals.as_slice()
        );
    }

    #[test]
    fn test_array_index() {
        let path = ErrorPath::feature("my-feature")
            .property("my-array")
            .array_index(1);
        assert_eq!("features/my-feature.my-array[1]", &path.path);
        assert_eq!(&["\"my-array\"", "[", ","], path.literals.as_slice());

        let path = ErrorPath::feature("my-feature")
            .property("my-array")
            .array_index(0);
        assert_eq!("features/my-feature.my-array[0]", &path.path);
        assert_eq!(&["\"my-array\"", "["], path.literals.as_slice());
    }

    #[test]
    fn test_object_value() {
        let path = ErrorPath::feature("my-feature")
            .property("my-object")
            .object_value("MyObject");
        assert_eq!("features/my-feature.my-object#MyObject", &path.path);
        assert_eq!(&["\"my-object\"", "{"], path.literals.as_slice());
    }

    #[test]
    fn test_final_error() {
        //  1. `features/messaging.messages['my-message']#MessageData.is-control` expects a boolean,
        let path = ErrorPath::feature("messaging")
            .property("messages")
            .map_key("my-message")
            .object_value("MessageData")
            .property("is-control")
            .final_error_value(&json!(1));
        assert_eq!(
            "features/messaging.messages['my-message']#MessageData.is-control",
            &path.path
        );
        assert_eq!(
            &[
                "\"messages\"",
                "{",
                "\"my-message\"",
                "{",
                "\"is-control\"",
                "1"
            ],
            path.literals.as_slice()
        );

        //  2. `features/homescreen.sections-enabled[HomeScreenSection#pocket]` expects a boolean
        let path = ErrorPath::feature("homescreen")
            .property("sections-enabled")
            .enum_map_key("HomeScreenSection", "pocket")
            .final_error_value(&json!(1));
        assert_eq!(
            "features/homescreen.sections-enabled[HomeScreenSection#pocket]",
            &path.path
        );

        assert_eq!(
            &["\"sections-enabled\"", "{", "\"pocket\"", "1"],
            path.literals.as_slice()
        );
    }

    #[test]
    fn test_final_error_value_scalars() {
        let path = ErrorPath::feature("my-feature").property("is-enabled");

        let observed = {
            let value = json!(true);
            path.final_error_value(&value)
        };
        assert_eq!(observed.literals.as_slice(), &["\"is-enabled\"", "true"]);

        let observed = {
            let value = json!(13);
            path.final_error_value(&value)
        };
        assert_eq!(observed.literals.as_slice(), &["\"is-enabled\"", "13"]);

        let observed = {
            let value = json!("string");
            path.final_error_value(&value)
        };
        assert_eq!(
            observed.literals.as_slice(),
            &["\"is-enabled\"", "\"string\""]
        );
    }

    #[test]
    fn test_final_error_value_arrays() {
        let path = ErrorPath::feature("my-feature").property("is-enabled");

        let observed = {
            let value = json!([]);
            let o = path.final_error_value(&value);
            assert_eq!(o.first_error_token(), Some("["));
            o
        };
        assert_eq!(observed.literals.as_slice(), &["\"is-enabled\"", "[", "]"]);

        let observed = {
            let value = json!([1, 2]);
            let o = path.final_error_value(&value);
            assert_eq!(o.first_error_token(), Some("["));
            o
        };
        assert_eq!(
            observed.literals.as_slice(),
            &["\"is-enabled\"", "[", "1", "2", "]"]
        );
    }

    #[test]
    fn test_final_error_value_objects() {
        let path = ErrorPath::feature("my-feature").property("is-enabled");

        let observed = {
            let value = json!({});
            let o = path.final_error_value(&value);
            assert_eq!(o.first_error_token(), Some("{"));
            o
        };
        assert_eq!(observed.literals.as_slice(), &["\"is-enabled\"", "{", "}"]);

        let observed = {
            let value = json!({"last": true});
            let o = path.final_error_value(&value);
            assert_eq!(o.first_error_token(), Some("{"));
            o
        };
        assert_eq!(
            observed.literals.as_slice(),
            &["\"is-enabled\"", "{", "\"last\"", "true", "}"]
        );

        let observed = {
            let value = json!({"first": true, "last": true});
            let o = path.final_error_value(&value);
            assert_eq!(o.first_error_token(), Some("{"));
            o
        };
        assert_eq!(
            observed.literals.as_slice(),
            &["\"is-enabled\"", "{", "\"last\"", "true", "}"]
        );
    }
}

#[cfg(feature = "client-lib")]
#[cfg(test)]
mod line_col_tests {

    use super::*;
    use crate::error::Result;

    fn line_col<'a>(src: &'a str, path: impl Iterator<Item = &'a str>) -> (usize, usize) {
        let mut lines = src.lines().peekable();
        line_col_from_lines(&mut lines, (0, 0), path)
    }

    #[test]
    fn test_find_err() -> Result<()> {
        fn do_test(s: &str, path: &[&str], expected: (usize, usize)) {
            let p = path.last().unwrap();
            let path = path.iter().cloned();
            let from = line_col(s, path);
            assert_eq!(from, expected, "Can't find \"{p}\" at {expected:?} in {s}");
        }

        fn do_multi(s: &[&str], path: &[&str], expected: (usize, usize)) {
            let s = s.join("\n");
            do_test(&s, path, expected);
        }

        do_test("ab cd", &["cd"], (0, 3));
        do_test("ab cd", &["ab", "cd"], (0, 3));
        do_test("áط ¢đ εƒ gի", &["áط", "¢đ"], (0, 3));

        do_test("ab ab", &["ab"], (0, 0));
        do_test("ab ab", &["ab", "ab"], (0, 3));

        do_multi(
            &["ab xx cd", "xx ef xx gh", "ij xx"],
            &["ab", "cd", "gh", "xx"],
            (2, 3),
        );

        do_multi(
            &[
                "{",                       // 0
                "  boolean: true,",        // 1
                "  object: {",             // 2
                "    integer: \"string\"", // 3
                "  }",                     // 4
                "}",                       // 5
            ],
            &["object", "integer", "\"string\""],
            (3, 13),
        );

        // pathological case
        do_multi(
            &[
                "{",                       // 0
                "  boolean: true,",        // 1
                "  object: {",             // 2
                "    integer: 1,",         // 3
                "    astring: \"string\"", // 4
                "  },",                    // 5
                "  integer: \"string\"",   // 6
                "}",                       // 7
            ],
            &["integer", "\"string\""],
            (4, 13),
        );

        // With unicode tokens (including R2L)
        do_multi(&["áط ab", "¢đ cd", "εƒ ef", "gh gի"], &["áط", "cd"], (1, 3));

        // Pseudolocalized pangrams, as a small fuzz test
        do_multi(
            &[
                "Wàłţż, Waltz,",
                "bâđ bad",
                "ņÿmƥĥ, nymph,",
                "ƒőŕ for",
                "qüíĉķ quick",
                "ĵíğş jigs",
                "vęx vex",
            ],
            &["bad", "nymph"],
            (2, 7),
        );

        Ok(())
    }

    #[test]
    fn test_find_index_from() -> Result<()> {
        assert_eq!(find_index("012345601", "01", 0), Some(0));
        assert_eq!(find_index("012345601", "01", 1), Some(7));
        assert_eq!(find_index("012345602", "01", 1), None);
        assert_eq!(find_index("åéîø token", "token", 0), Some(5));
        Ok(())
    }
}

#[cfg(feature = "client-lib")]
#[cfg(test)]
mod integration_tests {

    use serde_json::json;

    use super::*;

    fn test_error_span(src: &[&str], path: &ErrorPath, from: (usize, usize), to: (usize, usize)) {
        test_error_span_string(src.join("\n"), path, from, to);
    }

    fn test_error_span_oneline(
        src: &[&str],
        path: &ErrorPath,
        from: (usize, usize),
        to: (usize, usize),
    ) {
        test_error_span_string(src.join(""), path, from, to);
    }

    fn test_error_span_string(
        src: String,
        path: &ErrorPath,
        from: (usize, usize),
        to: (usize, usize),
    ) {
        let observed = path.error_span(src.as_str());

        assert_eq!(
            observed.from,
            from.into(),
            "Incorrectly found first error token \"{p}\" starts at {from:?} in {src}",
            from = observed.from,
            p = path.first_error_token().unwrap()
        );
        assert_eq!(
            observed.to,
            to.into(),
            "Incorrectly found last error token \"{p}\" ends at {to:?} in {src}",
            p = path.last_error_token().unwrap(),
            to = observed.to,
        );
    }

    #[test]
    fn test_last_token() {
        let path = ErrorPath::feature("test-feature")
            .property("integer")
            .final_error_quoted("string");
        let src = &[
            // 01234567890123456789012345
            r#"{"#,                     // 0
            r#"  "boolean": true,"#,    // 1
            r#"  "integer": "string""#, // 2
            r#"}"#,                     // 3
        ];

        test_error_span(src, &path, (2, 13), (2, 21));
        test_error_span_oneline(src, &path, (0, 32), (0, 32 + "string".len() + 2))
    }

    #[test]
    fn test_type_mismatch_scalar() {
        let path = ErrorPath::feature("test-feature")
            .property("boolean")
            .final_error_value(&json!(13));

        let src = &[
            // 01234567890123456789012345
            r#"{"#,                // 0
            r#"  "boolean": 13,"#, // 1
            r#"  "integer": 1"#,   // 2
            r#"}"#,                // 3
        ];
        test_error_span(src, &path, (1, 13), (1, 13 + 2));
    }

    #[test]
    fn test_type_mismatch_error_on_one_line() {
        let path = ErrorPath::feature("test-feature")
            .property("integer")
            .final_error_value(&json!({
                "string": "string"
            }));

        let src = &[
            // 01234567890123456789012345
            r#"{"#,                                    // 0
            r#"  "integer": { "string": "string" },"#, // 1
            r#"  "short": 1,"#,                        // 2
            r#"  "boolean": true,"#,                   // 3
            r#"}"#,                                    // 4
        ];
        test_error_span(
            src,
            &path,
            (1, 13),
            (1, 13 + r#"{ "string": "string" }"#.len()),
        );

        test_error_span_oneline(
            src,
            &path,
            (0, 14),
            (0, 14 + r#"{ "string": "string" }"#.len()),
        );
    }

    #[test]
    fn test_type_mismatch_error_on_multiple_lines() {
        let path = ErrorPath::feature("test-feature").final_error_value(&json!({}));
        let src = &[
            // 012345678
            r#"{ "#, // 0
            r#"  "#, // 1
            r#"  "#, // 2
            r#"  "#, // 3
            r#"} "#, // 4
        ];
        test_error_span(src, &path, (0, 0), (4, 1));
    }

    #[test]
    fn test_error_abbr() {
        let path = ErrorPath::feature("test_feature").final_error_value(&json!(true));
        assert_eq!(path.error_token_abbr().as_str(), "true");

        let path = ErrorPath::feature("test_feature").final_error_value(&json!(42));
        assert_eq!(path.error_token_abbr().as_str(), "42");

        let path = ErrorPath::feature("test_feature").final_error_value(&json!("string"));
        assert_eq!(path.error_token_abbr().as_str(), "\"string\"");

        let path = ErrorPath::feature("test_feature").final_error_value(&json!([]));
        assert_eq!(path.error_token_abbr().as_str(), "[…]");

        let path = ErrorPath::feature("test_feature").final_error_value(&json!({}));
        assert_eq!(path.error_token_abbr().as_str(), "{…}");

        let path = ErrorPath::feature("test_feature").final_error_quoted("foo");
        assert_eq!(path.error_token_abbr().as_str(), "\"foo\"");
    }
}