Skip to content

Commit 85ab8df

Browse files
committed
cargo clippy & fmt
1 parent 1bb001c commit 85ab8df

File tree

3 files changed

+38
-13
lines changed

3 files changed

+38
-13
lines changed

src/codegen/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ mod function_tests;
1111
mod generics_test;
1212
mod initialization_test;
1313
mod multifile_codegen_tests;
14+
mod online_change_tests;
1415
mod parameters_tests;
1516
mod statement_codegen_test;
1617
mod string_tests;
17-
mod online_change_tests;
1818
#[cfg(feature = "verify")]
1919
mod switch_case_tests;
2020
mod typesystem_test;

src/codegen/tests/online_change_tests.rs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ use crate::test_utils::tests::codegen_with_online_change as codegen;
44

55
#[test]
66
fn generate_function_with_online_change() {
7-
let src = codegen("
7+
let src = codegen(
8+
"
89
FUNCTION foo : DINT
910
VAR
1011
x : DINT;
1112
END_VAR
1213
END_FUNCTION
13-
");
14+
",
15+
);
1416
assert_snapshot!(src, @r###"
1517
; ModuleID = '<internal>'
1618
source_filename = "<internal>"
@@ -40,13 +42,15 @@ fn generate_function_with_online_change() {
4042

4143
#[test]
4244
fn generate_program_with_online_change() {
43-
let src = codegen("
45+
let src = codegen(
46+
"
4447
PROGRAM prg
4548
VAR
4649
x : DINT;
4750
END_VAR
4851
END_PROGRAM
49-
");
52+
",
53+
);
5054
assert_snapshot!(src, @r###"
5155
; ModuleID = '<internal>'
5256
source_filename = "<internal>"
@@ -100,7 +104,8 @@ fn generate_program_with_online_change() {
100104

101105
#[test]
102106
fn generate_program_and_var_with_online_change() {
103-
let src = codegen("
107+
let src = codegen(
108+
"
104109
PROGRAM prg
105110
VAR
106111
x : DINT;
@@ -110,7 +115,8 @@ fn generate_program_and_var_with_online_change() {
110115
VAR_GLOBAL
111116
gV : DINT;
112117
END_VAR
113-
");
118+
",
119+
);
114120
assert_snapshot!(src, @r###"
115121
; ModuleID = '<internal>'
116122
source_filename = "<internal>"
@@ -168,7 +174,8 @@ fn generate_program_and_var_with_online_change() {
168174

169175
#[test]
170176
fn generate_function_and_var_with_online_change() {
171-
let src = codegen("
177+
let src = codegen(
178+
"
172179
FUNCTION foo : DINT
173180
VAR
174181
x : DINT;
@@ -178,7 +185,8 @@ fn generate_function_and_var_with_online_change() {
178185
VAR_GLOBAL
179186
gV : DINT;
180187
END_VAR
181-
");
188+
",
189+
);
182190
assert_snapshot!(src, @r###"
183191
; ModuleID = '<internal>'
184192
source_filename = "<internal>"

src/test_utils.rs

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,18 @@ pub mod tests {
1414
use plc_source::{source_location::SourceLocationFactory, Compilable, SourceCode, SourceContainer};
1515

1616
use crate::{
17-
builtins, codegen::{CodegenContext, GeneratedModule}, index::{self, FxIndexSet, Index}, lexer, lowering::AstLowerer, parser, resolver::{
17+
builtins,
18+
codegen::{CodegenContext, GeneratedModule},
19+
index::{self, FxIndexSet, Index},
20+
lexer,
21+
lowering::AstLowerer,
22+
parser,
23+
resolver::{
1824
const_evaluator::evaluate_constants, AnnotationMapImpl, AstAnnotations, Dependency,
1925
StringLiterals, TypeAnnotator,
20-
}, typesystem::get_builtin_types, DebugLevel, OnlineChange, Validator
26+
},
27+
typesystem::get_builtin_types,
28+
DebugLevel, OnlineChange, Validator,
2129
};
2230

2331
pub fn parse(src: &str) -> (CompilationUnit, Vec<Diagnostic>) {
@@ -188,7 +196,12 @@ pub mod tests {
188196
}
189197

190198
pub fn codegen_with_online_change(src: &str) -> String {
191-
codegen_debug_without_unwrap_oc(src, DebugLevel::None, OnlineChange::Enabled{ file_name: "test".into(), format: crate::ConfigFormat::JSON }).unwrap()
199+
codegen_debug_without_unwrap_oc(
200+
src,
201+
DebugLevel::None,
202+
OnlineChange::Enabled { file_name: "test".into(), format: crate::ConfigFormat::JSON },
203+
)
204+
.unwrap()
192205
}
193206

194207
pub fn codegen_debug_without_unwrap(src: &str, debug_level: DebugLevel) -> Result<String, String> {
@@ -199,7 +212,11 @@ pub mod tests {
199212
/// reported diagnostics. Therefor the return value of this method is always a tuple.
200213
/// TODO: This should not be so, we should have a diagnostic type that holds multiple new
201214
/// issues.
202-
pub fn codegen_debug_without_unwrap_oc(src: &str, debug_level: DebugLevel, online_change: OnlineChange) -> Result<String, String> {
215+
pub fn codegen_debug_without_unwrap_oc(
216+
src: &str,
217+
debug_level: DebugLevel,
218+
online_change: OnlineChange,
219+
) -> Result<String, String> {
203220
let mut reporter = Diagnostician::buffered();
204221
reporter.register_file("<internal>".to_string(), src.to_string());
205222
let mut id_provider = IdProvider::default();

0 commit comments

Comments
 (0)