mirror of
https://github.com/AleoHQ/leo.git
synced 2024-12-19 07:32:26 +03:00
re-enabled tests, removed fuzzing hooks
This commit is contained in:
parent
3c258bf3a4
commit
1604f10115
@ -550,7 +550,7 @@ impl ReconstructingReducer for Canonicalizer {
|
|||||||
for (index, character) in string.iter().enumerate() {
|
for (index, character) in string.iter().enumerate() {
|
||||||
let col_start = span.col_start + index + 1 + col_adder; // account for open quote
|
let col_start = span.col_start + index + 1 + col_adder; // account for open quote
|
||||||
let bytes = span.content.clone().into_bytes();
|
let bytes = span.content.clone().into_bytes();
|
||||||
let col_stop = if bytes[col_start - 1] == b'\\' { // 0rphon
|
let col_stop = if bytes[col_start - 1] == b'\\' {
|
||||||
let mut width = 0;
|
let mut width = 0;
|
||||||
|
|
||||||
match bytes[col_start] {
|
match bytes[col_start] {
|
||||||
@ -558,7 +558,7 @@ impl ReconstructingReducer for Canonicalizer {
|
|||||||
b'u' => {
|
b'u' => {
|
||||||
width += 1;
|
width += 1;
|
||||||
let mut index = 1;
|
let mut index = 1;
|
||||||
while bytes[col_start + index] != b'}' { // 0rphon
|
while bytes[col_start + index] != b'}' {
|
||||||
width += 1;
|
width += 1;
|
||||||
index += 1;
|
index += 1;
|
||||||
}
|
}
|
||||||
|
@ -339,7 +339,7 @@ impl<'a> ParserContext<'a> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
if let Some((int, span)) = self.eat_int() {
|
if let Some((int, span)) = self.eat_int() {
|
||||||
let name = Symbol::intern(&int.value); //todo 0rphon: covered by unused import tests
|
let name = Symbol::intern(&int.value);
|
||||||
return Ok(Identifier { name, span });
|
return Ok(Identifier { name, span });
|
||||||
}
|
}
|
||||||
self.expect_ident()
|
self.expect_ident()
|
||||||
|
@ -53,7 +53,7 @@ impl ParserContext<'_> {
|
|||||||
Token::U32 => IntegerType::U32,
|
Token::U32 => IntegerType::U32,
|
||||||
Token::U64 => IntegerType::U64,
|
Token::U64 => IntegerType::U64,
|
||||||
Token::U128 => IntegerType::U128,
|
Token::U128 => IntegerType::U128,
|
||||||
_ => return None, // todo 0rphon: unreachable
|
_ => return None,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ fn eat(input: &[u8], wanted: &str) -> Option<usize> {
|
|||||||
if input.len() < wanted.len() {
|
if input.len() < wanted.len() {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
if &input[..wanted.len()] == wanted { // 0rphon
|
if &input[..wanted.len()] == wanted {
|
||||||
return Some(wanted.len());
|
return Some(wanted.len());
|
||||||
}
|
}
|
||||||
None
|
None
|
||||||
@ -70,7 +70,7 @@ impl Token {
|
|||||||
|
|
||||||
if escaped {
|
if escaped {
|
||||||
let string = input_tendril.to_string();
|
let string = input_tendril.to_string();
|
||||||
let escaped = &string[1..string.len()]; // 0rphon
|
let escaped = &string[1..string.len()];
|
||||||
|
|
||||||
if escaped.len() != 1 {
|
if escaped.len() != 1 {
|
||||||
return Err(ParserError::lexer_escaped_char_incorrect_length(escaped).into());
|
return Err(ParserError::lexer_escaped_char_incorrect_length(escaped).into());
|
||||||
@ -92,7 +92,7 @@ impl Token {
|
|||||||
|
|
||||||
if hex {
|
if hex {
|
||||||
let string = input_tendril.to_string();
|
let string = input_tendril.to_string();
|
||||||
let hex_string = &string[2..string.len()]; // 0rphon
|
let hex_string = &string[2..string.len()];
|
||||||
|
|
||||||
if hex_string.len() != 2 {
|
if hex_string.len() != 2 {
|
||||||
return Err(ParserError::lexer_escaped_hex_incorrect_length(hex_string).into());
|
return Err(ParserError::lexer_escaped_hex_incorrect_length(hex_string).into());
|
||||||
@ -114,7 +114,7 @@ impl Token {
|
|||||||
|
|
||||||
let unicode_number = &string[3..string.len() - 1];
|
let unicode_number = &string[3..string.len() - 1];
|
||||||
let len = unicode_number.len();
|
let len = unicode_number.len();
|
||||||
if !(1..=6).contains(&len) { // 0rphon
|
if !(1..=6).contains(&len) {
|
||||||
return Err(ParserError::lexer_invalid_escaped_unicode_length(unicode_number).into());
|
return Err(ParserError::lexer_invalid_escaped_unicode_length(unicode_number).into());
|
||||||
} else if let Ok(hex) = u32::from_str_radix(unicode_number, 16) {
|
} else if let Ok(hex) = u32::from_str_radix(unicode_number, 16) {
|
||||||
if let Some(character) = std::char::from_u32(hex) {
|
if let Some(character) = std::char::from_u32(hex) {
|
||||||
@ -136,8 +136,6 @@ impl Token {
|
|||||||
return Ok(Char::Scalar(character));
|
return Ok(Char::Scalar(character));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 0rphon: should be impossible to hit if function is used correctly
|
|
||||||
panic!();
|
|
||||||
Err(ParserError::lexer_invalid_char(input_tendril.to_string()).into())
|
Err(ParserError::lexer_invalid_char(input_tendril.to_string()).into())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,8 +193,6 @@ impl Token {
|
|||||||
///
|
///
|
||||||
pub(crate) fn eat(input_tendril: StrTendril) -> Result<(usize, Token)> {
|
pub(crate) fn eat(input_tendril: StrTendril) -> Result<(usize, Token)> {
|
||||||
if input_tendril.is_empty() {
|
if input_tendril.is_empty() {
|
||||||
// 0rphon
|
|
||||||
panic!();
|
|
||||||
return Err(ParserError::lexer_empty_input_tendril().into());
|
return Err(ParserError::lexer_empty_input_tendril().into());
|
||||||
}
|
}
|
||||||
let input = input_tendril.as_bytes();
|
let input = input_tendril.as_bytes();
|
||||||
@ -276,7 +272,7 @@ impl Token {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if i == input.len() || !end {
|
if i == input.len() || !end {
|
||||||
return Err(ParserError::lexer_string_not_closed(String::from_utf8_lossy(&input[..i])).into()); // 0rphon
|
return Err(ParserError::lexer_string_not_closed(String::from_utf8_lossy(&input[..i])).into());
|
||||||
}
|
}
|
||||||
|
|
||||||
return Ok((i + 1, Token::StringLit(string)));
|
return Ok((i + 1, Token::StringLit(string)));
|
||||||
|
@ -259,7 +259,7 @@ ppp test
|
|||||||
let token_raw = token.token.to_string();
|
let token_raw = token.token.to_string();
|
||||||
let start = line_indicies.get(token.span.line_start - 1).unwrap();
|
let start = line_indicies.get(token.span.line_start - 1).unwrap();
|
||||||
let stop = line_indicies.get(token.span.line_stop - 1).unwrap();
|
let stop = line_indicies.get(token.span.line_stop - 1).unwrap();
|
||||||
let original = &raw[*start + token.span.col_start - 1..*stop + token.span.col_stop - 1]; // 0rphon
|
let original = &raw[*start + token.span.col_start - 1..*stop + token.span.col_stop - 1];
|
||||||
assert_eq!(original, &token_raw);
|
assert_eq!(original, &token_raw);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -201,8 +201,7 @@ impl Token {
|
|||||||
Some(match self {
|
Some(match self {
|
||||||
Token::Address => sym::address,
|
Token::Address => sym::address,
|
||||||
Token::As => sym::As,
|
Token::As => sym::As,
|
||||||
// todo 0rphon: possibly reachable via unused import tests
|
Token::At => sym::At,
|
||||||
Token::At => panic!(), //sym::At,
|
|
||||||
Token::Bool => sym::bool,
|
Token::Bool => sym::bool,
|
||||||
Token::Char => sym::char,
|
Token::Char => sym::char,
|
||||||
Token::Circuit => sym::circuit,
|
Token::Circuit => sym::circuit,
|
||||||
@ -237,8 +236,7 @@ impl Token {
|
|||||||
Token::U32 => sym::u32,
|
Token::U32 => sym::u32,
|
||||||
Token::U64 => sym::u64,
|
Token::U64 => sym::u64,
|
||||||
Token::U128 => sym::u128,
|
Token::U128 => sym::u128,
|
||||||
// todo 0rphon: possibly reachable via unused import tests
|
_ => return None,
|
||||||
_ => panic!(), //return None,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
2
test.bat
2
test.bat
@ -1,4 +1,4 @@
|
|||||||
@REM cargo test --package leo-parser --lib -- test::parser_tests --exact --nocapture cargo 2>&1 | rp -B 2 dbg
|
@REM cargo test --package leo-parser --lib -- test::parser_tests --exact --nocapture cargo 2>&1 | rg -B 2 dbg
|
||||||
set CLEAR_LEO_TEST_EXPECTATIONS=1
|
set CLEAR_LEO_TEST_EXPECTATIONS=1
|
||||||
cargo test --package leo-parser --lib -- test::parser_tests --exact --nocapture
|
cargo test --package leo-parser --lib -- test::parser_tests --exact --nocapture
|
||||||
set CLEAR_LEO_TEST_EXPECTATIONS=
|
set CLEAR_LEO_TEST_EXPECTATIONS=
|
@ -39,11 +39,11 @@ expectation: Fail
|
|||||||
|
|
||||||
'\uz'
|
'\uz'
|
||||||
'\u1'
|
'\u1'
|
||||||
'' // 0rphon '\u};
|
'\u};
|
||||||
'🦀\n'
|
'🦀\n'
|
||||||
'\u123'
|
'\u123'
|
||||||
'' //0rphon '🦀1🦀'
|
'🦀1🦀'
|
||||||
'' //0rphon '\u6🦀}'
|
'\u6🦀}'
|
||||||
'\u{af🦀'
|
'\u{af🦀'
|
||||||
'\u{2764z'
|
'\u{2764z'
|
||||||
'\u{276g}'
|
'\u{276g}'
|
||||||
|
@ -4,5 +4,5 @@ expectation: Fail
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
0xb
|
0xb
|
||||||
0xb // 0rphon 0x
|
0x
|
||||||
0xbfield
|
0xbfield
|
@ -19,8 +19,8 @@ expectation: Fail
|
|||||||
|
|
||||||
"\x"
|
"\x"
|
||||||
|
|
||||||
"\x" // 0rphon "\u}"
|
"\u}"
|
||||||
|
|
||||||
"\x" // 0rphon "\u6🦀}"
|
"\u6🦀}"
|
||||||
|
|
||||||
"\u{af🦀"
|
"\u{af🦀"
|
||||||
|
Loading…
Reference in New Issue
Block a user