Thread: [javascriptlint-commit] SF.net SVN: javascriptlint: [176] trunk/tests
Status: Beta
Brought to you by:
matthiasmiller
From: <mat...@us...> - 2008-03-20 21:38:21
|
Revision: 176 http://javascriptlint.svn.sourceforge.net/javascriptlint/?rev=176&view=rev Author: matthiasmiller Date: 2008-03-20 14:38:16 -0700 (Thu, 20 Mar 2008) Log Message: ----------- tests: fix some more incorrect line positions Modified Paths: -------------- trunk/tests/control_comments/declare.js trunk/tests/errors/unterminated_comment.js trunk/tests/warnings/ambiguous_newline.js trunk/tests/warnings/block_without_braces.js trunk/tests/warnings/empty_statement.js Modified: trunk/tests/control_comments/declare.js =================================================================== --- trunk/tests/control_comments/declare.js 2008-03-20 21:31:06 UTC (rev 175) +++ trunk/tests/control_comments/declare.js 2008-03-20 21:38:16 UTC (rev 176) @@ -1,10 +1,10 @@ /*jsl:option explicit*/ function declare() { window.alert('http://www.javascriptlint.com/'); - /*jsl:declare window*/ + /*jsl:declare window*/ /*warning:redeclared_var*/ /* redeclaration only at local scope */ - var window;/*warning:redeclared_var*/ + var window; var document; /*jsl:declare document*//*warning:redeclared_var*/ } @@ -17,8 +17,8 @@ document.write('<a href="http://www.javascriptlint.com/">JavaScript Lint</a>'); -/*jsl:declare document*/ -function document()/*warning:redeclared_var*/ +/*jsl:declare document*/ /*warning:redeclared_var*/ +function document() { } Modified: trunk/tests/errors/unterminated_comment.js =================================================================== --- trunk/tests/errors/unterminated_comment.js 2008-03-20 21:31:06 UTC (rev 175) +++ trunk/tests/errors/unterminated_comment.js 2008-03-20 21:38:16 UTC (rev 176) @@ -1,8 +1,8 @@ function unterminated_comment() { - /* - This should not produce a syntax error - when ending a multiline-comment like this: - ////////////////////////////////////////////////////////*/ /*warning:nested_comment*/ - - return true; + /* + This should not produce a syntax error + when ending a multiline-comment like this: + ////////////////////////////////////////////////////////*/ /*warning:nested_comment*/ + + return true; } Modified: trunk/tests/warnings/ambiguous_newline.js =================================================================== --- trunk/tests/warnings/ambiguous_newline.js 2008-03-20 21:31:06 UTC (rev 175) +++ trunk/tests/warnings/ambiguous_newline.js 2008-03-20 21:38:16 UTC (rev 176) @@ -218,15 +218,15 @@ + "!"; /*warning:ambiguous_newline*/ /* illegal: ++ */ - b = i++ - || true; /*warning:ambiguous_newline*//*warning:inc_dec_within_stmt*/ + b = i++ /*warning:inc_dec_within_stmt*/ + || true; /*warning:ambiguous_newline*/ /* illegal: -- */ - s = i-- - + " = i"; /*warning:ambiguous_newline*//*warning:inc_dec_within_stmt*/ + s = i-- /*warning:inc_dec_within_stmt*/ + + " = i"; /*warning:ambiguous_newline*/ /* legal */ - if (true) + if (true) /*warning:meaningless_block*/ { i++; } Modified: trunk/tests/warnings/block_without_braces.js =================================================================== --- trunk/tests/warnings/block_without_braces.js 2008-03-20 21:31:06 UTC (rev 175) +++ trunk/tests/warnings/block_without_braces.js 2008-03-20 21:38:16 UTC (rev 176) @@ -5,8 +5,8 @@ if (i) i++; /*warning:block_without_braces*/ - do i--; /*warning:block_without_braces*/ - while (i); + do i--; + while (i); /*warning:block_without_braces*/ for (i = 0; i < 10; i++) i *= 2; /*warning:block_without_braces*/ Modified: trunk/tests/warnings/empty_statement.js =================================================================== --- trunk/tests/warnings/empty_statement.js 2008-03-20 21:31:06 UTC (rev 175) +++ trunk/tests/warnings/empty_statement.js 2008-03-20 21:38:16 UTC (rev 176) @@ -7,16 +7,16 @@ while (false); /*warning:empty_statement*/ while (false) /*jsl:pass*/; /*warning:invalid_pass*//*warning:empty_statement*/ + while (false) { /*warning:empty_statement*/ + } while (false) { - } /*warning:empty_statement*/ - while (false) { /*jsl:pass*/ } /* empty block within for; useless expression */ + for (i = 0; i < 2; i += 1) { /*warning:empty_statement*/ + } for (i = 0; i < 2; i += 1) { - } /*warning:empty_statement*/ - for (i = 0; i < 2; i += 1) { /*jsl:pass*/ } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mat...@us...> - 2008-03-31 14:01:25
|
Revision: 179 http://javascriptlint.svn.sourceforge.net/javascriptlint/?rev=179&view=rev Author: matthiasmiller Date: 2008-03-31 07:01:17 -0700 (Mon, 31 Mar 2008) Log Message: ----------- Use consistent indentation in tests. Modified Paths: -------------- trunk/tests/conf/define.js trunk/tests/conf/legacy_control_comments.js trunk/tests/control_comments/invalid_fallthru.js trunk/tests/html/script_tag_in_js_literal.html trunk/tests/path_resolution/is_a_dir.js trunk/tests/path_resolution/is_a_dir_not_file.js trunk/tests/path_resolution/is_a_file.js trunk/tests/path_resolution/process/error-2.ecmascript trunk/tests/path_resolution/process/error.ecmascript trunk/tests/path_resolution/process/included.ecmascript trunk/tests/run_tests.pl trunk/tests/warnings/default_not_at_end.js trunk/tests/warnings/legacy_cc_not_understood.js trunk/tests/warnings/missing_semicolon.js Modified: trunk/tests/conf/define.js =================================================================== --- trunk/tests/conf/define.js 2008-03-31 13:45:14 UTC (rev 178) +++ trunk/tests/conf/define.js 2008-03-31 14:01:17 UTC (rev 179) @@ -1,8 +1,8 @@ /*conf:+define window*/ /*jsl:option explicit*/ function define() { - window.alert('http://www.javascriptlint.com/'); + window.alert('http://www.javascriptlint.com/'); - /* cannot use document, however */ - document.write('<a href="http://www.javascriptlint.com/">JavaScript Lint</a>'); /*warning:undeclared_identifier*/ + /* cannot use document, however */ + document.write('<a href="http://www.javascriptlint.com/">JavaScript Lint</a>'); /*warning:undeclared_identifier*/ } Modified: trunk/tests/conf/legacy_control_comments.js =================================================================== --- trunk/tests/conf/legacy_control_comments.js 2008-03-31 13:45:14 UTC (rev 178) +++ trunk/tests/conf/legacy_control_comments.js 2008-03-31 14:01:17 UTC (rev 179) @@ -2,7 +2,7 @@ /* Make sure that legacy control comments aren't respected */ function legacy_control_comments() { - /*@ignore@*/ - ; /*warning:empty_statement*/ - /*@end@*/ + /*@ignore@*/ + ; /*warning:empty_statement*/ + /*@end@*/ } Modified: trunk/tests/control_comments/invalid_fallthru.js =================================================================== --- trunk/tests/control_comments/invalid_fallthru.js 2008-03-31 13:45:14 UTC (rev 178) +++ trunk/tests/control_comments/invalid_fallthru.js 2008-03-31 14:01:17 UTC (rev 179) @@ -2,12 +2,12 @@ function invalid_fallthru() { /* mistake - invalid use of fallthru */ /*jsl:fallthru*/ /*warning:invalid_fallthru*/ - var i; + var i; switch (i) { /*jsl:fallthru*/ /*warning:invalid_fallthru*/ case /*jsl:fallthru*/1: /*warning:invalid_fallthru*/ break; default /*jsl:fallthru*/: /*warning:invalid_fallthru*/ - break; + break; } } Modified: trunk/tests/html/script_tag_in_js_literal.html =================================================================== --- trunk/tests/html/script_tag_in_js_literal.html 2008-03-31 13:45:14 UTC (rev 178) +++ trunk/tests/html/script_tag_in_js_literal.html 2008-03-31 14:01:17 UTC (rev 179) @@ -1,13 +1,13 @@ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> <html> <head> - <title>JavaScript Lint Test Page</title> - <script type="text/javascript"><!-- - /* alert the </script> end tag */ - var x = "</script>"; - window.alert(x); - //--> - </script> + <title>JavaScript Lint Test Page</title> + <script type="text/javascript"><!-- + /* alert the </script> end tag */ + var x = "</script>"; + window.alert(x); + //--> + </script> </head> <body> </body> Modified: trunk/tests/path_resolution/is_a_dir.js =================================================================== --- trunk/tests/path_resolution/is_a_dir.js 2008-03-31 13:45:14 UTC (rev 178) +++ trunk/tests/path_resolution/is_a_dir.js 2008-03-31 14:01:17 UTC (rev 179) @@ -1,4 +1,4 @@ /*conf:+process dir/ */ function zero() { - return 0; + return 0; } Modified: trunk/tests/path_resolution/is_a_dir_not_file.js =================================================================== --- trunk/tests/path_resolution/is_a_dir_not_file.js 2008-03-31 13:45:14 UTC (rev 178) +++ trunk/tests/path_resolution/is_a_dir_not_file.js 2008-03-31 14:01:17 UTC (rev 179) @@ -1,4 +1,4 @@ /*conf:+process dir*/ function zero() { - return 0; + return 0; } Modified: trunk/tests/path_resolution/is_a_file.js =================================================================== --- trunk/tests/path_resolution/is_a_file.js 2008-03-31 13:45:14 UTC (rev 178) +++ trunk/tests/path_resolution/is_a_file.js 2008-03-31 14:01:17 UTC (rev 179) @@ -1,4 +1,4 @@ /*conf:+process file*/ function zero() { - return 0; + return 0; } Modified: trunk/tests/path_resolution/process/error-2.ecmascript =================================================================== --- trunk/tests/path_resolution/process/error-2.ecmascript 2008-03-31 13:45:14 UTC (rev 178) +++ trunk/tests/path_resolution/process/error-2.ecmascript 2008-03-31 14:01:17 UTC (rev 179) @@ -1,3 +1,3 @@ function process() { - error! + error! } Modified: trunk/tests/path_resolution/process/error.ecmascript =================================================================== --- trunk/tests/path_resolution/process/error.ecmascript 2008-03-31 13:45:14 UTC (rev 178) +++ trunk/tests/path_resolution/process/error.ecmascript 2008-03-31 14:01:17 UTC (rev 179) @@ -1,3 +1,3 @@ function process() { - error! + error! } Modified: trunk/tests/path_resolution/process/included.ecmascript =================================================================== --- trunk/tests/path_resolution/process/included.ecmascript 2008-03-31 13:45:14 UTC (rev 178) +++ trunk/tests/path_resolution/process/included.ecmascript 2008-03-31 14:01:17 UTC (rev 179) @@ -1,3 +1,3 @@ function zero() { - return 0; + return 0; } Modified: trunk/tests/run_tests.pl =================================================================== --- trunk/tests/run_tests.pl 2008-03-31 13:45:14 UTC (rev 178) +++ trunk/tests/run_tests.pl 2008-03-31 14:01:17 UTC (rev 179) @@ -8,7 +8,7 @@ # require a path to jsl # if (scalar(@ARGV) != 1) { - die("Usage: run_tests.pl <path to jsl>\n"); + die("Usage: run_tests.pl <path to jsl>\n"); } my $jsl_path = File::Spec->rel2abs($ARGV[0]); my $tests_path = $FindBin::Bin; @@ -16,84 +16,84 @@ my $num_tests = 0; my $num_passed = 0; sub TestFile { - /\.(js|htm|html)$/ or return; - my $filename = $_; - my $pretty_name = $File::Find::name; + /\.(js|htm|html)$/ or return; + my $filename = $_; + my $pretty_name = $File::Find::name; - my $conf_file = ".jsl.conf"; + my $conf_file = ".jsl.conf"; - # open the path being validated - open(FILE, $filename) or die("Could not open $filename: $!"); - my @contents = <FILE>; + # open the path being validated + open(FILE, $filename) or die("Could not open $filename: $!"); + my @contents = <FILE>; - # look for special configuration directives - my @conf = grep(s/\/\*conf:(([^*]|(\*[^\/]))*)\*\//\1\n/g, @contents); - open(FILE, ">$conf_file") or die("Could not open configuration file $conf_file: $!"); - print FILE join("",@conf); - close FILE; + # look for special configuration directives + my @conf = grep(s/\/\*conf:(([^*]|(\*[^\/]))*)\*\//\1\n/g, @contents); + open(FILE, ">$conf_file") or die("Could not open configuration file $conf_file: $!"); + print FILE join("",@conf); + close FILE; - my $this_passed = 1; + my $this_passed = 1; - # look for expected configuration error - my @all_conf_errors = grep(s/\/\*conf_error:(([^*]|(\*[^\/]))*)\*\//\1/g, @contents); - my $conf_error; - if (scalar(@all_conf_errors) > 1) { - print "Only one conf_error allowed per script."; - $this_passed = 0; - } - elsif (scalar(@all_conf_errors) == 1) { - $conf_error = $all_conf_errors[0]; - unless ($conf_error) { - print "Missing conf_error text."; - $this_passed = 0; - } - } + # look for expected configuration error + my @all_conf_errors = grep(s/\/\*conf_error:(([^*]|(\*[^\/]))*)\*\//\1/g, @contents); + my $conf_error; + if (scalar(@all_conf_errors) > 1) { + print "Only one conf_error allowed per script."; + $this_passed = 0; + } + elsif (scalar(@all_conf_errors) == 1) { + $conf_error = $all_conf_errors[0]; + unless ($conf_error) { + print "Missing conf_error text."; + $this_passed = 0; + } + } - # run the lint - print "Testing $pretty_name...\n"; - my $results = `$jsl_path --conf $conf_file --process $filename --nologo --nofilelisting --nocontext --nosummary -output-format __LINE__,__ERROR_NAME__`; - my $exit_code = $? >> 8; - unlink $conf_file; - die "Error executing $jsl_path" unless defined $results; + # run the lint + print "Testing $pretty_name...\n"; + my $results = `$jsl_path --conf $conf_file --process $filename --nologo --nofilelisting --nocontext --nosummary -output-format __LINE__,__ERROR_NAME__`; + my $exit_code = $? >> 8; + unlink $conf_file; + die "Error executing $jsl_path" unless defined $results; - if ($conf_error) { - unless ($exit_code == 2) { - print "Expected exit code: $exit_code\n"; - $this_passed = 0; - } - unless (index($results, "configuration error: $conf_error") > 0) { - print "Expected configuration error: $conf_error"; - print "Got configuration error: $results"; - $this_passed = 0; - } - } - elsif ($exit_code == 2) { - print "Usage or configuration error:\n$results"; - $this_passed = 0; - } + if ($conf_error) { + unless ($exit_code == 2) { + print "Expected exit code: $exit_code\n"; + $this_passed = 0; + } + unless (index($results, "configuration error: $conf_error") > 0) { + print "Expected configuration error: $conf_error"; + print "Got configuration error: $results"; + $this_passed = 0; + } + } + elsif ($exit_code == 2) { + print "Usage or configuration error:\n$results"; + $this_passed = 0; + } - foreach my $result (split("\n", $results)) { - my ($line, $error) = split(",", $result); - next unless $error; # for now, skip blank errors (such as inability to open file) + foreach my $result (split("\n", $results)) { + my ($line, $error) = split(",", $result); + next unless $error; # for now, skip blank errors (such as inability to open file) - # some warnings point beyond the end of the file - $line = scalar(@contents) if $line > scalar(@contents); + # some warnings point beyond the end of the file + $line = scalar(@contents) if $line > scalar(@contents); - unless ($contents[$line-1] =~ s/\/\*warning:$error\*\///) { - print "Error in $filename, line $line: $error\n"; - $this_passed = 0; - } - } - for (my $i = 1; $i <= scalar(@contents); $i++) { - if ($contents[$i-1] =~ /\/\*warning:([^*]*)\*\//) { - print "Error in $filename, line $i: no $1 warning\n"; - $this_passed = 0; - } - } - close(FILE); + unless ($contents[$line-1] =~ s/\/\*warning:$error\*\///) { + print "Error in $filename, line $line: $error\n"; + $this_passed = 0; + } + } + for (my $i = 1; $i <= scalar(@contents); $i++) { + if ($contents[$i-1] =~ /\/\*warning:([^*]*)\*\//) { + print "Error in $filename, line $i: no $1 warning\n"; + $this_passed = 0; + } + } + close(FILE); - $num_tests++; - $num_passed++ if $this_passed; + $num_tests++; + $num_passed++ if $this_passed; } # locate all files in the test folder Modified: trunk/tests/warnings/default_not_at_end.js =================================================================== --- trunk/tests/warnings/default_not_at_end.js 2008-03-31 13:45:14 UTC (rev 178) +++ trunk/tests/warnings/default_not_at_end.js 2008-03-31 14:01:17 UTC (rev 179) @@ -4,9 +4,9 @@ /*default case at top*/ switch (i) { - default: - i++; - break; + default: + i++; + break; case 1: /*warning:default_not_at_end*/ return 1; } Modified: trunk/tests/warnings/legacy_cc_not_understood.js =================================================================== --- trunk/tests/warnings/legacy_cc_not_understood.js 2008-03-31 13:45:14 UTC (rev 178) +++ trunk/tests/warnings/legacy_cc_not_understood.js 2008-03-31 14:01:17 UTC (rev 179) @@ -5,5 +5,5 @@ /* illegal - unrecognized */ /*@bogon@*/ /*warning:legacy_cc_not_understood*/ - return; + return; } Modified: trunk/tests/warnings/missing_semicolon.js =================================================================== --- trunk/tests/warnings/missing_semicolon.js 2008-03-31 13:45:14 UTC (rev 178) +++ trunk/tests/warnings/missing_semicolon.js 2008-03-31 14:01:17 UTC (rev 179) @@ -8,12 +8,12 @@ /* missing semicolon after return */ /* missing semicolon after lambda */ function x() { - this.y = function() { return 0 } /*warning:missing_semicolon*/ + this.y = function() { return 0 } /*warning:missing_semicolon*/ } /*warning:missing_semicolon*/ /* missing semicolon after return */ /* missing semicolon after lambda */ x.prototype.z = function() { - return 1 + return 1 } /*warning:missing_semicolon*/ } /*warning:missing_semicolon*/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |