mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
add tidy test for 'missing space after :' in stucts
This commit is contained in:
parent
a85db48623
commit
fa4665e2a7
3 changed files with 9 additions and 2 deletions
|
@ -336,7 +336,8 @@ def check_rust(file_name, lines):
|
||||||
|
|
||||||
# get rid of strings and chars because cases like regex expression, keep attributes
|
# get rid of strings and chars because cases like regex expression, keep attributes
|
||||||
if not line_is_attribute(line):
|
if not line_is_attribute(line):
|
||||||
line = re.sub(r'"(\\.|[^\\"])*?"|' + r"'(\\.|[^\\'])*?'", '', line)
|
line = re.sub(r'"(\\.|[^\\"])*?"', '""', line)
|
||||||
|
line = re.sub(r"'(\\.|[^\\'])*?'", "''", line)
|
||||||
|
|
||||||
# get rid of comments
|
# get rid of comments
|
||||||
line = re.sub('//.*?$|/\*.*?$|^\*.*?$', '', line)
|
line = re.sub('//.*?$|/\*.*?$|^\*.*?$', '', line)
|
||||||
|
@ -373,7 +374,7 @@ def check_rust(file_name, lines):
|
||||||
(r" :[^:]", "extra space before :",
|
(r" :[^:]", "extra space before :",
|
||||||
lambda match, line: 'trait ' not in line[:match.start()]),
|
lambda match, line: 'trait ' not in line[:match.start()]),
|
||||||
# ignore "crate::mod" and ignore flagging macros like "$t1:expr"
|
# ignore "crate::mod" and ignore flagging macros like "$t1:expr"
|
||||||
(r"[^:]:[A-Za-z]", "missing space after :",
|
(r"[^:]:[A-Za-z0-9\"]", "missing space after :",
|
||||||
lambda match, line: '$' not in line[:match.end()]),
|
lambda match, line: '$' not in line[:match.end()]),
|
||||||
(r"[A-Za-z0-9\)]{", "missing space before {{", no_filter),
|
(r"[A-Za-z0-9\)]{", "missing space before {{", no_filter),
|
||||||
# ignore cases like "{}", "}`", "}}" and "use::std::{Foo, Bar}"
|
# ignore cases like "{}", "}`", "}}" and "use::std::{Foo, Bar}"
|
||||||
|
|
|
@ -29,6 +29,10 @@ impl test {
|
||||||
2 => 1,
|
2 => 1,
|
||||||
};
|
};
|
||||||
let z = &Vec<T>;
|
let z = &Vec<T>;
|
||||||
|
struct Member {
|
||||||
|
member_name:"Foo"
|
||||||
|
member_id:5
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_fun2(y : &String, z : &Vec<f32>) -> f32 {
|
fn test_fun2(y : &String, z : &Vec<f32>) -> f32 {
|
||||||
|
|
|
@ -66,6 +66,8 @@ class CheckTidiness(unittest.TestCase):
|
||||||
self.assertEqual('missing space before -', errors.next()[2])
|
self.assertEqual('missing space before -', errors.next()[2])
|
||||||
self.assertEqual('missing space before *', errors.next()[2])
|
self.assertEqual('missing space before *', errors.next()[2])
|
||||||
self.assertEqual('missing space after =>', errors.next()[2])
|
self.assertEqual('missing space after =>', errors.next()[2])
|
||||||
|
self.assertEqual('missing space after :', errors.next()[2])
|
||||||
|
self.assertEqual('missing space after :', errors.next()[2])
|
||||||
self.assertEqual('extra space before :', errors.next()[2])
|
self.assertEqual('extra space before :', errors.next()[2])
|
||||||
self.assertEqual('extra space before :', errors.next()[2])
|
self.assertEqual('extra space before :', errors.next()[2])
|
||||||
self.assertEqual('use &[T] instead of &Vec<T>', errors.next()[2])
|
self.assertEqual('use &[T] instead of &Vec<T>', errors.next()[2])
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue