Created
February 14, 2009 01:26
-
-
Save davidbody/64206 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> | |
<head> | |
<title>semicolon</title> | |
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.6.0/build/logger/assets/logger.css"/> | |
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.6.0/build/yuitest/assets/testlogger.css"/> | |
<script type="text/javascript" src="http://yui.yahooapis.com/2.6.0/build/yahoo-dom-event/yahoo-dom-event.js"></script> | |
<script type="text/javascript" src="http://yui.yahooapis.com/2.6.0/build/logger/logger-min.js"></script> | |
<script type="text/javascript" src="http://yui.yahooapis.com/2.6.0/build/yuitest/yuitest-min.js"></script> | |
</head> | |
<body class=" yui-skin-sam"> | |
<h1>JavaScript Semicolon Insertion</h1> | |
<p>JavaScript automatically inserts a semicolon at the end of a line if it thinks you need one.</p> | |
<p>Sometimes this is not what you expect or want.</p> | |
<pre> | |
// This function is fine | |
function() { | |
return { | |
status: true | |
}; | |
} | |
// This one isn't | |
function() { | |
return | |
{ | |
status: true | |
}; | |
} | |
</pre> | |
<div id="testLogger"></div> | |
<script type="text/javascript"> | |
YAHOO.namespace("example"); | |
// This function is fine | |
YAHOO.example.good_function = function() { | |
return { | |
status: true | |
}; | |
} | |
// This one isn't | |
YAHOO.example.bad_function = function() { | |
return | |
{ | |
status: true | |
}; | |
} | |
YAHOO.example.SemicolonTestCase = new YAHOO.tool.TestCase({ | |
name: "Semicolon Test Case", | |
testGood : function () { | |
var Assert = YAHOO.util.Assert; | |
Assert.isObject(YAHOO.example.good_function()); | |
}, | |
testBad : function () { | |
var Assert = YAHOO.util.Assert; | |
Assert.isObject(YAHOO.example.bad_function()); | |
} | |
}); | |
YAHOO.example.MyTestSuite = new YAHOO.tool.TestSuite("Test Suite"); | |
YAHOO.example.MyTestSuite.add(YAHOO.example.SemicolonTestCase); | |
YAHOO.util.Event.onDOMReady(function (){ | |
var logger = new YAHOO.tool.TestLogger("testLogger"); | |
YAHOO.tool.TestRunner.add(YAHOO.example.MyTestSuite); | |
YAHOO.tool.TestRunner.run(); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment