[Pkg-javascript-commits] [node-sha.js] 203/237: vectors: adhere to standard

Bastien Roucariès rouca at moszumanska.debian.org
Fri May 5 09:04:00 UTC 2017


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to branch master
in repository node-sha.js.

commit 5657c76f23e92d268010e0fd5880d5c52014eab2
Author: Daniel Cousens <github at dcousens.com>
Date:   Sat May 30 13:35:11 2015 +1000

    vectors: adhere to standard
---
 test/vectors.js | 27 +++++++++++++--------------
 1 file changed, 13 insertions(+), 14 deletions(-)

diff --git a/test/vectors.js b/test/vectors.js
index e1a65ba..4aef39c 100644
--- a/test/vectors.js
+++ b/test/vectors.js
@@ -1,23 +1,23 @@
-
-var vectors = require('hash-test-vectors')
 var tape = require('tape')
-//var from = require('bops/typedarray/from')
+var vectors = require('hash-test-vectors')
+// var from = require('bops/typedarray/from')
 var Buffer = require('buffer').Buffer
 var hexpp = require('../hexpp')
 
 var createHash = require('../')
 
-function makeTest(alg, i, verbose) {
+function makeTest (alg, i, verbose) {
   var v = vectors[i]
 
   tape(alg + ': NIST vector ' + i, function (t) {
-    if(verbose) {
+    if (verbose) {
       console.log(v)
       console.log('VECTOR', i)
       console.log('INPUT', v.input)
       console.log(hexpp(new Buffer(v.input, 'base64')))
       console.log(new Buffer(v.input, 'base64').toString('hex'))
     }
+
     var buf = new Buffer(v.input, 'base64')
     t.equal(createHash(alg).update(buf).digest('hex'), v[alg])
 
@@ -38,8 +38,8 @@ function makeTest(alg, i, verbose) {
 
     var j, buf3
 
-    i    = ~~(buf.length / 3)
-    j    = ~~(buf.length * 2 / 3)
+    i = ~~(buf.length / 3)
+    j = ~~(buf.length * 2 / 3)
     buf1 = buf.slice(0, i)
     buf2 = buf.slice(i, j)
     buf3 = buf.slice(j, buf.length)
@@ -54,16 +54,17 @@ function makeTest(alg, i, verbose) {
     )
 
     setTimeout(function () {
-      //avoid "too much recursion" errors in tape in firefox
+      // avoid "too much recursion" errors in tape in firefox
       t.end()
     })
   })
 
 }
 
-if(process.argv[2])
-  makeTest(process.argv[2], parseInt(process.argv[3]), true)
-else
+if (process.argv[2]) {
+  makeTest(process.argv[2], parseInt(process.argv[3], 10), true)
+
+} else {
   vectors.forEach(function (v, i) {
     makeTest('sha', i)
     makeTest('sha1', i)
@@ -72,6 +73,4 @@ else
     makeTest('sha384', i)
     makeTest('sha512', i)
   })
-
-
-
+}

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-sha.js.git



More information about the Pkg-javascript-commits mailing list