mirror of
https://github.com/denoland/deno.git
synced 2024-11-29 16:30:56 -05:00
fix clippy warnings (#3798)
This commit is contained in:
parent
97ed0c954d
commit
ba78ba69b0
2 changed files with 16 additions and 21 deletions
|
@ -712,7 +712,7 @@ mod tests {
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.code
|
.code
|
||||||
.as_bytes()
|
.as_bytes()
|
||||||
.starts_with("console.log(\"Hello World\");".as_bytes()));
|
.starts_with(b"console.log(\"Hello World\");"));
|
||||||
};
|
};
|
||||||
|
|
||||||
tokio_util::run(fut.boxed())
|
tokio_util::run(fut.boxed())
|
||||||
|
|
|
@ -934,7 +934,7 @@ mod tests {
|
||||||
let r = result.unwrap();
|
let r = result.unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
r.source_code,
|
r.source_code,
|
||||||
"export { printHello } from \"./print_hello.ts\";\n".as_bytes()
|
&b"export { printHello } from \"./print_hello.ts\";\n"[..]
|
||||||
);
|
);
|
||||||
assert_eq!(&(r.media_type), &msg::MediaType::TypeScript);
|
assert_eq!(&(r.media_type), &msg::MediaType::TypeScript);
|
||||||
// Should not create .headers.json file due to matching ext
|
// Should not create .headers.json file due to matching ext
|
||||||
|
@ -952,7 +952,7 @@ mod tests {
|
||||||
let r2 = result2.unwrap();
|
let r2 = result2.unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
r2.source_code,
|
r2.source_code,
|
||||||
"export { printHello } from \"./print_hello.ts\";\n".as_bytes()
|
&b"export { printHello } from \"./print_hello.ts\";\n"[..]
|
||||||
);
|
);
|
||||||
// If get_source_file_async does not call remote, this should be JavaScript
|
// If get_source_file_async does not call remote, this should be JavaScript
|
||||||
// as we modified before! (we do not overwrite .headers.json due to no http fetch)
|
// as we modified before! (we do not overwrite .headers.json due to no http fetch)
|
||||||
|
@ -979,7 +979,7 @@ mod tests {
|
||||||
let r3 = result3.unwrap();
|
let r3 = result3.unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
r3.source_code,
|
r3.source_code,
|
||||||
"export { printHello } from \"./print_hello.ts\";\n".as_bytes()
|
&b"export { printHello } from \"./print_hello.ts\";\n"[..]
|
||||||
);
|
);
|
||||||
// If get_source_file_async does not call remote, this should be JavaScript
|
// If get_source_file_async does not call remote, this should be JavaScript
|
||||||
// as we modified before! (we do not overwrite .headers.json due to no http fetch)
|
// as we modified before! (we do not overwrite .headers.json due to no http fetch)
|
||||||
|
@ -997,7 +997,7 @@ mod tests {
|
||||||
assert!(result4.is_ok());
|
assert!(result4.is_ok());
|
||||||
let r4 = result4.unwrap();
|
let r4 = result4.unwrap();
|
||||||
let expected4 =
|
let expected4 =
|
||||||
"export { printHello } from \"./print_hello.ts\";\n".as_bytes();
|
&b"export { printHello } from \"./print_hello.ts\";\n"[..];
|
||||||
assert_eq!(r4.source_code, expected4);
|
assert_eq!(r4.source_code, expected4);
|
||||||
// Now the old .headers.json file should have gone! Resolved back to TypeScript
|
// Now the old .headers.json file should have gone! Resolved back to TypeScript
|
||||||
assert_eq!(&(r4.media_type), &msg::MediaType::TypeScript);
|
assert_eq!(&(r4.media_type), &msg::MediaType::TypeScript);
|
||||||
|
@ -1029,7 +1029,7 @@ mod tests {
|
||||||
.then(move |result| {
|
.then(move |result| {
|
||||||
assert!(result.is_ok());
|
assert!(result.is_ok());
|
||||||
let r = result.unwrap();
|
let r = result.unwrap();
|
||||||
let expected = "export const loaded = true;\n".as_bytes();
|
let expected = b"export const loaded = true;\n";
|
||||||
assert_eq!(r.source_code, expected);
|
assert_eq!(r.source_code, expected);
|
||||||
// Mismatch ext with content type, create .headers.json
|
// Mismatch ext with content type, create .headers.json
|
||||||
assert_eq!(&(r.media_type), &msg::MediaType::JavaScript);
|
assert_eq!(&(r.media_type), &msg::MediaType::JavaScript);
|
||||||
|
@ -1053,7 +1053,7 @@ mod tests {
|
||||||
.then(move |result2| {
|
.then(move |result2| {
|
||||||
assert!(result2.is_ok());
|
assert!(result2.is_ok());
|
||||||
let r2 = result2.unwrap();
|
let r2 = result2.unwrap();
|
||||||
let expected2 = "export const loaded = true;\n".as_bytes();
|
let expected2 = b"export const loaded = true;\n";
|
||||||
assert_eq!(r2.source_code, expected2);
|
assert_eq!(r2.source_code, expected2);
|
||||||
// If get_source_file_async does not call remote, this should be TypeScript
|
// If get_source_file_async does not call remote, this should be TypeScript
|
||||||
// as we modified before! (we do not overwrite .headers.json due to no http fetch)
|
// as we modified before! (we do not overwrite .headers.json due to no http fetch)
|
||||||
|
@ -1068,7 +1068,7 @@ mod tests {
|
||||||
.map(move |result3| {
|
.map(move |result3| {
|
||||||
assert!(result3.is_ok());
|
assert!(result3.is_ok());
|
||||||
let r3 = result3.unwrap();
|
let r3 = result3.unwrap();
|
||||||
let expected3 = "export const loaded = true;\n".as_bytes();
|
let expected3 = b"export const loaded = true;\n";
|
||||||
assert_eq!(r3.source_code, expected3);
|
assert_eq!(r3.source_code, expected3);
|
||||||
// Now the old .headers.json file should be overwritten back to JavaScript!
|
// Now the old .headers.json file should be overwritten back to JavaScript!
|
||||||
// (due to http fetch)
|
// (due to http fetch)
|
||||||
|
@ -1448,7 +1448,7 @@ mod tests {
|
||||||
.map(move |result| {
|
.map(move |result| {
|
||||||
assert!(result.is_ok());
|
assert!(result.is_ok());
|
||||||
let r = result.unwrap();
|
let r = result.unwrap();
|
||||||
assert_eq!(r.source_code, "export const loaded = true;\n".as_bytes());
|
assert_eq!(r.source_code, b"export const loaded = true;\n");
|
||||||
assert_eq!(&(r.media_type), &msg::MediaType::TypeScript);
|
assert_eq!(&(r.media_type), &msg::MediaType::TypeScript);
|
||||||
// matching ext, no .headers.json file created
|
// matching ext, no .headers.json file created
|
||||||
assert!(fs::read_to_string(&headers_file_name).is_err());
|
assert!(fs::read_to_string(&headers_file_name).is_err());
|
||||||
|
@ -1463,7 +1463,7 @@ mod tests {
|
||||||
let result2 = fetcher.fetch_cached_remote_source(&module_url);
|
let result2 = fetcher.fetch_cached_remote_source(&module_url);
|
||||||
assert!(result2.is_ok());
|
assert!(result2.is_ok());
|
||||||
let r2 = result2.unwrap().unwrap();
|
let r2 = result2.unwrap().unwrap();
|
||||||
assert_eq!(r2.source_code, "export const loaded = true;\n".as_bytes());
|
assert_eq!(r2.source_code, b"export const loaded = true;\n");
|
||||||
// Not MediaType::TypeScript due to .headers.json modification
|
// Not MediaType::TypeScript due to .headers.json modification
|
||||||
assert_eq!(&(r2.media_type), &msg::MediaType::JavaScript);
|
assert_eq!(&(r2.media_type), &msg::MediaType::JavaScript);
|
||||||
});
|
});
|
||||||
|
@ -1494,7 +1494,7 @@ mod tests {
|
||||||
.then(move |result| {
|
.then(move |result| {
|
||||||
assert!(result.is_ok());
|
assert!(result.is_ok());
|
||||||
let r = result.unwrap();
|
let r = result.unwrap();
|
||||||
assert_eq!(r.source_code, "export const loaded = true;\n".as_bytes());
|
assert_eq!(r.source_code, b"export const loaded = true;\n");
|
||||||
assert_eq!(&(r.media_type), &msg::MediaType::TypeScript);
|
assert_eq!(&(r.media_type), &msg::MediaType::TypeScript);
|
||||||
// no ext, should create .headers.json file
|
// no ext, should create .headers.json file
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
@ -1509,7 +1509,7 @@ mod tests {
|
||||||
.then(move |result| {
|
.then(move |result| {
|
||||||
assert!(result.is_ok());
|
assert!(result.is_ok());
|
||||||
let r2 = result.unwrap();
|
let r2 = result.unwrap();
|
||||||
assert_eq!(r2.source_code, "export const loaded = true;\n".as_bytes());
|
assert_eq!(r2.source_code, b"export const loaded = true;\n");
|
||||||
assert_eq!(&(r2.media_type), &msg::MediaType::JavaScript);
|
assert_eq!(&(r2.media_type), &msg::MediaType::JavaScript);
|
||||||
// mismatch ext, should create .headers.json file
|
// mismatch ext, should create .headers.json file
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
@ -1525,7 +1525,7 @@ mod tests {
|
||||||
.map(move |result| {
|
.map(move |result| {
|
||||||
assert!(result.is_ok());
|
assert!(result.is_ok());
|
||||||
let r3 = result.unwrap();
|
let r3 = result.unwrap();
|
||||||
assert_eq!(r3.source_code, "export const loaded = true;\n".as_bytes());
|
assert_eq!(r3.source_code, b"export const loaded = true;\n");
|
||||||
assert_eq!(&(r3.media_type), &msg::MediaType::TypeScript);
|
assert_eq!(&(r3.media_type), &msg::MediaType::TypeScript);
|
||||||
// unknown ext, should create .headers.json file
|
// unknown ext, should create .headers.json file
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
@ -1822,14 +1822,9 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn test_filter_shebang() {
|
fn test_filter_shebang() {
|
||||||
assert_eq!(filter_shebang(b"#!"[..].to_owned()), b"");
|
assert_eq!(filter_shebang(b"#!"[..].to_owned()), b"");
|
||||||
assert_eq!(
|
assert_eq!(filter_shebang(b"#!\n\n"[..].to_owned()), b"\n\n");
|
||||||
filter_shebang("#!\n\n".as_bytes().to_owned()),
|
let code = b"#!/usr/bin/env deno\nconsole.log('hello');\n"[..].to_owned();
|
||||||
"\n\n".as_bytes()
|
assert_eq!(filter_shebang(code), b"\nconsole.log('hello');\n");
|
||||||
);
|
|
||||||
let code = "#!/usr/bin/env deno\nconsole.log('hello');\n"
|
|
||||||
.as_bytes()
|
|
||||||
.to_owned();
|
|
||||||
assert_eq!(filter_shebang(code), "\nconsole.log('hello');\n".as_bytes());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Reference in a new issue