1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-28 16:20:57 -05:00

add tests

This commit is contained in:
Bartek Iwańczuk 2024-11-07 00:47:21 +01:00
parent 66a152a0ac
commit 336cda567a
No known key found for this signature in database
GPG key ID: 0C6BCDDC3B3AD750
4 changed files with 17 additions and 3 deletions

View file

@ -43,6 +43,7 @@
"tests/specs/fmt",
"tests/specs/lint/bom",
"tests/specs/lint/default_ts",
"tests/specs/lint/minified",
"tests/specs/lint/syntax_error_reporting",
"tests/specs/publish/no_check_surfaces_syntax_error",
"tests/specs/run/default_ts",

View file

@ -14,12 +14,13 @@ impl FileMetrics {
let long_lines_ratio =
self.long_lines_count as f64 / self.total_lines as f64;
(long_lines_ratio > 0.3 || self.whitespace_ratio < 0.05)
&& !(self.has_license_comment && self.total_lines < 5)
(long_lines_ratio >= 0.2 || self.whitespace_ratio < 0.05)
&& !(self.has_license_comment && self.total_lines < 3)
}
}
pub fn analyze_content(content: &str) -> FileMetrics {
const LONG_LINE_LEN: usize = 250;
let mut total_lines = 0;
let mut long_lines_count = 0;
let mut whitespace_count = 0;
@ -73,7 +74,7 @@ pub fn analyze_content(content: &str) -> FileMetrics {
}
// Check line length
if line_buffer.len() > 250 {
if line_buffer.len() > LONG_LINE_LEN {
long_lines_count += 1;
}

View file

@ -0,0 +1,7 @@
{
"tests": {
"args": ["lint", "minified.js"],
"output": "minified.out",
"exitCode": 1
}
}

View file

@ -0,0 +1,5 @@
/*
* Copyright (c) 2024 Example Corp.
* Licensed under MIT License
*/
function f(a,b){return a.concat(b)}var x=function(n){return n+1};function g(a,b){return a.concat(b)}var x=function(n){return n+1};function h(a,b){return a.concat(b)}var x=function(n){return n+1};function i(a,b){return a.concat(b)}var x=function(n){return n+1};function j(a,b){return a.concat(b)}var x=function(n){return n+1};