Permalink
Browse files

I'm renaming the files to end in _tests.js instead of _test.js so the…

…y are not mistaken to be tests.

R=chrishenry
DELTA=727 (364 added, 330 deleted, 33 changed)


Revision created by MOE tool push_codebase.
MOE_MIGRATION=6099


git-svn-id: http://closure-library.googlecode.com/svn/trunk@2425 0b95b8e8-c90f-11de-9d4f-f947ee5921c8
  • Loading branch information...
1 parent bd2a9d2 commit b378891fe75fd6375e2d2e9559b8c307363d17d7 gdennis@google.com committed Jan 9, 2013
@@ -17,15 +17,22 @@
*
*/
-goog.provide('goog.crypt.hash_test');
+goog.provide('goog.crypt.hashTester');
goog.require('goog.array');
goog.require('goog.crypt');
+goog.require('goog.testing.PerformanceTable');
+goog.require('goog.testing.PseudoRandom');
goog.require('goog.testing.asserts');
-goog.setTestOnly('hash_test');
+goog.setTestOnly('hashTester');
-goog.crypt.hash_test.runBasicTests = function(hash) {
+/**
+ * Runs basic tests.
+ *
+ * @param {!goog.crypt.Hash} hash A hash instance.
+ */
+goog.crypt.hashTester.runBasicTests = function(hash) {
// Compute first hash.
hash.update([97, 158]);
var golden1 = hash.digest();
@@ -90,7 +97,13 @@ goog.crypt.hash_test.runBasicTests = function(hash) {
};
-goog.crypt.hash_test.runBlockTests = function(hash, blockBytes) {
+/**
+ * Runs block tests.
+ *
+ * @param {!goog.crypt.Hash} hash A hash instance.
+ * @param {number} blockBytes Size of the hash block.
+ */
+goog.crypt.hashTester.runBlockTests = function(hash, blockBytes) {
// Compute a message which is 1 byte shorter than hash block size.
var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
var message = '';
@@ -150,17 +163,22 @@ goog.crypt.hash_test.runBlockTests = function(hash, blockBytes) {
};
-// Run performance tests
-goog.crypt.hash_test.runPerfTests = function(hashFactory, hashName) {
+/**
+ * Runs performance tests.
+ *
+ * @param {function():!goog.crypt.Hash} hashFactory A hash factory.
+ * @param {string} hashName Name of the hashing function.
+ */
+goog.crypt.hashTester.runPerfTests = function(hashFactory, hashName) {
var body = goog.dom.getDocument().body;
var perfTable = goog.dom.createElement('div');
goog.dom.appendChild(body, perfTable);
var table = new goog.testing.PerformanceTable(perfTable);
function runPerfTest(byteLength, updateCount) {
- var label = (hashName + ': ' + updateCount + ' update(s) of ' + byteLength
- + ' bytes');
+ var label = (hashName + ': ' + updateCount + ' update(s) of ' + byteLength +
+ ' bytes');
function run(data, dataType) {
table.run(function() {
@@ -172,8 +190,8 @@ goog.crypt.hash_test.runPerfTests = function(hashFactory, hashName) {
}, label + ' (' + dataType + ')');
}
- var byteArray = goog.crypt.hash_test.createRandomByteArray_(byteLength);
- var byteString = goog.crypt.hash_test.createByteString_(byteArray);
+ var byteArray = goog.crypt.hashTester.createRandomByteArray_(byteLength);
+ var byteString = goog.crypt.hashTester.createByteString_(byteArray);
run(byteArray, 'byte array');
run(byteString, 'byte string');
@@ -188,24 +206,38 @@ goog.crypt.hash_test.runPerfTests = function(hashFactory, hashName) {
};
-goog.crypt.hash_test.createRandomByteArray_ = function(length) {
+/**
+ * Creates and returns a random byte array.
+ *
+ * @param {number} length Length of the byte array.
+ * @return {!Array.<number>} An array of bytes.
+ * @private
+ */
+goog.crypt.hashTester.createRandomByteArray_ = function(length) {
var random = new goog.testing.PseudoRandom(0);
var bytes = [];
for (var i = 0; i < length; ++i) {
// Generates an integer from 0 to 255.
- var byte = Math.floor(random.random() * 0x100);
- bytes.push(byte);
+ var b = Math.floor(random.random() * 0x100);
+ bytes.push(b);
}
return bytes;
};
-goog.crypt.hash_test.createByteString_ = function(bytes) {
+/**
+ * Creates a string from an array of bytes.
+ *
+ * @param {!Array.<number>} bytes An array of bytes.
+ * @return {string} The string encoded by the bytes.
+ * @private
+ */
+goog.crypt.hashTester.createByteString_ = function(bytes) {
var str = '';
- goog.array.forEach(bytes, function(byte) {
- str += String.fromCharCode(byte);
+ goog.array.forEach(bytes, function(b) {
+ str += String.fromCharCode(b);
});
return str;
};
@@ -11,7 +11,7 @@
<title>Closure Unit Tests - goog.crypt.sha1</title>
<script src='../base.js'></script>
<script>
- goog.require('goog.crypt.hash_test');
+ goog.require('goog.crypt.hashTester');
goog.require('goog.crypt.Hmac');
goog.require('goog.crypt.Sha1');
goog.require('goog.testing.jsunit');
@@ -62,7 +62,7 @@
function testBasicOperations() {
var hmac = new goog.crypt.Hmac(new goog.crypt.Sha1(), 'key', 64);
- goog.crypt.hash_test.runBasicTests(hmac);
+ goog.crypt.hashTester.runBasicTests(hmac);
}
function testHmac() {
@@ -14,7 +14,7 @@
<script src="../base.js"></script>
<script>
goog.require('goog.crypt.Md5');
- goog.require('goog.crypt.hash_test')
+ goog.require('goog.crypt.hashTester')
goog.require('goog.testing.PerformanceTable');
goog.require('goog.testing.PseudoRandom');
goog.require('goog.testing.jsunit');
@@ -29,7 +29,7 @@
<script>
function testHashing() {
- goog.crypt.hash_test.runPerfTests(function() {
+ goog.crypt.hashTester.runPerfTests(function() {
return new goog.crypt.Md5();
}, 'MD5');
}
@@ -13,7 +13,7 @@
<script src="../base.js"></script>
<script>
goog.require('goog.crypt');
- goog.require('goog.crypt.hash_test');
+ goog.require('goog.crypt.hashTester');
goog.require('goog.crypt.Md5');
goog.require('goog.testing.jsunit');
</script>
@@ -25,12 +25,12 @@
function testBasicOperations() {
var md5 = new goog.crypt.Md5();
- goog.crypt.hash_test.runBasicTests(md5);
+ goog.crypt.hashTester.runBasicTests(md5);
}
function testBlockOperations() {
var md5 = new goog.crypt.Md5();
- goog.crypt.hash_test.runBlockTests(md5, 64);
+ goog.crypt.hashTester.runBlockTests(md5, 64);
}
function testHashing() {
@@ -14,7 +14,7 @@
<script src="../base.js"></script>
<script>
goog.require('goog.crypt.Sha1');
- goog.require('goog.crypt.hash_test');
+ goog.require('goog.crypt.hashTester');
goog.require('goog.testing.PerformanceTable');
goog.require('goog.testing.PseudoRandom');
goog.require('goog.testing.jsunit');
@@ -30,7 +30,7 @@
<script>
function testHashing() {
- goog.crypt.hash_test.runPerfTests(function() {
+ goog.crypt.hashTester.runPerfTests(function() {
return new goog.crypt.Sha1();
}, 'SHA1');
}
@@ -12,7 +12,7 @@
<script src="../base.js"></script>
<script>
goog.require('goog.crypt');
- goog.require('goog.crypt.hash_test');
+ goog.require('goog.crypt.hashTester');
goog.require('goog.crypt.Sha1');
goog.require('goog.testing.jsunit');
goog.require('goog.userAgent');
@@ -23,12 +23,12 @@
function testBasicOperations() {
var sha1 = new goog.crypt.Sha1();
- goog.crypt.hash_test.runBasicTests(sha1);
+ goog.crypt.hashTester.runBasicTests(sha1);
}
function testBlockOperations() {
var sha1 = new goog.crypt.Sha1();
- goog.crypt.hash_test.runBlockTests(sha1, 64);
+ goog.crypt.hashTester.runBlockTests(sha1, 64);
}
function testHashing() {
@@ -14,7 +14,7 @@
<script src="../base.js"></script>
<script>
goog.require('goog.crypt.Sha224');
- goog.require('goog.crypt.hash_test');
+ goog.require('goog.crypt.hashTester');
goog.require('goog.testing.PerformanceTable');
goog.require('goog.testing.PseudoRandom');
goog.require('goog.testing.jsunit');
@@ -30,7 +30,7 @@
<script>
function testHashing() {
- goog.crypt.hash_test.runPerfTests(function() {
+ goog.crypt.hashTester.runPerfTests(function() {
return new goog.crypt.Sha224();
}, 'SHA224');
}
@@ -12,7 +12,7 @@
<script src="../base.js"></script>
<script>
goog.require('goog.crypt');
- goog.require('goog.crypt.hash_test');
+ goog.require('goog.crypt.hashTester');
goog.require('goog.crypt.Sha224');
goog.require('goog.testing.jsunit');
</script>
@@ -22,7 +22,7 @@
function testBasicOperations() {
var sha224 = new goog.crypt.Sha224();
- goog.crypt.hash_test.runBasicTests(sha224);
+ goog.crypt.hashTester.runBasicTests(sha224);
}
function testHashing() {
@@ -14,7 +14,7 @@
<script src="../base.js"></script>
<script>
goog.require('goog.crypt.Sha256');
- goog.require('goog.crypt.hash_test');
+ goog.require('goog.crypt.hashTester');
goog.require('goog.testing.PerformanceTable');
goog.require('goog.testing.PseudoRandom');
goog.require('goog.testing.jsunit');
@@ -30,7 +30,7 @@
<script>
function testHashing() {
- goog.crypt.hash_test.runPerfTests(function() {
+ goog.crypt.hashTester.runPerfTests(function() {
return new goog.crypt.Sha256();
}, 'SHA256');
}
@@ -12,7 +12,7 @@
<script src="../base.js"></script>
<script>
goog.require('goog.crypt');
- goog.require('goog.crypt.hash_test');
+ goog.require('goog.crypt.hashTester');
goog.require('goog.crypt.Sha256');
goog.require('goog.testing.jsunit');
</script>
@@ -22,7 +22,7 @@
function testBasicOperations() {
var sha256 = new goog.crypt.Sha256();
- goog.crypt.hash_test.runBasicTests(sha256);
+ goog.crypt.hashTester.runBasicTests(sha256);
}
function testHashing() {
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -12,7 +12,7 @@
<title>Closure Unit Tests - goog.storage.mechanism.HTML5LocalStorage</title>
<script src="../../base.js"></script>
<script>
- goog.require('goog.storage.mechanism.iterablemechanism_test');
+ goog.require('goog.storage.mechanism.iterableMechanismTester');
goog.require('goog.storage.mechanism.mechanism_sharing_test');
goog.require('goog.storage.mechanism.mechanism_test');
goog.require('goog.storage.mechanism.HTML5LocalStorage');
@@ -12,7 +12,7 @@
<title>Closure Unit Tests - goog.storage.mechanism.HTML5SessionStorage</title>
<script src="../../base.js"></script>
<script>
- goog.require('goog.storage.mechanism.iterablemechanism_test');
+ goog.require('goog.storage.mechanism.iterableMechanismTester');
goog.require('goog.storage.mechanism.mechanism_sharing_test');
goog.require('goog.storage.mechanism.mechanism_test');
goog.require('goog.storage.mechanism.HTML5SessionStorage');
@@ -12,7 +12,7 @@
<title>Closure Unit Tests - goog.storage.mechanism.IEUserData</title>
<script src="../../base.js"></script>
<script>
- goog.require('goog.storage.mechanism.iterablemechanism_test');
+ goog.require('goog.storage.mechanism.iterableMechanismTester');
goog.require('goog.storage.mechanism.mechanism_separation_test');
goog.require('goog.storage.mechanism.mechanism_sharing_test');
goog.require('goog.storage.mechanism.mechanism_test');
@@ -20,12 +20,12 @@
*
*/
-goog.provide('goog.storage.mechanism.iterablemechanism_test');
+goog.provide('goog.storage.mechanism.iterableMechanismTester');
goog.require('goog.iter.Iterator');
goog.require('goog.storage.mechanism.IterableMechanism');
goog.require('goog.testing.asserts');
-goog.setTestOnly('iterablemechanism_test');
+goog.setTestOnly('iterableMechanismTester');
var mechanism = null;
@@ -12,7 +12,7 @@
<title>Closure Unit Tests - goog.storage.mechanism.mechanismfactory</title>
<script src="../../base.js"></script>
<script>
- goog.require('goog.storage.mechanism.iterablemechanism_test');
+ goog.require('goog.storage.mechanism.iterableMechanismTester');
goog.require('goog.storage.mechanism.mechanism_separation_test');
goog.require('goog.storage.mechanism.mechanism_sharing_test');
goog.require('goog.storage.mechanism.mechanism_test');
@@ -12,7 +12,7 @@
<title>Closure Unit Tests - goog.storage.mechanism.PrefixedMechanism</title>
<script src="../../base.js"></script>
<script>
- goog.require('goog.storage.mechanism.iterablemechanism_test');
+ goog.require('goog.storage.mechanism.iterableMechanismTester');
goog.require('goog.storage.mechanism.mechanism_separation_test');
goog.require('goog.storage.mechanism.mechanism_sharing_test');
goog.require('goog.storage.mechanism.mechanism_test');

0 comments on commit b378891

Please sign in to comment.