Debian Codegraph @

tests/256_comma_error.rs

raw symbols SCIP
1 #![allow(dead_code)]
2
3 use ronrust-analyzer cargo ron 0.12.0 crate/::errorrust-analyzer cargo ron 0.12.0 error/::{Errorrust-analyzer cargo ron 0.12.0 error/Error#, Positionrust-analyzer cargo ron 0.12.0 error/Position#, Spanrust-analyzer cargo ron 0.12.0 error/Span#, SpannedErrorrust-analyzer cargo ron 0.12.0 error/SpannedError#};
4
5 #[cfg(feature = "internal-span-substring-test")]
6 use ronrust-analyzer cargo ron 0.12.0 crate/::utilrust-analyzer cargo ron 0.12.0 util/::span_substringrust-analyzer cargo ron 0.12.0 util/span_substring/::check_error_span_inclusiverust-analyzer cargo ron 0.12.0 util/span_substring/check_error_span_inclusive().;
7
8 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, serderust-analyzer cargo serde 1.0.228 crate/::Deserializerust-analyzer cargo serde_derive 1.0.228 Deserialize:)]
9 struct Testrust-analyzer cargo ron 0.12.0 Test# {
10 arust-analyzer cargo ron 0.12.0 Test#a.: i32,
11 brust-analyzer cargo ron 0.12.0 Test#b.: i32,
12 }
13
14 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
15 fn test_missing_comma_errorrust-analyzer cargo ron 0.12.0 test_missing_comma_error().() {
16 let tuple_string = r#"(
17 1 // <-- forgotten comma here
18 2
19 )"#;
20
21 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
22 ronrust-analyzer cargo ron 0.12.0 crate/::from_strrust-analyzer cargo ron 0.12.0 de/from_str().::<(i32, i32)>(tuple_string).unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().(),
23 SpannedErrorrust-analyzer cargo ron 0.12.0 error/SpannedError# {
24 coderust-analyzer cargo ron 0.12.0 error/SpannedError#code.: Errorrust-analyzer cargo ron 0.12.0 error/Error#::ExpectedCommarust-analyzer cargo ron 0.12.0 error/Error#ExpectedComma#,
25 spanrust-analyzer cargo ron 0.12.0 error/SpannedError#span.: Spanrust-analyzer cargo ron 0.12.0 error/Span# {
26 startrust-analyzer cargo ron 0.12.0 error/Span#start.: Positionrust-analyzer cargo ron 0.12.0 error/Position# { linerust-analyzer cargo ron 0.12.0 error/Position#line.: 3, colrust-analyzer cargo ron 0.12.0 error/Position#col.: 9 },
27 endrust-analyzer cargo ron 0.12.0 error/Span#end.: Positionrust-analyzer cargo ron 0.12.0 error/Position# { linerust-analyzer cargo ron 0.12.0 error/Position#line.: 3, colrust-analyzer cargo ron 0.12.0 error/Position#col.: 9 }
28 }
29 }
30 );
31
32 let list_string = r#"[
33 0,
34 1 // <-- forgotten comma here
35 2
36 ]"#;
37
38 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
39 ronrust-analyzer cargo ron 0.12.0 crate/::from_strrust-analyzer cargo ron 0.12.0 de/from_str().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<i32>>(list_string).unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().(),
40 SpannedErrorrust-analyzer cargo ron 0.12.0 error/SpannedError# {
41 coderust-analyzer cargo ron 0.12.0 error/SpannedError#code.: Errorrust-analyzer cargo ron 0.12.0 error/Error#::ExpectedCommarust-analyzer cargo ron 0.12.0 error/Error#ExpectedComma#,
42 spanrust-analyzer cargo ron 0.12.0 error/SpannedError#span.: Spanrust-analyzer cargo ron 0.12.0 error/Span# {
43 startrust-analyzer cargo ron 0.12.0 error/Span#start.: Positionrust-analyzer cargo ron 0.12.0 error/Position# { linerust-analyzer cargo ron 0.12.0 error/Position#line.: 4, colrust-analyzer cargo ron 0.12.0 error/Position#col.: 9 },
44 endrust-analyzer cargo ron 0.12.0 error/Span#end.: Positionrust-analyzer cargo ron 0.12.0 error/Position# { linerust-analyzer cargo ron 0.12.0 error/Position#line.: 4, colrust-analyzer cargo ron 0.12.0 error/Position#col.: 9 }
45 }
46 }
47 );
48
49 let struct_string = r#"Test(
50 a: 1 // <-- forgotten comma here
51 b: 2
52 )"#;
53
54 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
55 ronrust-analyzer cargo ron 0.12.0 crate/::from_strrust-analyzer cargo ron 0.12.0 de/from_str().::<Testrust-analyzer cargo ron 0.12.0 Test#>(struct_string).unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().(),
56 SpannedErrorrust-analyzer cargo ron 0.12.0 error/SpannedError# {
57 coderust-analyzer cargo ron 0.12.0 error/SpannedError#code.: Errorrust-analyzer cargo ron 0.12.0 error/Error#::ExpectedCommarust-analyzer cargo ron 0.12.0 error/Error#ExpectedComma#,
58 spanrust-analyzer cargo ron 0.12.0 error/SpannedError#span.: Spanrust-analyzer cargo ron 0.12.0 error/Span# {
59 startrust-analyzer cargo ron 0.12.0 error/Span#start.: Positionrust-analyzer cargo ron 0.12.0 error/Position# { linerust-analyzer cargo ron 0.12.0 error/Position#line.: 3, colrust-analyzer cargo ron 0.12.0 error/Position#col.: 9 },
60 endrust-analyzer cargo ron 0.12.0 error/Span#end.: Positionrust-analyzer cargo ron 0.12.0 error/Position# { linerust-analyzer cargo ron 0.12.0 error/Position#line.: 3, colrust-analyzer cargo ron 0.12.0 error/Position#col.: 9 }
61 }
62 }
63 );
64
65 let map_string = r#"{
66 "a": 1 // <-- forgotten comma here
67 "b": 2
68 }"#;
69
70 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
71 ronrust-analyzer cargo ron 0.12.0 crate/::from_strrust-analyzer cargo ron 0.12.0 de/from_str().::<stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::collectionsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/::HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, i32>>(map_string).unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().(),
72 SpannedErrorrust-analyzer cargo ron 0.12.0 error/SpannedError# {
73 coderust-analyzer cargo ron 0.12.0 error/SpannedError#code.: Errorrust-analyzer cargo ron 0.12.0 error/Error#::ExpectedCommarust-analyzer cargo ron 0.12.0 error/Error#ExpectedComma#,
74 spanrust-analyzer cargo ron 0.12.0 error/SpannedError#span.: Spanrust-analyzer cargo ron 0.12.0 error/Span# {
75 startrust-analyzer cargo ron 0.12.0 error/Span#start.: Positionrust-analyzer cargo ron 0.12.0 error/Position# { linerust-analyzer cargo ron 0.12.0 error/Position#line.: 3, colrust-analyzer cargo ron 0.12.0 error/Position#col.: 9 },
76 endrust-analyzer cargo ron 0.12.0 error/Span#end.: Positionrust-analyzer cargo ron 0.12.0 error/Position# { linerust-analyzer cargo ron 0.12.0 error/Position#line.: 3, colrust-analyzer cargo ron 0.12.0 error/Position#col.: 9 }
77 }
78 }
79 );
80
81 let extensions_string = r#"#![enable(
82 implicit_some // <-- forgotten comma here
83 unwrap_newtypes
84 ]) 42"#;
85
86 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
87 ronrust-analyzer cargo ron 0.12.0 crate/::from_strrust-analyzer cargo ron 0.12.0 de/from_str().::<u8>(extensions_string).unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().(),
88 SpannedErrorrust-analyzer cargo ron 0.12.0 error/SpannedError# {
89 coderust-analyzer cargo ron 0.12.0 error/SpannedError#code.: Errorrust-analyzer cargo ron 0.12.0 error/Error#::ExpectedCommarust-analyzer cargo ron 0.12.0 error/Error#ExpectedComma#,
90 spanrust-analyzer cargo ron 0.12.0 error/SpannedError#span.: Spanrust-analyzer cargo ron 0.12.0 error/Span# {
91 startrust-analyzer cargo ron 0.12.0 error/Span#start.: Positionrust-analyzer cargo ron 0.12.0 error/Position# { linerust-analyzer cargo ron 0.12.0 error/Position#line.: 2, colrust-analyzer cargo ron 0.12.0 error/Position#col.: 50 },
92 endrust-analyzer cargo ron 0.12.0 error/Span#end.: Positionrust-analyzer cargo ron 0.12.0 error/Position# { linerust-analyzer cargo ron 0.12.0 error/Position#line.: 3, colrust-analyzer cargo ron 0.12.0 error/Position#col.: 9 }
93 }
94 }
95 );
96
97 #[cfg(feature = "internal-span-substring-test")]
98 check_error_span_inclusiverust-analyzer cargo ron 0.12.0 util/span_substring/check_error_span_inclusive().::<u8>(
99 extensions_string,
100 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(SpannedErrorrust-analyzer cargo ron 0.12.0 error/SpannedError# {
101 coderust-analyzer cargo ron 0.12.0 error/SpannedError#code.: Errorrust-analyzer cargo ron 0.12.0 error/Error#::ExpectedCommarust-analyzer cargo ron 0.12.0 error/Error#ExpectedComma#,
102 spanrust-analyzer cargo ron 0.12.0 error/SpannedError#span.: Spanrust-analyzer cargo ron 0.12.0 error/Span# {
103 startrust-analyzer cargo ron 0.12.0 error/Span#start.: Positionrust-analyzer cargo ron 0.12.0 error/Position# { linerust-analyzer cargo ron 0.12.0 error/Position#line.: 2, colrust-analyzer cargo ron 0.12.0 error/Position#col.: 50 },
104 endrust-analyzer cargo ron 0.12.0 error/Span#end.: Positionrust-analyzer cargo ron 0.12.0 error/Position# { linerust-analyzer cargo ron 0.12.0 error/Position#line.: 3, colrust-analyzer cargo ron 0.12.0 error/Position#col.: 9 },
105 },
106 }),
107 "\n u",
108 );
109 }
110
111 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
112 fn test_comma_endrust-analyzer cargo ron 0.12.0 test_comma_end().() {
113 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(ronrust-analyzer cargo ron 0.12.0 crate/::from_strrust-analyzer cargo ron 0.12.0 de/from_str().::<(i32, i32)>("(0, 1)").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), (0, 1));
114 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(ronrust-analyzer cargo ron 0.12.0 crate/::from_strrust-analyzer cargo ron 0.12.0 de/from_str().::<(i32, i32)>("(0, 1,)").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), (0, 1));
115 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(ronrust-analyzer cargo ron 0.12.0 crate/::from_strrust-analyzer cargo ron 0.12.0 de/from_str().::<()>("()"), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()));
116 }