re-enabled tests, removed fuzzing hooks

This commit is contained in:
0rphon 2022-03-14 16:29:34 -07:00
parent 3c258bf3a4
commit 1604f10115
10 changed files with 19 additions and 25 deletions

View File

@ -550,7 +550,7 @@ impl ReconstructingReducer for Canonicalizer {
for (index, character) in string.iter().enumerate() {
let col_start = span.col_start + index + 1 + col_adder; // account for open quote
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;
match bytes[col_start] {
@ -558,7 +558,7 @@ impl ReconstructingReducer for Canonicalizer {
b'u' => {
width += 1;
let mut index = 1;
while bytes[col_start + index] != b'}' { // 0rphon
while bytes[col_start + index] != b'}' {
width += 1;
index += 1;
}

View File

@ -339,7 +339,7 @@ impl<'a> ParserContext<'a> {
});
}
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 });
}
self.expect_ident()

View File

@ -53,7 +53,7 @@ impl ParserContext<'_> {
Token::U32 => IntegerType::U32,
Token::U64 => IntegerType::U64,
Token::U128 => IntegerType::U128,
_ => return None, // todo 0rphon: unreachable
_ => return None,
})
}

View File

@ -32,7 +32,7 @@ fn eat(input: &[u8], wanted: &str) -> Option<usize> {
if input.len() < wanted.len() {
return None;
}
if &input[..wanted.len()] == wanted { // 0rphon
if &input[..wanted.len()] == wanted {
return Some(wanted.len());
}
None
@ -70,7 +70,7 @@ impl Token {
if escaped {
let string = input_tendril.to_string();
let escaped = &string[1..string.len()]; // 0rphon
let escaped = &string[1..string.len()];
if escaped.len() != 1 {
return Err(ParserError::lexer_escaped_char_incorrect_length(escaped).into());
@ -92,7 +92,7 @@ impl Token {
if hex {
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 {
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 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());
} else if let Ok(hex) = u32::from_str_radix(unicode_number, 16) {
if let Some(character) = std::char::from_u32(hex) {
@ -136,8 +136,6 @@ impl Token {
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())
}
@ -195,8 +193,6 @@ impl Token {
///
pub(crate) fn eat(input_tendril: StrTendril) -> Result<(usize, Token)> {
if input_tendril.is_empty() {
// 0rphon
panic!();
return Err(ParserError::lexer_empty_input_tendril().into());
}
let input = input_tendril.as_bytes();
@ -276,7 +272,7 @@ impl Token {
}
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)));

View File

@ -259,7 +259,7 @@ ppp test
let token_raw = token.token.to_string();
let start = line_indicies.get(token.span.line_start - 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);
}
})

View File

@ -201,8 +201,7 @@ impl Token {
Some(match self {
Token::Address => sym::address,
Token::As => sym::As,
// todo 0rphon: possibly reachable via unused import tests
Token::At => panic!(), //sym::At,
Token::At => sym::At,
Token::Bool => sym::bool,
Token::Char => sym::char,
Token::Circuit => sym::circuit,
@ -237,8 +236,7 @@ impl Token {
Token::U32 => sym::u32,
Token::U64 => sym::u64,
Token::U128 => sym::u128,
// todo 0rphon: possibly reachable via unused import tests
_ => panic!(), //return None,
_ => return None,
})
}
}

View File

@ -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
cargo test --package leo-parser --lib -- test::parser_tests --exact --nocapture
set CLEAR_LEO_TEST_EXPECTATIONS=

View File

@ -39,11 +39,11 @@ expectation: Fail
'\uz'
'\u1'
'' // 0rphon '\u};
'\u};
'🦀\n'
'\u123'
'' //0rphon '🦀1🦀'
'' //0rphon '\u6🦀}'
'🦀1🦀'
'\u6🦀}'
'\u{af🦀'
'\u{2764z'
'\u{276g}'

View File

@ -4,5 +4,5 @@ expectation: Fail
*/
0xb
0xb // 0rphon 0x
0x
0xbfield

View File

@ -19,8 +19,8 @@ expectation: Fail
"\x"
"\x" // 0rphon "\u}"
"\u}"
"\x" // 0rphon "\u6🦀}"
"\u6🦀}"
"\u{af🦀"