Skip to content

Commit

Permalink
Test updates.
Browse files Browse the repository at this point in the history
  • Loading branch information
sciguyryan committed Feb 1, 2024
1 parent 8208eb3 commit 5948a15
Showing 1 changed file with 25 additions and 26 deletions.
51 changes: 25 additions & 26 deletions redox-core/src/parsing/asm_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ impl<'a> AsmParser<'a> {
// Default to the text section, in case no sections are specified.
let mut section = FileSection::Text;

for line in sanitized.lines() {
for line in sanitized.lines().map(|l| l.trim()) {
if line.starts_with(';') {
continue;
}
Expand Down Expand Up @@ -1108,16 +1108,15 @@ mod tests_asm_parsing {

#[test]
fn code_misc_tests() {
let tests = [
ParserTest::new(
"mov EAX,\\\r\nEBX",
&[
Instruction::MovU32RegU32Reg(RegisterId::EAX, RegisterId::EBX),
],
false,
"failed to correctly parse instruction.",
),
];
let tests = [ParserTest::new(
"mov eax,\\\r\nebx",
&[Instruction::MovU32RegU32Reg(
RegisterId::EAX,
RegisterId::EBX,
)],
false,
"failed to correctly parse instruction.",
)];

ParserTests::new(&tests).run_all();
}
Expand Down Expand Up @@ -1198,7 +1197,7 @@ mod tests_asm_parsing {
),
// This is invalid because the argument to call must be an integer register or integer immediate pointer.
ParserTest::new(
"call ER1",
"call eax",
&[],
true,
"succeeded in parsing instruction with invalid arguments.",
Expand All @@ -1212,96 +1211,96 @@ mod tests_asm_parsing {
),
// This is invalid because the argument to call must be an integer register or integer immediate pointer.
ParserTest::new(
"call &FP1",
"call &fr1",
&[],
true,
"succeeded in parsing instruction with invalid arguments.",
),
// This is invalid because the register ID doesn't exist.
ParserTest::new(
"call &AAA",
"call &aaa",
&[],
true,
"succeeded in parsing instruction with invalid arguments.",
),
// This is invalid because we have an open square bracket (indicating an expression) but no
// closing one. This is invalid syntax.
ParserTest::new(
"mov &[ER1*2, ER1",
"mov &[eax*2, eax",
&[],
true,
"succeeded in parsing instruction with invalid arguments.",
),
// This is invalid because we have a closing square bracket (indicating an expression) but no
// opening one. This is invalid syntax.
ParserTest::new(
"mov &ER1*2], ER1",
"mov &eax*2], eax",
&[],
true,
"succeeded in parsing instruction with invalid arguments.",
),
// This is invalid because the expression containing an invalid register.
ParserTest::new(
"mov &[ERQ*2], ER1",
"mov &[erq*2], eax",
&[],
true,
"succeeded in parsing instruction with invalid arguments.",
),
// This is invalid because the value is larger than supported by a u8 value.
// In an expression we may only use u8 values.
ParserTest::new(
"mov &[ER1*999], ER1",
"mov &[eax*999], eax",
&[],
true,
"succeeded in parsing instruction with invalid arguments.",
),
// This is invalid because we can't use floats in expressions.
ParserTest::new(
"mov &[ER1*1.0], ER1",
"mov &[eax*1.0], eax",
&[],
true,
"succeeded in parsing instruction with invalid arguments.",
),
// This is invalid because we have an operator with nothing following it.
ParserTest::new(
"mov &[ER1*], ER1",
"mov &[eax*], eax",
&[],
true,
"succeeded in parsing instruction with invalid arguments.",
),
// This is invalid because we have an operator with nothing preceding it.
ParserTest::new(
"mov &[*ER1], ER1",
"mov &[*eax], eax",
&[],
true,
"succeeded in parsing instruction with invalid arguments.",
),
// This is invalid because we have an operator with nothing following it.
ParserTest::new(
"mov &[ER1*ER2*], ER1",
"mov &[eax*ebx*], eax",
&[],
true,
"succeeded in parsing instruction with invalid arguments.",
),
// This is invalid because we have too many arguments within the expression.
// We may, at most, have three values.
ParserTest::new(
"mov &[ER1*ER2*ER3*ER4], ER1",
"mov &[eax*ebx*ecx*edx], eax",
&[],
true,
"succeeded in parsing instruction with invalid arguments.",
),
// This is invalid because a single period is not a valid floating-point value.
ParserTest::new(
"mov ., ER1",
"mov ., eax",
&[],
true,
"succeeded in parsing instruction with invalid arguments.",
),
// This is invalid because a number followed by single period with no following digits
// is not a valid floating-point value.
ParserTest::new(
"mov 1., ER1",
"mov 1., eax",
&[],
true,
"succeeded in parsing instruction with invalid arguments.",
Expand All @@ -1323,7 +1322,7 @@ mod tests_asm_parsing {
// This is invalid because there should be a second function argument on the next line,
// which is made inline by the \ symbol.
ParserTest::new(
"mov EAX,\\\n",
"mov eax,\\\n",
&[],
true,
"succeeded in parsing invalid section marker.",
Expand Down

0 comments on commit 5948a15

Please sign in to comment.