2007-06-06 16:10:16 +00:00
|
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
|
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
|
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
|
|
|
<head>
|
|
|
|
<title>Prototype Unit test file</title>
|
|
|
|
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
|
|
|
<script src="../../dist/prototype.js" type="text/javascript"></script>
|
|
|
|
<script src="../lib/unittest.js" type="text/javascript"></script>
|
|
|
|
<link rel="stylesheet" href="../test.css" type="text/css" />
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<h1>Prototype Unit test file</h1>
|
|
|
|
<p>
|
|
|
|
Test of utility functions in number.js
|
|
|
|
</p>
|
|
|
|
|
|
|
|
<!-- Log output -->
|
|
|
|
<div id="testlog"> </div>
|
|
|
|
|
|
|
|
<!-- Tests follow -->
|
|
|
|
<script type="text/javascript" language="javascript" charset="utf-8">
|
|
|
|
// <![CDATA[
|
|
|
|
|
|
|
|
new Test.Unit.Runner({
|
|
|
|
|
2008-03-16 18:53:51 +00:00
|
|
|
testNumberMathMethods: function() {
|
|
|
|
this.assertEqual(1, (0.9).round());
|
|
|
|
this.assertEqual(-2, (-1.9).floor());
|
|
|
|
this.assertEqual(-1, (-1.9).ceil());
|
2007-06-06 16:10:16 +00:00
|
|
|
|
2008-03-16 18:53:51 +00:00
|
|
|
$w('abs floor round ceil').each(function(method) {
|
|
|
|
this.assertEqual(Math[method](Math.PI), Math.PI[method]());
|
|
|
|
}, this);
|
|
|
|
},
|
2007-06-06 16:10:16 +00:00
|
|
|
|
2008-03-16 18:53:51 +00:00
|
|
|
testNumberToColorPart: function() {
|
|
|
|
this.assertEqual('00', (0).toColorPart());
|
|
|
|
this.assertEqual('0a', (10).toColorPart());
|
|
|
|
this.assertEqual('ff', (255).toColorPart());
|
|
|
|
},
|
2007-06-06 16:10:16 +00:00
|
|
|
|
2008-03-16 18:53:51 +00:00
|
|
|
testNumberToPaddedString: function() {
|
|
|
|
this.assertEqual('00', (0).toPaddedString(2, 16));
|
|
|
|
this.assertEqual('0a', (10).toPaddedString(2, 16));
|
|
|
|
this.assertEqual('ff', (255).toPaddedString(2, 16));
|
|
|
|
this.assertEqual('000', (0).toPaddedString(3));
|
|
|
|
this.assertEqual('010', (10).toPaddedString(3));
|
|
|
|
this.assertEqual('100', (100).toPaddedString(3));
|
|
|
|
this.assertEqual('1000', (1000).toPaddedString(3));
|
|
|
|
},
|
2007-06-06 16:10:16 +00:00
|
|
|
|
2008-03-16 18:53:51 +00:00
|
|
|
testNumberToJSON: function() {
|
|
|
|
this.assertEqual('null', Number.NaN.toJSON());
|
|
|
|
this.assertEqual('0', (0).toJSON());
|
|
|
|
this.assertEqual('-293', (-293).toJSON());
|
|
|
|
}
|
2007-06-06 16:10:16 +00:00
|
|
|
|
2008-01-06 00:34:39 +00:00
|
|
|
});
|
2007-06-06 16:10:16 +00:00
|
|
|
|
|
|
|
// ]]>
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|