Incorrect test lua isbn-verifier

Instructions state to take a number, double every 2nd digit from the right, subtract 9 if >= 10 and add all results and check whether result % 10 is 0.
There however is a test that fails:

it('should check a valid Canadian SIN', function()
    assert.equal(true, luhn.valid('046 454 286'))
  end)

Use instructions:
0 + 8 + 6 + 8 +5 + 8 + 2 + 5 + 6 = 48
So result should be false (48 % 10 ~= 0).

Doubling 8 results in 7 (8*2 = 16; 1 + 6 = 7), not 5

Not only is my math shaky, I also conflated the isbn-verifier exercise with the luhn exercise. Sorry.

1 Like