(&self, f: &mut fmt::Formatter<'_>)
| 56 | |
| 57 | impl<'a> fmt::Debug for PrintableTestCase<'a> { |
| 58 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
| 59 | match self.kind { |
| 60 | TestCaseKind::Compile => { |
| 61 | writeln!(f, ";; Compile test case\n")?; |
| 62 | writeln!(f, "test compile")?; |
| 63 | } |
| 64 | TestCaseKind::Run => { |
| 65 | writeln!(f, ";; Run test case\n")?; |
| 66 | writeln!(f, "test interpret")?; |
| 67 | writeln!(f, "test run")?; |
| 68 | } |
| 69 | }; |
| 70 | |
| 71 | write_non_default_flags(f, self.isa.flags())?; |
| 72 | |
| 73 | write!(f, "target {} ", self.isa.triple().architecture)?; |
| 74 | write_non_default_isa_flags(f, &self.isa)?; |
| 75 | write!(f, "\n\n")?; |
| 76 | |
| 77 | // Print the functions backwards, so that the main function is printed last |
| 78 | // and near the test inputs for run test cases. |
| 79 | for func in self.functions.iter().rev() { |
| 80 | writeln!(f, "{func}\n")?; |
| 81 | } |
| 82 | |
| 83 | if !self.inputs.is_empty() { |
| 84 | writeln!( |
| 85 | f, |
| 86 | "; Note: the results in the below test cases are simply a placeholder and probably will be wrong\n" |
| 87 | )?; |
| 88 | } |
| 89 | |
| 90 | for input in self.inputs.iter() { |
| 91 | // TODO: We don't know the expected outputs, maybe we can run the interpreter |
| 92 | // here to figure them out? Should work, however we need to be careful to catch |
| 93 | // panics in case its the interpreter that is failing. |
| 94 | // For now create a placeholder output consisting of the zero value for the type |
| 95 | let returns = &self.main().signature.returns; |
| 96 | let placeholder_output = returns |
| 97 | .iter() |
| 98 | .map(|param| DataValue::read_from_slice_ne(&[0; 16][..], param.value_type)) |
| 99 | .map(|val| format!("{val}")) |
| 100 | .collect::<Vec<_>>() |
| 101 | .join(", "); |
| 102 | |
| 103 | // If we have no output, we don't need the == condition |
| 104 | let test_condition = match returns.len() { |
| 105 | 0 => String::new(), |
| 106 | 1 => format!(" == {placeholder_output}"), |
| 107 | _ => format!(" == [{placeholder_output}]"), |
| 108 | }; |
| 109 | |
| 110 | let args = input |
| 111 | .iter() |
| 112 | .map(|val| format!("{val}")) |
| 113 | .collect::<Vec<_>>() |
| 114 | .join(", "); |
| 115 |
nothing calls this directly
no test coverage detected