Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Ill-conceived test wrapper.

  • Loading branch information...
commit 7234da421b1beb5c7b3d40c1415a4eed446f8b48 1 parent 1afb214
Brian J Brennan authored

Showing 2 changed files with 28 additions and 20 deletions. Show diff stats Hide diff stats

  1. +6 0 runner.js
  2. +22 20 test.js
6 runner.js
... ... @@ -0,0 +1,6 @@
  1 +var assert = require("assert");
  2 +
  3 +exports['test'] = function(suite, tests){
  4 + console.log('Running', suite, 'tests');
  5 + tests(assert);
  6 +};
42 test.js
... ... @@ -1,30 +1,32 @@
1   -var assert = require("assert");
  1 +var run = require("./runner");
2 2 var dist = require("./distance");
3 3
4   -assert.equal(dist.hamming('awesome', 'aewsome'), 2);
5   -assert.equal(dist.hamming('a', 'ba'), 2);
6   -assert.equal(dist.hamming('cab', 'abra'), 4);
  4 +run.test('Hamming', function(t){
  5 + t.equal(dist.hamming('awesome', 'aewsome'), 2);
  6 + t.equal(dist.hamming('a', 'ba'), 2);
  7 + t.equal(dist.hamming('cab', 'abra'), 4);
  8 +});
7 9
8   -// tests shameleslly ripped from the wikipedia article
9   -assert.equal(dist.jaro('great', 'great'), 1);
10   -assert.equal(dist.jaro('dicksonx', 'dixon'), (1/3)*(4/5+4/8+1));
11   -assert.equal(dist.jaro('martha', 'marhta'), (1/3)*(1+1+5/6));
12   -assert.equal(dist.jaro('duane', 'dwayne'), (1/3)*(4/6+4/5+1));
13   -assert.equal(dist.jaro('jones', 'johnson'), (1/3)*(4/5+4/7+1));
  10 +run.test("Jaro", function(t){
  11 + // tests shameleslly ripped from the wikipedia article
  12 + t.equal(dist.jaro('great', 'great'), 1);
  13 + t.equal(dist.jaro('dicksonx', 'dixon'), (1/3)*(4/5+4/8+1));
  14 + t.equal(dist.jaro('martha', 'marhta'), (1/3)*(1+1+5/6));
  15 + t.equal(dist.jaro('duane', 'dwayne'), (1/3)*(4/6+4/5+1));
  16 + t.equal(dist.jaro('jones', 'johnson'), (1/3)*(4/5+4/7+1));
  17 +});
14 18
15   -// testing jarowinkler
16   -(function(){
  19 +run.test("Jaro-Winkler", function(t){
17 20 var f = function(distance, prefix) {
18 21 return distance + (prefix * 0.1 * (1 - distance));
19 22 };
20   -
21   - var test = function(str1, str2, prefix){
  23 + var affirm = function(str1, str2, prefix){
22 24 var d = dist.jaro(str1, str2);
23   - assert.equal(dist.jarowinkler(str1, str2), f(d,prefix));
  25 + t.equal(dist.jarowinkler(str1, str2), f(d,prefix));
24 26 };
25 27
26   - test('dicksonx', 'dixon', 2);
27   - test('martha', 'marhta', 3);
28   - test('duane', 'dwayne', 1);
29   - test('jones', 'johnson', 2);
30   -})();
  28 + affirm('dicksonx', 'dixon', 2);
  29 + affirm('martha', 'marhta', 3);
  30 + affirm('duane', 'dwayne', 1);
  31 + affirm('jones', 'johnson', 2);
  32 +});

0 comments on commit 7234da4

Please sign in to comment.
Something went wrong with that request. Please try again.