Debian Codegraph @

src/lexer_tests.rs

raw symbols SCIP
1 use superrust-analyzer cargo pp-rs 0.2.1 crate/::lexerrust-analyzer cargo pp-rs 0.2.1 lexer/::{
2 CharsAndLinerust-analyzer cargo pp-rs 0.2.1 lexer/CharsAndLine#, Lexerrust-analyzer cargo pp-rs 0.2.1 lexer/Lexer#, LexerItemrust-analyzer cargo pp-rs 0.2.1 lexer/LexerItem#, ReplaceCommentsrust-analyzer cargo pp-rs 0.2.1 lexer/ReplaceComments#, SkipBackslashNewlinerust-analyzer cargo pp-rs 0.2.1 lexer/SkipBackslashNewline#, Tokenrust-analyzer cargo pp-rs 0.2.1 lexer/Token#, TokenValuerust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#,
3 COMMENT_SENTINEL_VALUErust-analyzer cargo pp-rs 0.2.1 lexer/COMMENT_SENTINEL_VALUE.,
4 };
5 use superrust-analyzer cargo pp-rs 0.2.1 crate/::tokenrust-analyzer cargo pp-rs 0.2.1 token/::{Floatrust-analyzer cargo pp-rs 0.2.1 token/Float#, Integerrust-analyzer cargo pp-rs 0.2.1 token/Integer#, Locationrust-analyzer cargo pp-rs 0.2.1 token/Location#, PreprocessorErrorrust-analyzer cargo pp-rs 0.2.1 token/PreprocessorError#, Punctrust-analyzer cargo pp-rs 0.2.1 token/Punct#};
6 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::opsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/::Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#;
7
8 fn crust-analyzer cargo pp-rs 0.2.1 lexer_tests/c().(c: char, line: u32) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<(char, u32)> {
9 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((c, line))
10 }
11
12 fn lrust-analyzer cargo pp-rs 0.2.1 lexer_tests/l().(line: u32, pos: Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<u32>) -> Locationrust-analyzer cargo pp-rs 0.2.1 token/Location# {
13 Locationrust-analyzer cargo pp-rs 0.2.1 token/Location# {
14 linerust-analyzer cargo pp-rs 0.2.1 token/Location#line.,
15 startrust-analyzer cargo pp-rs 0.2.1 token/Location#start.: pos.startrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#start.,
16 endrust-analyzer cargo pp-rs 0.2.1 token/Location#end.: pos.endrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#end.,
17 }
18 }
19
20 fn unwrap_tokenrust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token().(item: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<LexerItemrust-analyzer cargo pp-rs 0.2.1 lexer/LexerItem#>) -> Tokenrust-analyzer cargo pp-rs 0.2.1 lexer/Token# {
21 item.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()
22 }
23
24 fn unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(item: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<LexerItemrust-analyzer cargo pp-rs 0.2.1 lexer/LexerItem#>) -> TokenValuerust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue# {
25 unwrap_tokenrust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token().(item).valuerust-analyzer cargo pp-rs 0.2.1 lexer/Token#value.
26 }
27
28 fn unwrap_errorrust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_error().(item: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<LexerItemrust-analyzer cargo pp-rs 0.2.1 lexer/LexerItem#>) -> PreprocessorErrorrust-analyzer cargo pp-rs 0.2.1 token/PreprocessorError# {
29 item.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().().0
30 }
31
32 fn expect_lexer_endrust-analyzer cargo pp-rs 0.2.1 lexer_tests/expect_lexer_end().(lexer: &mut Lexerrust-analyzer cargo pp-rs 0.2.1 lexer/Lexer#) {
33 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(lexer.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), TokenValuerust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#::NewLinerust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#NewLine#);
34 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(lexer.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
35 }
36
37 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<i32> for TokenValuerust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue# {
38 fn fromrust-analyzer cargo pp-rs 0.2.1 lexer_tests/impl#[TokenValue][`From<i32>`]from().(value: i32) -> Selfrust-analyzer cargo pp-rs 0.2.1 lexer_tests/impl#[TokenValue][`From<i32>`] {
39 TokenValuerust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#::Integerrust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#Integer#(Integerrust-analyzer cargo pp-rs 0.2.1 token/Integer# {
40 valuerust-analyzer cargo pp-rs 0.2.1 token/Integer#value.: value as u64,
41 signedrust-analyzer cargo pp-rs 0.2.1 token/Integer#signed.: true,
42 widthrust-analyzer cargo pp-rs 0.2.1 token/Integer#width.: 32,
43 })
44 }
45 }
46
47 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<u32> for TokenValuerust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue# {
48 fn fromrust-analyzer cargo pp-rs 0.2.1 lexer_tests/impl#[TokenValue][`From<u32>`]from().(value: u32) -> Selfrust-analyzer cargo pp-rs 0.2.1 lexer_tests/impl#[TokenValue][`From<u32>`] {
49 TokenValuerust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#::Integerrust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#Integer#(Integerrust-analyzer cargo pp-rs 0.2.1 token/Integer# {
50 valuerust-analyzer cargo pp-rs 0.2.1 token/Integer#value.: value as u64,
51 signedrust-analyzer cargo pp-rs 0.2.1 token/Integer#signed.: false,
52 widthrust-analyzer cargo pp-rs 0.2.1 token/Integer#width.: 32,
53 })
54 }
55 }
56
57 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<f32> for TokenValuerust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue# {
58 fn fromrust-analyzer cargo pp-rs 0.2.1 lexer_tests/impl#[TokenValue][`From<f32>`]from().(value: f32) -> Selfrust-analyzer cargo pp-rs 0.2.1 lexer_tests/impl#[TokenValue][`From<f32>`] {
59 TokenValuerust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#::Floatrust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#Float#(Floatrust-analyzer cargo pp-rs 0.2.1 token/Float# { valuerust-analyzer cargo pp-rs 0.2.1 token/Float#value., widthrust-analyzer cargo pp-rs 0.2.1 token/Float#width.: 32 })
60 }
61 }
62
63 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
64 fn chars_and_locationrust-analyzer cargo pp-rs 0.2.1 lexer_tests/chars_and_location().() {
65 // Test handling of characters in a line.
66 let mut it = CharsAndLinerust-analyzer cargo pp-rs 0.2.1 lexer/CharsAndLine#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`CharsAndLine<'a>`]new().("abc");
67 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`CharsAndLine<'a>`][Iterator]next().(), crust-analyzer cargo pp-rs 0.2.1 lexer_tests/c().('a', 1));
68 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`CharsAndLine<'a>`][Iterator]next().(), crust-analyzer cargo pp-rs 0.2.1 lexer_tests/c().('b', 1));
69 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`CharsAndLine<'a>`][Iterator]next().(), crust-analyzer cargo pp-rs 0.2.1 lexer_tests/c().('c', 1));
70 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`CharsAndLine<'a>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
71
72 // Test handling of \n in the regular case.
73 let mut it = CharsAndLinerust-analyzer cargo pp-rs 0.2.1 lexer/CharsAndLine#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`CharsAndLine<'a>`]new().("a\nb");
74 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`CharsAndLine<'a>`][Iterator]next().(), crust-analyzer cargo pp-rs 0.2.1 lexer_tests/c().('a', 1));
75 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`CharsAndLine<'a>`][Iterator]next().(), crust-analyzer cargo pp-rs 0.2.1 lexer_tests/c().('\n', 1));
76 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`CharsAndLine<'a>`][Iterator]next().(), crust-analyzer cargo pp-rs 0.2.1 lexer_tests/c().('b', 2));
77 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`CharsAndLine<'a>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
78
79 // Test handling of \r in the regular case.
80 let mut it = CharsAndLinerust-analyzer cargo pp-rs 0.2.1 lexer/CharsAndLine#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`CharsAndLine<'a>`]new().("a\rb");
81 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`CharsAndLine<'a>`][Iterator]next().(), crust-analyzer cargo pp-rs 0.2.1 lexer_tests/c().('a', 1));
82 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`CharsAndLine<'a>`][Iterator]next().(), crust-analyzer cargo pp-rs 0.2.1 lexer_tests/c().('\n', 1));
83 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`CharsAndLine<'a>`][Iterator]next().(), crust-analyzer cargo pp-rs 0.2.1 lexer_tests/c().('b', 2));
84 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`CharsAndLine<'a>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
85
86 // Test handling of \n\r.
87 let mut it = CharsAndLinerust-analyzer cargo pp-rs 0.2.1 lexer/CharsAndLine#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`CharsAndLine<'a>`]new().("a\n\rb");
88 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`CharsAndLine<'a>`][Iterator]next().(), crust-analyzer cargo pp-rs 0.2.1 lexer_tests/c().('a', 1));
89 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`CharsAndLine<'a>`][Iterator]next().(), crust-analyzer cargo pp-rs 0.2.1 lexer_tests/c().('\n', 1));
90 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`CharsAndLine<'a>`][Iterator]next().(), crust-analyzer cargo pp-rs 0.2.1 lexer_tests/c().('b', 2));
91 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`CharsAndLine<'a>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
92
93 // Test handling of \r\n.
94 let mut it = CharsAndLinerust-analyzer cargo pp-rs 0.2.1 lexer/CharsAndLine#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`CharsAndLine<'a>`]new().("a\r\nb");
95 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`CharsAndLine<'a>`][Iterator]next().(), crust-analyzer cargo pp-rs 0.2.1 lexer_tests/c().('a', 1));
96 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`CharsAndLine<'a>`][Iterator]next().(), crust-analyzer cargo pp-rs 0.2.1 lexer_tests/c().('\n', 1));
97 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`CharsAndLine<'a>`][Iterator]next().(), crust-analyzer cargo pp-rs 0.2.1 lexer_tests/c().('b', 2));
98 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`CharsAndLine<'a>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
99
100 // Test handling of a mix of \r and \n
101 let mut it = CharsAndLinerust-analyzer cargo pp-rs 0.2.1 lexer/CharsAndLine#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`CharsAndLine<'a>`]new().("\n\r\n\r\r\r\n");
102 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`CharsAndLine<'a>`][Iterator]next().(), crust-analyzer cargo pp-rs 0.2.1 lexer_tests/c().('\n', 1));
103 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`CharsAndLine<'a>`][Iterator]next().(), crust-analyzer cargo pp-rs 0.2.1 lexer_tests/c().('\n', 2));
104 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`CharsAndLine<'a>`][Iterator]next().(), crust-analyzer cargo pp-rs 0.2.1 lexer_tests/c().('\n', 3));
105 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`CharsAndLine<'a>`][Iterator]next().(), crust-analyzer cargo pp-rs 0.2.1 lexer_tests/c().('\n', 4));
106 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`CharsAndLine<'a>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
107
108 // Unicode handling
109 let mut it = CharsAndLinerust-analyzer cargo pp-rs 0.2.1 lexer/CharsAndLine#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`CharsAndLine<'a>`]new().("a→üs🦀");
110 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`CharsAndLine<'a>`][Iterator]next().(), crust-analyzer cargo pp-rs 0.2.1 lexer_tests/c().('a', 1));
111 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`CharsAndLine<'a>`][Iterator]next().(), crust-analyzer cargo pp-rs 0.2.1 lexer_tests/c().('→', 1));
112 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`CharsAndLine<'a>`][Iterator]next().(), crust-analyzer cargo pp-rs 0.2.1 lexer_tests/c().('ü', 1));
113 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`CharsAndLine<'a>`][Iterator]next().(), crust-analyzer cargo pp-rs 0.2.1 lexer_tests/c().('s', 1));
114 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`CharsAndLine<'a>`][Iterator]next().(), crust-analyzer cargo pp-rs 0.2.1 lexer_tests/c().('🦀', 1));
115 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`CharsAndLine<'a>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
116 }
117
118 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
119 fn skip_backslash_newlinerust-analyzer cargo pp-rs 0.2.1 lexer_tests/skip_backslash_newline().() {
120 // Test a simple case.
121 let mut it = SkipBackslashNewlinerust-analyzer cargo pp-rs 0.2.1 lexer/SkipBackslashNewline#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`SkipBackslashNewline<'a>`]new().("a\\\nb");
122 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`SkipBackslashNewline<'a>`][Iterator]next().(), crust-analyzer cargo pp-rs 0.2.1 lexer_tests/c().('a', 1));
123 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`SkipBackslashNewline<'a>`][Iterator]next().(), crust-analyzer cargo pp-rs 0.2.1 lexer_tests/c().('b', 2));
124 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`SkipBackslashNewline<'a>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
125
126 // Test a double case that requires the loop in the algorithm.
127 let mut it = SkipBackslashNewlinerust-analyzer cargo pp-rs 0.2.1 lexer/SkipBackslashNewline#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`SkipBackslashNewline<'a>`]new().("a\\\n\\\nb");
128 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`SkipBackslashNewline<'a>`][Iterator]next().(), crust-analyzer cargo pp-rs 0.2.1 lexer_tests/c().('a', 1));
129 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`SkipBackslashNewline<'a>`][Iterator]next().(), crust-analyzer cargo pp-rs 0.2.1 lexer_tests/c().('b', 3));
130 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`SkipBackslashNewline<'a>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
131
132 // Test a backslash on its own
133 let mut it = SkipBackslashNewlinerust-analyzer cargo pp-rs 0.2.1 lexer/SkipBackslashNewline#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`SkipBackslashNewline<'a>`]new().("a\\b");
134 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`SkipBackslashNewline<'a>`][Iterator]next().(), crust-analyzer cargo pp-rs 0.2.1 lexer_tests/c().('a', 1));
135 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`SkipBackslashNewline<'a>`][Iterator]next().(), crust-analyzer cargo pp-rs 0.2.1 lexer_tests/c().('\\', 1));
136 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`SkipBackslashNewline<'a>`][Iterator]next().(), crust-analyzer cargo pp-rs 0.2.1 lexer_tests/c().('b', 1));
137 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`SkipBackslashNewline<'a>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
138
139 // Test a case just before EOF
140 let mut it = SkipBackslashNewlinerust-analyzer cargo pp-rs 0.2.1 lexer/SkipBackslashNewline#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`SkipBackslashNewline<'a>`]new().("\\\n");
141 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`SkipBackslashNewline<'a>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
142 }
143
144 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
145 fn replace_commentsrust-analyzer cargo pp-rs 0.2.1 lexer_tests/replace_comments().() {
146 // Test a slash that's not a comment
147 let mut it = ReplaceCommentsrust-analyzer cargo pp-rs 0.2.1 lexer/ReplaceComments#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`ReplaceComments<'a>`]new().("a/b");
148 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`ReplaceComments<'a>`][Iterator]next().(), crust-analyzer cargo pp-rs 0.2.1 lexer_tests/c().('a', 1));
149 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`ReplaceComments<'a>`][Iterator]next().(), crust-analyzer cargo pp-rs 0.2.1 lexer_tests/c().('/', 1));
150 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`ReplaceComments<'a>`][Iterator]next().(), crust-analyzer cargo pp-rs 0.2.1 lexer_tests/c().('b', 1));
151 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`ReplaceComments<'a>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
152
153 // Test a slash with nothing afterwards
154 let mut it = ReplaceCommentsrust-analyzer cargo pp-rs 0.2.1 lexer/ReplaceComments#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`ReplaceComments<'a>`]new().("a/");
155 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`ReplaceComments<'a>`][Iterator]next().(), crust-analyzer cargo pp-rs 0.2.1 lexer_tests/c().('a', 1));
156 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`ReplaceComments<'a>`][Iterator]next().(), crust-analyzer cargo pp-rs 0.2.1 lexer_tests/c().('/', 1));
157 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`ReplaceComments<'a>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
158
159 // Test a single-line comment
160 let mut it = ReplaceCommentsrust-analyzer cargo pp-rs 0.2.1 lexer/ReplaceComments#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`ReplaceComments<'a>`]new().("a//foo\nb");
161 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`ReplaceComments<'a>`][Iterator]next().(), crust-analyzer cargo pp-rs 0.2.1 lexer_tests/c().('a', 1));
162 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`ReplaceComments<'a>`][Iterator]next().(), crust-analyzer cargo pp-rs 0.2.1 lexer_tests/c().(COMMENT_SENTINEL_VALUErust-analyzer cargo pp-rs 0.2.1 lexer/COMMENT_SENTINEL_VALUE., 1));
163 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`ReplaceComments<'a>`][Iterator]next().(), crust-analyzer cargo pp-rs 0.2.1 lexer_tests/c().('\n', 1));
164 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`ReplaceComments<'a>`][Iterator]next().(), crust-analyzer cargo pp-rs 0.2.1 lexer_tests/c().('b', 2));
165 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`ReplaceComments<'a>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
166
167 // Test a single-line comment without an ending newline
168 let mut it = ReplaceCommentsrust-analyzer cargo pp-rs 0.2.1 lexer/ReplaceComments#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`ReplaceComments<'a>`]new().("//foo");
169 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`ReplaceComments<'a>`][Iterator]next().(), crust-analyzer cargo pp-rs 0.2.1 lexer_tests/c().(COMMENT_SENTINEL_VALUErust-analyzer cargo pp-rs 0.2.1 lexer/COMMENT_SENTINEL_VALUE., 1));
170 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`ReplaceComments<'a>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
171
172 // Test a single-line comment without nothing afterwards
173 let mut it = ReplaceCommentsrust-analyzer cargo pp-rs 0.2.1 lexer/ReplaceComments#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`ReplaceComments<'a>`]new().("//");
174 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`ReplaceComments<'a>`][Iterator]next().(), crust-analyzer cargo pp-rs 0.2.1 lexer_tests/c().(COMMENT_SENTINEL_VALUErust-analyzer cargo pp-rs 0.2.1 lexer/COMMENT_SENTINEL_VALUE., 1));
175 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`ReplaceComments<'a>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
176
177 // Test a single-line comment with a line continuation
178 let mut it = ReplaceCommentsrust-analyzer cargo pp-rs 0.2.1 lexer/ReplaceComments#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`ReplaceComments<'a>`]new().("//foo\\\na");
179 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`ReplaceComments<'a>`][Iterator]next().(), crust-analyzer cargo pp-rs 0.2.1 lexer_tests/c().(COMMENT_SENTINEL_VALUErust-analyzer cargo pp-rs 0.2.1 lexer/COMMENT_SENTINEL_VALUE., 1));
180 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`ReplaceComments<'a>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
181
182 // Test a multi-line comment
183 let mut it = ReplaceCommentsrust-analyzer cargo pp-rs 0.2.1 lexer/ReplaceComments#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`ReplaceComments<'a>`]new().("a/*fo\n\no*/b");
184 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`ReplaceComments<'a>`][Iterator]next().(), crust-analyzer cargo pp-rs 0.2.1 lexer_tests/c().('a', 1));
185 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`ReplaceComments<'a>`][Iterator]next().(), crust-analyzer cargo pp-rs 0.2.1 lexer_tests/c().(COMMENT_SENTINEL_VALUErust-analyzer cargo pp-rs 0.2.1 lexer/COMMENT_SENTINEL_VALUE., 1));
186 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`ReplaceComments<'a>`][Iterator]next().(), crust-analyzer cargo pp-rs 0.2.1 lexer_tests/c().('b', 3));
187 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`ReplaceComments<'a>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
188
189 // Test a multi-line comment, without a proper ending (only the *)
190 let mut it = ReplaceCommentsrust-analyzer cargo pp-rs 0.2.1 lexer/ReplaceComments#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`ReplaceComments<'a>`]new().("a/*fo\n\no*");
191 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`ReplaceComments<'a>`][Iterator]next().(), crust-analyzer cargo pp-rs 0.2.1 lexer_tests/c().('a', 1));
192 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`ReplaceComments<'a>`][Iterator]next().(), crust-analyzer cargo pp-rs 0.2.1 lexer_tests/c().(COMMENT_SENTINEL_VALUErust-analyzer cargo pp-rs 0.2.1 lexer/COMMENT_SENTINEL_VALUE., 1));
193 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`ReplaceComments<'a>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
194
195 // Test a multi-line comment, without a proper ending (nothing)
196 let mut it = ReplaceCommentsrust-analyzer cargo pp-rs 0.2.1 lexer/ReplaceComments#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`ReplaceComments<'a>`]new().("a/*fo\n\no");
197 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`ReplaceComments<'a>`][Iterator]next().(), crust-analyzer cargo pp-rs 0.2.1 lexer_tests/c().('a', 1));
198 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`ReplaceComments<'a>`][Iterator]next().(), crust-analyzer cargo pp-rs 0.2.1 lexer_tests/c().(COMMENT_SENTINEL_VALUErust-analyzer cargo pp-rs 0.2.1 lexer/COMMENT_SENTINEL_VALUE., 1));
199 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`ReplaceComments<'a>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
200
201 // Test a multi-line comment, or /*/ not being a complete one
202 let mut it = ReplaceCommentsrust-analyzer cargo pp-rs 0.2.1 lexer/ReplaceComments#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`ReplaceComments<'a>`]new().("a/*/b");
203 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`ReplaceComments<'a>`][Iterator]next().(), crust-analyzer cargo pp-rs 0.2.1 lexer_tests/c().('a', 1));
204 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`ReplaceComments<'a>`][Iterator]next().(), crust-analyzer cargo pp-rs 0.2.1 lexer_tests/c().(COMMENT_SENTINEL_VALUErust-analyzer cargo pp-rs 0.2.1 lexer/COMMENT_SENTINEL_VALUE., 1));
205 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`ReplaceComments<'a>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
206 }
207
208 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
209 fn lex_whitespacerust-analyzer cargo pp-rs 0.2.1 lexer_tests/lex_whitespace().() {
210 // Empty input gives nothing.
211 let mut it = Lexerrust-analyzer cargo pp-rs 0.2.1 lexer/Lexer#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]new().("");
212 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
213
214 // Pure whitespace give nothing too
215 let mut it = Lexerrust-analyzer cargo pp-rs 0.2.1 lexer/Lexer#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]new().("/**/\t //a");
216 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
217 }
218
219 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
220 fn lex_newlinerust-analyzer cargo pp-rs 0.2.1 lexer_tests/lex_newline().() {
221 let mut it = Lexerrust-analyzer cargo pp-rs 0.2.1 lexer/Lexer#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]new().("\r\n\n");
222 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), TokenValuerust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#::NewLinerust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#NewLine#);
223 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), TokenValuerust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#::NewLinerust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#NewLine#);
224 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
225
226 // Check a newline is added only if the last token wasn't a newline
227 let mut it = Lexerrust-analyzer cargo pp-rs 0.2.1 lexer/Lexer#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]new().("\r\n\n\t/**/ //");
228 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), TokenValuerust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#::NewLinerust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#NewLine#);
229 expect_lexer_endrust-analyzer cargo pp-rs 0.2.1 lexer_tests/expect_lexer_end().(&mut it);
230
231 let mut it = Lexerrust-analyzer cargo pp-rs 0.2.1 lexer/Lexer#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]new().("\r\n\n#");
232 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), TokenValuerust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#::NewLinerust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#NewLine#);
233 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), TokenValuerust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#::NewLinerust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#NewLine#);
234 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), TokenValuerust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#::Hashrust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#Hash#);
235 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), TokenValuerust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#::NewLinerust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#NewLine#);
236 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
237 }
238
239 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
240 fn lex_hashrust-analyzer cargo pp-rs 0.2.1 lexer_tests/lex_hash().() {
241 let mut it = Lexerrust-analyzer cargo pp-rs 0.2.1 lexer/Lexer#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]new().("a#b");
242 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
243 unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()),
244 TokenValuerust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#::Identrust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#Ident#("a".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())
245 );
246 let token = unwrap_tokenrust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().());
247 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(token.valuerust-analyzer cargo pp-rs 0.2.1 lexer/Token#value., TokenValuerust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#::Hashrust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#Hash#);
248 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(token.locationrust-analyzer cargo pp-rs 0.2.1 lexer/Token#location., lrust-analyzer cargo pp-rs 0.2.1 lexer_tests/l().(1, 1..2));
249 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
250 unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()),
251 TokenValuerust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#::Identrust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#Ident#("b".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())
252 );
253 expect_lexer_endrust-analyzer cargo pp-rs 0.2.1 lexer_tests/expect_lexer_end().(&mut it);
254
255 let mut it = Lexerrust-analyzer cargo pp-rs 0.2.1 lexer/Lexer#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]new().("\nvoid #");
256 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), TokenValuerust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#::NewLinerust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#NewLine#);
257 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
258 unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()),
259 TokenValuerust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#::Identrust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#Ident#("void".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().())
260 );
261 let token = unwrap_tokenrust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().());
262 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(token.valuerust-analyzer cargo pp-rs 0.2.1 lexer/Token#value., TokenValuerust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#::Hashrust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#Hash#);
263 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(token.locationrust-analyzer cargo pp-rs 0.2.1 lexer/Token#location., lrust-analyzer cargo pp-rs 0.2.1 lexer_tests/l().(2, 6..7));
264 expect_lexer_endrust-analyzer cargo pp-rs 0.2.1 lexer_tests/expect_lexer_end().(&mut it);
265 }
266
267 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
268 fn lex_metadatarust-analyzer cargo pp-rs 0.2.1 lexer_tests/lex_metadata().() {
269 // Test the metadata of the first token
270 let mut it = Lexerrust-analyzer cargo pp-rs 0.2.1 lexer/Lexer#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]new().("1");
271 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
272 unwrap_tokenrust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()),
273 Tokenrust-analyzer cargo pp-rs 0.2.1 lexer/Token# {
274 valuerust-analyzer cargo pp-rs 0.2.1 lexer/Token#value.: 1.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
275 locationrust-analyzer cargo pp-rs 0.2.1 lexer/Token#location.: lrust-analyzer cargo pp-rs 0.2.1 lexer_tests/l().(1, 0..1),
276 leading_whitespacerust-analyzer cargo pp-rs 0.2.1 lexer/Token#leading_whitespace.: true,
277 start_of_linerust-analyzer cargo pp-rs 0.2.1 lexer/Token#start_of_line.: true
278 }
279 );
280 expect_lexer_endrust-analyzer cargo pp-rs 0.2.1 lexer_tests/expect_lexer_end().(&mut it);
281
282 // Test various whitespaces are recognized (or lack of)
283 let mut it = Lexerrust-analyzer cargo pp-rs 0.2.1 lexer/Lexer#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]new().(" 1/*\n*/2\t3+\n4");
284 // 1 is the first token and the whitespace doesn't prevent it from being the start of the
285 // line
286 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
287 unwrap_tokenrust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()),
288 Tokenrust-analyzer cargo pp-rs 0.2.1 lexer/Token# {
289 valuerust-analyzer cargo pp-rs 0.2.1 lexer/Token#value.: 1.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
290 locationrust-analyzer cargo pp-rs 0.2.1 lexer/Token#location.: lrust-analyzer cargo pp-rs 0.2.1 lexer_tests/l().(1, 1..2),
291 leading_whitespacerust-analyzer cargo pp-rs 0.2.1 lexer/Token#leading_whitespace.: true,
292 start_of_linerust-analyzer cargo pp-rs 0.2.1 lexer/Token#start_of_line.: true
293 }
294 );
295 // 2 is not at the start of the line because the \n in the /**/ doesn't count, however its
296 // location correctly lists the second line.
297 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
298 unwrap_tokenrust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()),
299 Tokenrust-analyzer cargo pp-rs 0.2.1 lexer/Token# {
300 valuerust-analyzer cargo pp-rs 0.2.1 lexer/Token#value.: 2.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
301 locationrust-analyzer cargo pp-rs 0.2.1 lexer/Token#location.: lrust-analyzer cargo pp-rs 0.2.1 lexer_tests/l().(2, 7..8),
302 leading_whitespacerust-analyzer cargo pp-rs 0.2.1 lexer/Token#leading_whitespace.: true,
303 start_of_linerust-analyzer cargo pp-rs 0.2.1 lexer/Token#start_of_line.: false
304 }
305 );
306 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
307 unwrap_tokenrust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()),
308 Tokenrust-analyzer cargo pp-rs 0.2.1 lexer/Token# {
309 valuerust-analyzer cargo pp-rs 0.2.1 lexer/Token#value.: 3.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
310 locationrust-analyzer cargo pp-rs 0.2.1 lexer/Token#location.: lrust-analyzer cargo pp-rs 0.2.1 lexer_tests/l().(2, 9..10),
311 leading_whitespacerust-analyzer cargo pp-rs 0.2.1 lexer/Token#leading_whitespace.: true,
312 start_of_linerust-analyzer cargo pp-rs 0.2.1 lexer/Token#start_of_line.: false
313 }
314 );
315 // + doesn't have a leading whitespace
316 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
317 unwrap_tokenrust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()),
318 Tokenrust-analyzer cargo pp-rs 0.2.1 lexer/Token# {
319 valuerust-analyzer cargo pp-rs 0.2.1 lexer/Token#value.: Punctrust-analyzer cargo pp-rs 0.2.1 token/Punct#::Plusrust-analyzer cargo pp-rs 0.2.1 token/Punct#Plus#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
320 locationrust-analyzer cargo pp-rs 0.2.1 lexer/Token#location.: lrust-analyzer cargo pp-rs 0.2.1 lexer_tests/l().(2, 10..11),
321 leading_whitespacerust-analyzer cargo pp-rs 0.2.1 lexer/Token#leading_whitespace.: false,
322 start_of_linerust-analyzer cargo pp-rs 0.2.1 lexer/Token#start_of_line.: false
323 }
324 );
325 // The newline is correctly tagged on the preceeding line
326 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
327 unwrap_tokenrust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()),
328 Tokenrust-analyzer cargo pp-rs 0.2.1 lexer/Token# {
329 valuerust-analyzer cargo pp-rs 0.2.1 lexer/Token#value.: TokenValuerust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#::NewLinerust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#NewLine#,
330 locationrust-analyzer cargo pp-rs 0.2.1 lexer/Token#location.: lrust-analyzer cargo pp-rs 0.2.1 lexer_tests/l().(2, 11..12),
331 leading_whitespacerust-analyzer cargo pp-rs 0.2.1 lexer/Token#leading_whitespace.: false,
332 start_of_linerust-analyzer cargo pp-rs 0.2.1 lexer/Token#start_of_line.: false
333 }
334 );
335 // 4 is after a newline that correctly sets start_of_line
336 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
337 unwrap_tokenrust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()),
338 Tokenrust-analyzer cargo pp-rs 0.2.1 lexer/Token# {
339 valuerust-analyzer cargo pp-rs 0.2.1 lexer/Token#value.: 4.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
340 locationrust-analyzer cargo pp-rs 0.2.1 lexer/Token#location.: lrust-analyzer cargo pp-rs 0.2.1 lexer_tests/l().(3, 12..13),
341 leading_whitespacerust-analyzer cargo pp-rs 0.2.1 lexer/Token#leading_whitespace.: true,
342 start_of_linerust-analyzer cargo pp-rs 0.2.1 lexer/Token#start_of_line.: true
343 }
344 );
345 // The final newline added by the lexer is at the correct position
346 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
347 unwrap_tokenrust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()),
348 Tokenrust-analyzer cargo pp-rs 0.2.1 lexer/Token# {
349 valuerust-analyzer cargo pp-rs 0.2.1 lexer/Token#value.: TokenValuerust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#::NewLinerust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#NewLine#,
350 locationrust-analyzer cargo pp-rs 0.2.1 lexer/Token#location.: lrust-analyzer cargo pp-rs 0.2.1 lexer_tests/l().(3, 13..13),
351 leading_whitespacerust-analyzer cargo pp-rs 0.2.1 lexer/Token#leading_whitespace.: false,
352 start_of_linerust-analyzer cargo pp-rs 0.2.1 lexer/Token#start_of_line.: false
353 }
354 );
355 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
356 }
357
358 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
359 fn lex_identifiersrust-analyzer cargo pp-rs 0.2.1 lexer_tests/lex_identifiers().() {
360 // Test some basic identifier cases
361 let mut it = Lexerrust-analyzer cargo pp-rs 0.2.1 lexer/Lexer#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]new().("foo BA_R baz0");
362 let token = unwrap_tokenrust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().());
363 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(token.valuerust-analyzer cargo pp-rs 0.2.1 lexer/Token#value., TokenValuerust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#::Identrust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#Ident#("foo".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()));
364 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(token.locationrust-analyzer cargo pp-rs 0.2.1 lexer/Token#location., lrust-analyzer cargo pp-rs 0.2.1 lexer_tests/l().(1, 0..3),);
365 let token = unwrap_tokenrust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().());
366 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(token.valuerust-analyzer cargo pp-rs 0.2.1 lexer/Token#value., TokenValuerust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#::Identrust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#Ident#("BA_R".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()));
367 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(token.locationrust-analyzer cargo pp-rs 0.2.1 lexer/Token#location., lrust-analyzer cargo pp-rs 0.2.1 lexer_tests/l().(1, 4..8),);
368 let token = unwrap_tokenrust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().());
369 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(token.valuerust-analyzer cargo pp-rs 0.2.1 lexer/Token#value., TokenValuerust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#::Identrust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#Ident#("baz0".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()));
370 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(token.locationrust-analyzer cargo pp-rs 0.2.1 lexer/Token#location., lrust-analyzer cargo pp-rs 0.2.1 lexer_tests/l().(1, 9..13),);
371 expect_lexer_endrust-analyzer cargo pp-rs 0.2.1 lexer_tests/expect_lexer_end().(&mut it);
372
373 // Test _ is a valid identifier
374 let mut it = Lexerrust-analyzer cargo pp-rs 0.2.1 lexer/Lexer#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]new().("_");
375 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
376 unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()),
377 TokenValuerust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#::Identrust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#Ident#("_".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())
378 );
379 expect_lexer_endrust-analyzer cargo pp-rs 0.2.1 lexer_tests/expect_lexer_end().(&mut it);
380
381 // Test that identifiers are not split by escaped newlines
382 let mut it = Lexerrust-analyzer cargo pp-rs 0.2.1 lexer/Lexer#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]new().("a\\\nb");
383 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
384 unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()),
385 TokenValuerust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#::Identrust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#Ident#("ab".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())
386 );
387 expect_lexer_endrust-analyzer cargo pp-rs 0.2.1 lexer_tests/expect_lexer_end().(&mut it);
388
389 // Test that identifiers are split by other whitespace like /**/
390 let mut it = Lexerrust-analyzer cargo pp-rs 0.2.1 lexer/Lexer#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]new().("a/**/b");
391 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
392 unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()),
393 TokenValuerust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#::Identrust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#Ident#("a".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())
394 );
395 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
396 unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()),
397 TokenValuerust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#::Identrust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#Ident#("b".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())
398 );
399 expect_lexer_endrust-analyzer cargo pp-rs 0.2.1 lexer_tests/expect_lexer_end().(&mut it);
400 }
401
402 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
403 fn lex_decimalrust-analyzer cargo pp-rs 0.2.1 lexer_tests/lex_decimal().() {
404 // Test some basic cases
405 let mut it = Lexerrust-analyzer cargo pp-rs 0.2.1 lexer/Lexer#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]new().("1 0u 42 65536U");
406 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), 1.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
407 let token = unwrap_tokenrust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().());
408 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(token.valuerust-analyzer cargo pp-rs 0.2.1 lexer/Token#value., 0u32.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
409 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(token.locationrust-analyzer cargo pp-rs 0.2.1 lexer/Token#location., lrust-analyzer cargo pp-rs 0.2.1 lexer_tests/l().(1, 2..4),);
410 let token = unwrap_tokenrust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().());
411 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(token.valuerust-analyzer cargo pp-rs 0.2.1 lexer/Token#value., 42.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
412 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(token.locationrust-analyzer cargo pp-rs 0.2.1 lexer/Token#location., lrust-analyzer cargo pp-rs 0.2.1 lexer_tests/l().(1, 5..7),);
413 let token = unwrap_tokenrust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().());
414 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(token.valuerust-analyzer cargo pp-rs 0.2.1 lexer/Token#value., 65536u32.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
415 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(token.locationrust-analyzer cargo pp-rs 0.2.1 lexer/Token#location., lrust-analyzer cargo pp-rs 0.2.1 lexer_tests/l().(1, 8..14),);
416 expect_lexer_endrust-analyzer cargo pp-rs 0.2.1 lexer_tests/expect_lexer_end().(&mut it);
417
418 // Test splitting with identifiers
419 let mut it = Lexerrust-analyzer cargo pp-rs 0.2.1 lexer/Lexer#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]new().("31ab");
420 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), 31.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
421 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
422 unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()),
423 TokenValuerust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#::Identrust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#Ident#("ab".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())
424 );
425 expect_lexer_endrust-analyzer cargo pp-rs 0.2.1 lexer_tests/expect_lexer_end().(&mut it);
426
427 // Test splitting with whitespace
428 let mut it = Lexerrust-analyzer cargo pp-rs 0.2.1 lexer/Lexer#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]new().("31/**/32");
429 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), 31.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
430 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), 32.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
431 expect_lexer_endrust-analyzer cargo pp-rs 0.2.1 lexer_tests/expect_lexer_end().(&mut it);
432
433 // Test splitting with punctuation
434 let mut it = Lexerrust-analyzer cargo pp-rs 0.2.1 lexer/Lexer#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]new().("31+32");
435 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), 31.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
436 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), Punctrust-analyzer cargo pp-rs 0.2.1 token/Punct#::Plusrust-analyzer cargo pp-rs 0.2.1 token/Punct#Plus#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
437 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), 32.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
438 expect_lexer_endrust-analyzer cargo pp-rs 0.2.1 lexer_tests/expect_lexer_end().(&mut it);
439
440 // Test that 2^64 produces an overflow error but that 2^64-1 correctly parses (even if it might
441 // produce an error down the line).
442 let mut it = Lexerrust-analyzer cargo pp-rs 0.2.1 lexer/Lexer#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]new().("18446744073709551616");
443 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_errorrust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_error().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), PreprocessorErrorrust-analyzer cargo pp-rs 0.2.1 token/PreprocessorError#::IntegerOverflowrust-analyzer cargo pp-rs 0.2.1 token/PreprocessorError#IntegerOverflow#);
444 let mut it = Lexerrust-analyzer cargo pp-rs 0.2.1 lexer/Lexer#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]new().("18446744073709551615");
445 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
446 unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()),
447 TokenValuerust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#::Integerrust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#Integer#(Integerrust-analyzer cargo pp-rs 0.2.1 token/Integer# {
448 valuerust-analyzer cargo pp-rs 0.2.1 token/Integer#value.: 18446744073709551615,
449 signedrust-analyzer cargo pp-rs 0.2.1 token/Integer#signed.: true,
450 widthrust-analyzer cargo pp-rs 0.2.1 token/Integer#width.: 32
451 })
452 );
453 expect_lexer_endrust-analyzer cargo pp-rs 0.2.1 lexer_tests/expect_lexer_end().(&mut it);
454
455 // Check that the 16bit or 64bit suffixes produce errors (for now).
456 let mut it = Lexerrust-analyzer cargo pp-rs 0.2.1 lexer/Lexer#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]new().("13s");
457 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
458 unwrap_errorrust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_error().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()),
459 PreprocessorErrorrust-analyzer cargo pp-rs 0.2.1 token/PreprocessorError#::NotSupported16BitLiteralrust-analyzer cargo pp-rs 0.2.1 token/PreprocessorError#NotSupported16BitLiteral#
460 );
461 let mut it = Lexerrust-analyzer cargo pp-rs 0.2.1 lexer/Lexer#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]new().("13S");
462 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
463 unwrap_errorrust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_error().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()),
464 PreprocessorErrorrust-analyzer cargo pp-rs 0.2.1 token/PreprocessorError#::NotSupported16BitLiteralrust-analyzer cargo pp-rs 0.2.1 token/PreprocessorError#NotSupported16BitLiteral#
465 );
466 let mut it = Lexerrust-analyzer cargo pp-rs 0.2.1 lexer/Lexer#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]new().("13l");
467 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
468 unwrap_errorrust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_error().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()),
469 PreprocessorErrorrust-analyzer cargo pp-rs 0.2.1 token/PreprocessorError#::NotSupported64BitLiteralrust-analyzer cargo pp-rs 0.2.1 token/PreprocessorError#NotSupported64BitLiteral#
470 );
471 let mut it = Lexerrust-analyzer cargo pp-rs 0.2.1 lexer/Lexer#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]new().("13L");
472 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
473 unwrap_errorrust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_error().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()),
474 PreprocessorErrorrust-analyzer cargo pp-rs 0.2.1 token/PreprocessorError#::NotSupported64BitLiteralrust-analyzer cargo pp-rs 0.2.1 token/PreprocessorError#NotSupported64BitLiteral#
475 );
476
477 // Check that they produce unsupported errors even if they happen with a unsigned suffix too.
478 let mut it = Lexerrust-analyzer cargo pp-rs 0.2.1 lexer/Lexer#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]new().("13uS");
479 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
480 unwrap_errorrust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_error().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()),
481 PreprocessorErrorrust-analyzer cargo pp-rs 0.2.1 token/PreprocessorError#::NotSupported16BitLiteralrust-analyzer cargo pp-rs 0.2.1 token/PreprocessorError#NotSupported16BitLiteral#
482 );
483 let mut it = Lexerrust-analyzer cargo pp-rs 0.2.1 lexer/Lexer#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]new().("13Ul");
484 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
485 unwrap_errorrust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_error().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()),
486 PreprocessorErrorrust-analyzer cargo pp-rs 0.2.1 token/PreprocessorError#::NotSupported64BitLiteralrust-analyzer cargo pp-rs 0.2.1 token/PreprocessorError#NotSupported64BitLiteral#
487 );
488 }
489
490 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
491 fn lex_hexadecimalrust-analyzer cargo pp-rs 0.2.1 lexer_tests/lex_hexadecimal().() {
492 // Test some basic cases
493 let mut it = Lexerrust-analyzer cargo pp-rs 0.2.1 lexer/Lexer#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]new().("0x1 0X0u 0xBaFfe 0XcaFeU");
494 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), 1.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
495 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), 0u32.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
496 let token = unwrap_tokenrust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().());
497 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(token.valuerust-analyzer cargo pp-rs 0.2.1 lexer/Token#value., 0xBAFFE.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
498 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(token.locationrust-analyzer cargo pp-rs 0.2.1 lexer/Token#location., lrust-analyzer cargo pp-rs 0.2.1 lexer_tests/l().(1, 9..16),);
499 let token = unwrap_tokenrust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().());
500 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(token.valuerust-analyzer cargo pp-rs 0.2.1 lexer/Token#value., 0xCAFEu32.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
501 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(token.locationrust-analyzer cargo pp-rs 0.2.1 lexer/Token#location., lrust-analyzer cargo pp-rs 0.2.1 lexer_tests/l().(1, 17..24),);
502 expect_lexer_endrust-analyzer cargo pp-rs 0.2.1 lexer_tests/expect_lexer_end().(&mut it);
503
504 // Test with redundant zeroes
505 let mut it = Lexerrust-analyzer cargo pp-rs 0.2.1 lexer/Lexer#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]new().("0x000 0x000000000000001");
506 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), 0.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
507 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), 1.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
508 expect_lexer_endrust-analyzer cargo pp-rs 0.2.1 lexer_tests/expect_lexer_end().(&mut it);
509
510 // Test splitting with identifiers
511 let mut it = Lexerrust-analyzer cargo pp-rs 0.2.1 lexer/Lexer#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]new().("0x31zb");
512 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), 0x31.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
513 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
514 unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()),
515 TokenValuerust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#::Identrust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#Ident#("zb".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())
516 );
517 expect_lexer_endrust-analyzer cargo pp-rs 0.2.1 lexer_tests/expect_lexer_end().(&mut it);
518
519 // Test splitting with whitespace
520 let mut it = Lexerrust-analyzer cargo pp-rs 0.2.1 lexer/Lexer#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]new().("0x31/**/32");
521 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), 0x31.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
522 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), 32.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
523 expect_lexer_endrust-analyzer cargo pp-rs 0.2.1 lexer_tests/expect_lexer_end().(&mut it);
524
525 // Test splitting with punctuation
526 let mut it = Lexerrust-analyzer cargo pp-rs 0.2.1 lexer/Lexer#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]new().("0x31+32");
527 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), 0x31.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
528 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), Punctrust-analyzer cargo pp-rs 0.2.1 token/Punct#::Plusrust-analyzer cargo pp-rs 0.2.1 token/Punct#Plus#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
529 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), 32.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
530 expect_lexer_endrust-analyzer cargo pp-rs 0.2.1 lexer_tests/expect_lexer_end().(&mut it);
531
532 // Test that 2^64 produces an overflow error but that 2^64-1 correctly parses (even if it might
533 // produce an error down the line).
534 let mut it = Lexerrust-analyzer cargo pp-rs 0.2.1 lexer/Lexer#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]new().("0x10000000000000000");
535 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_errorrust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_error().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), PreprocessorErrorrust-analyzer cargo pp-rs 0.2.1 token/PreprocessorError#::IntegerOverflowrust-analyzer cargo pp-rs 0.2.1 token/PreprocessorError#IntegerOverflow#);
536 let mut it = Lexerrust-analyzer cargo pp-rs 0.2.1 lexer/Lexer#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]new().("0xFFFFFFFFFFFFFFFF");
537 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
538 unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()),
539 TokenValuerust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#::Integerrust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#Integer#(Integerrust-analyzer cargo pp-rs 0.2.1 token/Integer# {
540 valuerust-analyzer cargo pp-rs 0.2.1 token/Integer#value.: 18446744073709551615,
541 signedrust-analyzer cargo pp-rs 0.2.1 token/Integer#signed.: true,
542 widthrust-analyzer cargo pp-rs 0.2.1 token/Integer#width.: 32
543 })
544 );
545 expect_lexer_endrust-analyzer cargo pp-rs 0.2.1 lexer_tests/expect_lexer_end().(&mut it);
546 }
547
548 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
549 fn lex_octalrust-analyzer cargo pp-rs 0.2.1 lexer_tests/lex_octal().() {
550 // Test some basic cases
551 let mut it = Lexerrust-analyzer cargo pp-rs 0.2.1 lexer/Lexer#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]new().("01 00u 07654 01234u");
552 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), 1.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
553 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), 0u32.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
554 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), 4012.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
555 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), 668u32.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
556 expect_lexer_endrust-analyzer cargo pp-rs 0.2.1 lexer_tests/expect_lexer_end().(&mut it);
557
558 // Test with redundant zeroes
559 let mut it = Lexerrust-analyzer cargo pp-rs 0.2.1 lexer/Lexer#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]new().("0000 0000000000000001");
560 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), 0.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
561 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), 1.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
562 expect_lexer_endrust-analyzer cargo pp-rs 0.2.1 lexer_tests/expect_lexer_end().(&mut it);
563
564 // Test splitting with identifiers
565 let mut it = Lexerrust-analyzer cargo pp-rs 0.2.1 lexer/Lexer#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]new().("031zb");
566 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), 25.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
567 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
568 unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()),
569 TokenValuerust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#::Identrust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#Ident#("zb".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())
570 );
571 expect_lexer_endrust-analyzer cargo pp-rs 0.2.1 lexer_tests/expect_lexer_end().(&mut it);
572
573 // Test splitting with whitespace
574 let mut it = Lexerrust-analyzer cargo pp-rs 0.2.1 lexer/Lexer#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]new().("031/**/32");
575 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), 25.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
576 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), 32.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
577 expect_lexer_endrust-analyzer cargo pp-rs 0.2.1 lexer_tests/expect_lexer_end().(&mut it);
578
579 // TODO(kangz): Fix octal numbers consuming 8 and 9s as well. This can be done with extra logic
580 // already but is not worth the complexity.
581
582 // Test splitting with 8 and 9
583 // let mut it = Lexer::new("039 038");
584 // assert_eq!(unwrap_token_value(it.next()), 3.into());
585 // assert_eq!(unwrap_token_value(it.next()), 9.into());
586 // assert_eq!(unwrap_token_value(it.next()), 3.into());
587 // assert_eq!(unwrap_token_value(it.next()), 8.into());
588 // expect_lexer_end(&mut it);
589
590 // Test splitting with punctuation
591 let mut it = Lexerrust-analyzer cargo pp-rs 0.2.1 lexer/Lexer#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]new().("031+32");
592 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), 25.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
593 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), Punctrust-analyzer cargo pp-rs 0.2.1 token/Punct#::Plusrust-analyzer cargo pp-rs 0.2.1 token/Punct#Plus#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
594 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), 32.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
595 expect_lexer_endrust-analyzer cargo pp-rs 0.2.1 lexer_tests/expect_lexer_end().(&mut it);
596
597 // Test that 2^64 produces an overflow error but that 2^64-1 correctly parses (even if it might
598 // produce an error down the line).
599 let mut it = Lexerrust-analyzer cargo pp-rs 0.2.1 lexer/Lexer#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]new().("02000000000000000000000");
600 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_errorrust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_error().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), PreprocessorErrorrust-analyzer cargo pp-rs 0.2.1 token/PreprocessorError#::IntegerOverflowrust-analyzer cargo pp-rs 0.2.1 token/PreprocessorError#IntegerOverflow#);
601 let mut it = Lexerrust-analyzer cargo pp-rs 0.2.1 lexer/Lexer#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]new().("01777777777777777777777");
602 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
603 unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()),
604 TokenValuerust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#::Integerrust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#Integer#(Integerrust-analyzer cargo pp-rs 0.2.1 token/Integer# {
605 valuerust-analyzer cargo pp-rs 0.2.1 token/Integer#value.: 18446744073709551615,
606 signedrust-analyzer cargo pp-rs 0.2.1 token/Integer#signed.: true,
607 widthrust-analyzer cargo pp-rs 0.2.1 token/Integer#width.: 32
608 })
609 );
610 expect_lexer_endrust-analyzer cargo pp-rs 0.2.1 lexer_tests/expect_lexer_end().(&mut it);
611 }
612
613 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
614 fn lex_floatrust-analyzer cargo pp-rs 0.2.1 lexer_tests/lex_float().() {
615 // Test a couple simple cases.
616 let mut it = Lexerrust-analyzer cargo pp-rs 0.2.1 lexer/Lexer#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]new().("1.0 0.0");
617 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), 1.0f32.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
618 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), 0.0f32.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
619 expect_lexer_endrust-analyzer cargo pp-rs 0.2.1 lexer_tests/expect_lexer_end().(&mut it);
620
621 // Test parsing with a leading .
622 let mut it = Lexerrust-analyzer cargo pp-rs 0.2.1 lexer/Lexer#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]new().(".99 0.01 .00000000");
623 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), 0.99f32.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
624 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), 0.01f32.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
625 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), 0.0f32.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
626 expect_lexer_endrust-analyzer cargo pp-rs 0.2.1 lexer_tests/expect_lexer_end().(&mut it);
627
628 // Test parsing with nothing after the .
629 let mut it = Lexerrust-analyzer cargo pp-rs 0.2.1 lexer/Lexer#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]new().("42. 0.");
630 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), 42.0f32.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
631 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), 0.0f32.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
632 expect_lexer_endrust-analyzer cargo pp-rs 0.2.1 lexer_tests/expect_lexer_end().(&mut it);
633
634 // Test parsing with the float suffix
635 let mut it = Lexerrust-analyzer cargo pp-rs 0.2.1 lexer/Lexer#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]new().("1000.f 1.f .2f");
636 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), 1000.0f32.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
637 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), 1.0f32.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
638 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), 0.2f32.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
639 expect_lexer_endrust-analyzer cargo pp-rs 0.2.1 lexer_tests/expect_lexer_end().(&mut it);
640
641 // Test parsing with exponents
642 // - with / without float suffixes
643 // - at different points in the float parsing.
644 let mut it = Lexerrust-analyzer cargo pp-rs 0.2.1 lexer/Lexer#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]new().("3e10 4.1e-10f .01e12F 4.1e+10f");
645 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), 3e10f32.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
646 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), 4.1e-10f32.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
647 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), 0.01e12f32.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
648 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), 4.1e+10f32.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
649 expect_lexer_endrust-analyzer cargo pp-rs 0.2.1 lexer_tests/expect_lexer_end().(&mut it);
650
651 // Test parsing with exponents
652 // - After values looking like octal integer (works)
653 // - After values looking like hexadecimal integer (doesn't work)
654 let mut it = Lexerrust-analyzer cargo pp-rs 0.2.1 lexer/Lexer#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]new().("05e2 0x1e-2");
655 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), 5e2f32.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
656
657 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), 0x1Ei32.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
658 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), Punctrust-analyzer cargo pp-rs 0.2.1 token/Punct#::Minusrust-analyzer cargo pp-rs 0.2.1 token/Punct#Minus#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
659 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), 2i32.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
660
661 // Test parsing with nothing valid after the 'e' (technically it shouldn't
662 // be an error, but there's no language where that sequence of token is
663 // valid.
664 let mut it = Lexerrust-analyzer cargo pp-rs 0.2.1 lexer/Lexer#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]new().("1.0e");
665 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
666 unwrap_errorrust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_error().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()),
667 PreprocessorErrorrust-analyzer cargo pp-rs 0.2.1 token/PreprocessorError#::FloatParsingErrorrust-analyzer cargo pp-rs 0.2.1 token/PreprocessorError#FloatParsingError#
668 );
669
670 // Check that 16bit and 64bit suffixes produce errors
671 let mut it = Lexerrust-analyzer cargo pp-rs 0.2.1 lexer/Lexer#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]new().("1.0l");
672 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
673 unwrap_errorrust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_error().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()),
674 PreprocessorErrorrust-analyzer cargo pp-rs 0.2.1 token/PreprocessorError#::NotSupported64BitLiteralrust-analyzer cargo pp-rs 0.2.1 token/PreprocessorError#NotSupported64BitLiteral#
675 );
676 let mut it = Lexerrust-analyzer cargo pp-rs 0.2.1 lexer/Lexer#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]new().("1.0L");
677 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
678 unwrap_errorrust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_error().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()),
679 PreprocessorErrorrust-analyzer cargo pp-rs 0.2.1 token/PreprocessorError#::NotSupported64BitLiteralrust-analyzer cargo pp-rs 0.2.1 token/PreprocessorError#NotSupported64BitLiteral#
680 );
681 let mut it = Lexerrust-analyzer cargo pp-rs 0.2.1 lexer/Lexer#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]new().("1.0h");
682 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
683 unwrap_errorrust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_error().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()),
684 PreprocessorErrorrust-analyzer cargo pp-rs 0.2.1 token/PreprocessorError#::NotSupported16BitLiteralrust-analyzer cargo pp-rs 0.2.1 token/PreprocessorError#NotSupported16BitLiteral#
685 );
686 let mut it = Lexerrust-analyzer cargo pp-rs 0.2.1 lexer/Lexer#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]new().("1.0H");
687 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
688 unwrap_errorrust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_error().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()),
689 PreprocessorErrorrust-analyzer cargo pp-rs 0.2.1 token/PreprocessorError#::NotSupported16BitLiteralrust-analyzer cargo pp-rs 0.2.1 token/PreprocessorError#NotSupported16BitLiteral#
690 );
691 }
692
693 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
694 fn lex_punctuationrust-analyzer cargo pp-rs 0.2.1 lexer_tests/lex_punctuation().() {
695 // Test parsing some of the token (but not all, that'd be too many tests!)
696 let mut it = Lexerrust-analyzer cargo pp-rs 0.2.1 lexer/Lexer#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]new().("+ != <<=");
697 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), Punctrust-analyzer cargo pp-rs 0.2.1 token/Punct#::Plusrust-analyzer cargo pp-rs 0.2.1 token/Punct#Plus#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
698 let token = unwrap_tokenrust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().());
699 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(token.valuerust-analyzer cargo pp-rs 0.2.1 lexer/Token#value., Punctrust-analyzer cargo pp-rs 0.2.1 token/Punct#::NotEqualrust-analyzer cargo pp-rs 0.2.1 token/Punct#NotEqual#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
700 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(token.locationrust-analyzer cargo pp-rs 0.2.1 lexer/Token#location., lrust-analyzer cargo pp-rs 0.2.1 lexer_tests/l().(1, 2..4),);
701 let token = unwrap_tokenrust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().());
702 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(token.valuerust-analyzer cargo pp-rs 0.2.1 lexer/Token#value., Punctrust-analyzer cargo pp-rs 0.2.1 token/Punct#::LeftShiftAssignrust-analyzer cargo pp-rs 0.2.1 token/Punct#LeftShiftAssign#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
703 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(token.locationrust-analyzer cargo pp-rs 0.2.1 lexer/Token#location., lrust-analyzer cargo pp-rs 0.2.1 lexer_tests/l().(1, 5..8),);
704 expect_lexer_endrust-analyzer cargo pp-rs 0.2.1 lexer_tests/expect_lexer_end().(&mut it);
705
706 // Test parsing a token that's a prefix of another one just before EOF
707 let mut it = Lexerrust-analyzer cargo pp-rs 0.2.1 lexer/Lexer#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]new().("<");
708 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), Punctrust-analyzer cargo pp-rs 0.2.1 token/Punct#::LeftAnglerust-analyzer cargo pp-rs 0.2.1 token/Punct#LeftAngle#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
709 expect_lexer_endrust-analyzer cargo pp-rs 0.2.1 lexer_tests/expect_lexer_end().(&mut it);
710
711 // Test \\\n doesn't split the token
712 let mut it = Lexerrust-analyzer cargo pp-rs 0.2.1 lexer/Lexer#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]new().("=\\\n=");
713 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), Punctrust-analyzer cargo pp-rs 0.2.1 token/Punct#::EqualEqualrust-analyzer cargo pp-rs 0.2.1 token/Punct#EqualEqual#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
714 expect_lexer_endrust-analyzer cargo pp-rs 0.2.1 lexer_tests/expect_lexer_end().(&mut it);
715
716 // Test whitespace splits the token
717 let mut it = Lexerrust-analyzer cargo pp-rs 0.2.1 lexer/Lexer#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]new().("+/**/=");
718 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), Punctrust-analyzer cargo pp-rs 0.2.1 token/Punct#::Plusrust-analyzer cargo pp-rs 0.2.1 token/Punct#Plus#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
719 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), Punctrust-analyzer cargo pp-rs 0.2.1 token/Punct#::Equalrust-analyzer cargo pp-rs 0.2.1 token/Punct#Equal#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
720 expect_lexer_endrust-analyzer cargo pp-rs 0.2.1 lexer_tests/expect_lexer_end().(&mut it);
721
722 // Test a number stops processing the token
723 let mut it = Lexerrust-analyzer cargo pp-rs 0.2.1 lexer/Lexer#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]new().("!1");
724 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), Punctrust-analyzer cargo pp-rs 0.2.1 token/Punct#::Bangrust-analyzer cargo pp-rs 0.2.1 token/Punct#Bang#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
725 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), 1.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
726 expect_lexer_endrust-analyzer cargo pp-rs 0.2.1 lexer_tests/expect_lexer_end().(&mut it);
727
728 // Test an identifier stops processing the token
729 let mut it = Lexerrust-analyzer cargo pp-rs 0.2.1 lexer/Lexer#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]new().("&a");
730 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), Punctrust-analyzer cargo pp-rs 0.2.1 token/Punct#::Ampersandrust-analyzer cargo pp-rs 0.2.1 token/Punct#Ampersand#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
731 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
732 unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()),
733 TokenValuerust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#::Identrust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#Ident#("a".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())
734 );
735 expect_lexer_endrust-analyzer cargo pp-rs 0.2.1 lexer_tests/expect_lexer_end().(&mut it);
736
737 // Test whitespace splits the token
738 let mut it = Lexerrust-analyzer cargo pp-rs 0.2.1 lexer/Lexer#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]new().(">/**/>");
739 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), Punctrust-analyzer cargo pp-rs 0.2.1 token/Punct#::RightAnglerust-analyzer cargo pp-rs 0.2.1 token/Punct#RightAngle#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
740 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), Punctrust-analyzer cargo pp-rs 0.2.1 token/Punct#::RightAnglerust-analyzer cargo pp-rs 0.2.1 token/Punct#RightAngle#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
741 expect_lexer_endrust-analyzer cargo pp-rs 0.2.1 lexer_tests/expect_lexer_end().(&mut it);
742
743 // Test that tokens are parsed greedily: `a+++++b` is `a ++ ++ + b` (invalid GLSL) and not
744 // `(a ++) + (++ b)` (valid GLSL)
745 let mut it = Lexerrust-analyzer cargo pp-rs 0.2.1 lexer/Lexer#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]new().("+++++");
746 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), Punctrust-analyzer cargo pp-rs 0.2.1 token/Punct#::Incrementrust-analyzer cargo pp-rs 0.2.1 token/Punct#Increment#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
747 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), Punctrust-analyzer cargo pp-rs 0.2.1 token/Punct#::Incrementrust-analyzer cargo pp-rs 0.2.1 token/Punct#Increment#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
748 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), Punctrust-analyzer cargo pp-rs 0.2.1 token/Punct#::Plusrust-analyzer cargo pp-rs 0.2.1 token/Punct#Plus#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
749 expect_lexer_endrust-analyzer cargo pp-rs 0.2.1 lexer_tests/expect_lexer_end().(&mut it);
750
751 // Test that an invalid char produces and error
752 let mut it = Lexerrust-analyzer cargo pp-rs 0.2.1 lexer/Lexer#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]new().("@");
753 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
754 unwrap_errorrust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_error().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()),
755 PreprocessorErrorrust-analyzer cargo pp-rs 0.2.1 token/PreprocessorError#::UnexpectedCharacterrust-analyzer cargo pp-rs 0.2.1 token/PreprocessorError#UnexpectedCharacter#
756 );
757
758 // Extra punctuation tests for code coverage.
759 let mut it = Lexerrust-analyzer cargo pp-rs 0.2.1 lexer/Lexer#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]new().("<= >= += -= &= || |= | ^= { } ] ? .");
760 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), Punctrust-analyzer cargo pp-rs 0.2.1 token/Punct#::LessEqualrust-analyzer cargo pp-rs 0.2.1 token/Punct#LessEqual#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
761 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), Punctrust-analyzer cargo pp-rs 0.2.1 token/Punct#::GreaterEqualrust-analyzer cargo pp-rs 0.2.1 token/Punct#GreaterEqual#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
762 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), Punctrust-analyzer cargo pp-rs 0.2.1 token/Punct#::AddAssignrust-analyzer cargo pp-rs 0.2.1 token/Punct#AddAssign#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
763 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), Punctrust-analyzer cargo pp-rs 0.2.1 token/Punct#::SubAssignrust-analyzer cargo pp-rs 0.2.1 token/Punct#SubAssign#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
764 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), Punctrust-analyzer cargo pp-rs 0.2.1 token/Punct#::AndAssignrust-analyzer cargo pp-rs 0.2.1 token/Punct#AndAssign#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
765 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), Punctrust-analyzer cargo pp-rs 0.2.1 token/Punct#::LogicalOrrust-analyzer cargo pp-rs 0.2.1 token/Punct#LogicalOr#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
766 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), Punctrust-analyzer cargo pp-rs 0.2.1 token/Punct#::OrAssignrust-analyzer cargo pp-rs 0.2.1 token/Punct#OrAssign#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
767 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), Punctrust-analyzer cargo pp-rs 0.2.1 token/Punct#::Piperust-analyzer cargo pp-rs 0.2.1 token/Punct#Pipe#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
768 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), Punctrust-analyzer cargo pp-rs 0.2.1 token/Punct#::XorAssignrust-analyzer cargo pp-rs 0.2.1 token/Punct#XorAssign#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
769 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), Punctrust-analyzer cargo pp-rs 0.2.1 token/Punct#::LeftBracerust-analyzer cargo pp-rs 0.2.1 token/Punct#LeftBrace#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
770 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), Punctrust-analyzer cargo pp-rs 0.2.1 token/Punct#::RightBracerust-analyzer cargo pp-rs 0.2.1 token/Punct#RightBrace#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
771 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), Punctrust-analyzer cargo pp-rs 0.2.1 token/Punct#::RightBracketrust-analyzer cargo pp-rs 0.2.1 token/Punct#RightBracket#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
772 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), Punctrust-analyzer cargo pp-rs 0.2.1 token/Punct#::Questionrust-analyzer cargo pp-rs 0.2.1 token/Punct#Question#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
773 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), Punctrust-analyzer cargo pp-rs 0.2.1 token/Punct#::Dotrust-analyzer cargo pp-rs 0.2.1 token/Punct#Dot#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
774 expect_lexer_endrust-analyzer cargo pp-rs 0.2.1 lexer_tests/expect_lexer_end().(&mut it);
775 }
776
777 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
778 fn lex_had_commentsrust-analyzer cargo pp-rs 0.2.1 lexer_tests/lex_had_comments().() {
779 // Test that had_comments doesn't get set to true if there is no comments.
780 let mut it = Lexerrust-analyzer cargo pp-rs 0.2.1 lexer/Lexer#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]new().("#version");
781 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().it.had_commentsrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]had_comments().());
782 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), TokenValuerust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#::Hashrust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#Hash#);
783 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().it.had_commentsrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]had_comments().());
784 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
785 unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()),
786 TokenValuerust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#::Identrust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#Ident#("version".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())
787 );
788 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().it.had_commentsrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]had_comments().());
789 expect_lexer_endrust-analyzer cargo pp-rs 0.2.1 lexer_tests/expect_lexer_end().(&mut it);
790
791 // Test that had_comments doesn't get triggered by its sentinel value of '\r'
792 let mut it = Lexerrust-analyzer cargo pp-rs 0.2.1 lexer/Lexer#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]new().("\r!");
793 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().it.had_commentsrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]had_comments().());
794 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), TokenValuerust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#::NewLinerust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#NewLine#);
795 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), Punctrust-analyzer cargo pp-rs 0.2.1 token/Punct#::Bangrust-analyzer cargo pp-rs 0.2.1 token/Punct#Bang#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
796 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().it.had_commentsrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]had_comments().());
797 expect_lexer_endrust-analyzer cargo pp-rs 0.2.1 lexer_tests/expect_lexer_end().(&mut it);
798
799 // Test that had_comments gets triggered by // comments
800 let mut it = Lexerrust-analyzer cargo pp-rs 0.2.1 lexer/Lexer#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]new().("//\n!");
801 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().it.had_commentsrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]had_comments().());
802 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), TokenValuerust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#::NewLinerust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#NewLine#);
803 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(it.had_commentsrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]had_comments().());
804 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), Punctrust-analyzer cargo pp-rs 0.2.1 token/Punct#::Bangrust-analyzer cargo pp-rs 0.2.1 token/Punct#Bang#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
805 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(it.had_commentsrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]had_comments().());
806 expect_lexer_endrust-analyzer cargo pp-rs 0.2.1 lexer_tests/expect_lexer_end().(&mut it);
807
808 // Test that had_comments doesn't gets triggered by /**/ comments
809 let mut it = Lexerrust-analyzer cargo pp-rs 0.2.1 lexer/Lexer#::newrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]new().("/**/#version");
810 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().it.had_commentsrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]had_comments().());
811 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()), TokenValuerust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#::Hashrust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#Hash#);
812 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(it.had_commentsrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]had_comments().());
813 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
814 unwrap_token_valuerust-analyzer cargo pp-rs 0.2.1 lexer_tests/unwrap_token_value().(it.nextrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`][Iterator]next().()),
815 TokenValuerust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#::Identrust-analyzer cargo pp-rs 0.2.1 lexer/TokenValue#Ident#("version".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())
816 );
817 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(it.had_commentsrust-analyzer cargo pp-rs 0.2.1 lexer/impl#[`Lexer<'a>`]had_comments().());
818 expect_lexer_endrust-analyzer cargo pp-rs 0.2.1 lexer_tests/expect_lexer_end().(&mut it);
819 }
820
821 // TODO test has_whitespace