More and more syntax tests

git-svn-id: http://macromates.com/svn/Bundles/trunk/Review/Bundles/JavaScript.tmbundle@10169 dfb7d73b-c2ec-0310-8fea-fb051d288c6d
This commit is contained in:
subtlegradient
2008-07-05 23:42:13 +00:00
committed by Thomas Aylott
parent 1899a8afde
commit a8b22dbdda
2 changed files with 124 additions and 0 deletions
@@ -0,0 +1,62 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>Embedded Javascript Test.html</title>
<style type="text/css" media="screen">
del{color:red;}
ins{color:green;}
</style>
</head>
<body>
1 <a href="#" onclick='var stringName = " </a> SHOULD be scoped as string";'>Link!</a> <br />
2 <a href="#" onclick='var stringName = " </"+"a> SHOULD be scoped as string";'>Link!</a> <br />
3 <a href="#" onclick="var stringName = ' </a> SHOULD be scoped as string';">Link!</a> <br />
4 <a href="#" onclick="var stringName = ' </'+'a> SHOULD be scoped as string';">Link!</a> <br />
5 <script>
"
</script>" </script></ins><br />
6 <script>
" \
</script>" </script></ins><br />
7 <script> " </script>" </script><br />
8 <script> " </scr"+"ipt>" </script><br />
End the string if the /script tag is followed by a newline. Don't if not.
9 <script>
" </script>
" </script>
<br />
10 <script>
' </script>
' </script>
<br />
11 <script>
" </script>"
</script>
<br />
12 <script>
' </script>'
</script>
<br />
<script>
var stringName = "SHOULD be scoped as string
var stringName = "SHOULD be scoped as string
</script>
<script>
var stringName = 'SHOULD be scoped as string
var stringName = 'SHOULD be scoped as string
</script>
</body>
</html>
+62
View File
@@ -92,6 +92,8 @@ funkName(
// =========
// = REGEX =
// =========
// WARNING: regular expressions should be preceded by a left parenthesis, assignment, colon, or comma
var regexName = /regex/
"stringName".match(/regex/)
@@ -190,3 +192,63 @@ x <<= 5
x >>= 5
x >>>= 5
// ===========
// = Strings =
// ===========
var stringName = "";
var stringName = '';
var stringName0 = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";
var stringName1 = "Lorem ipsum dolor sit amet, consectetur adipisicing e" +
"lit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua." +
" Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nis" +
"i ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehen" +
"derit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. E" +
"xcepteur sint occaecat cupidatat non proident, sunt in culpa qui offici" +
"a deserunt mollit anim id est laborum.";
// Allow escaped newline
var stringName2 = "Lorem ipsum dolor sit amet, consectetur adipisicing e\
SHOULD be scoped as string"
var stringName2 = 'Lorem ipsum dolor sit amet, consectetur adipisicing e\
SHOULD be scoped as string'
// First newline should be scoped as constant.character.escape.newline.js
// End string at unescaped newline
// SYNTAX ERROR: unterminated string literal
var stringName3 = "Lorem ipsum dolor sit amet, consectetur adipisicing e
Should NOT be scoped as string"
var stringName3 = 'Lorem ipsum dolor sit amet, consectetur adipisicing e
Should NOT be scoped as string'
// First newline SHOULD be scoped as invalid
var stringName4 = "Lorem ipsum dolor sit amet</script>";
"</script>" SHOULD be scoped as string & invalid.deprecated
var stringName5 = "Lorem ipsum dolor sit amet</script>
"</script>" Should NOT be scoped as string
// WARNING: regular expressions should be preceded by a left parenthesis, assignment, colon, or comma
{unquotedString: null}
{'singleQuotedString': null}// SYNTAX ERROR: invalid label
{"doubleQuotedString": null}// SYNTAX ERROR: invalid label
({'singleQuotedString': null})
({"doubleQuotedString": null})
switch (something){
case "stringName" :
break;
case unquotedString :
break;
case /regex/ :
break;
case 999.999 :
break;
case funkName() :
break;
default :
// do something
}