workshopper / scope-chains-closures

Javascript Scope Chains And Closures Workshop
ISC License
202 stars 142 forks source link

The closures lesson doesn't validate properly #9

Open Dannnno opened 9 years ago

Dannnno commented 9 years ago

With the following code

function foo () {
    var bar = 2;
    quuz = 13;
    function zip () {
        var quux = 9;
        bar = true;
    }
    return zip;
}

I get the output

not ok 2 The structure is correct
  ---
    operator: equal
    expected:
      '(global)\n\tfoo()\n\t- var bar\n\t- quux = ?\n\treturn zip\n\t\tzip()\n\t\t- var quux\n\t\t- bar = ?'
    actual:
      '(global)\n\tfoo()\n\t- var bar\n\t- quux = ?\n\treturn zip\n\t\tzip()\n\t\t- var quux\n\t\t- bar = ?'
jesstelford commented 9 years ago

You've got a typo on line 3:

quuz = 13

Should be

quux = 13
Dannnno commented 9 years ago

Well... This is embarassing...

Have you considered adding a diff tool to show where the difference is?

jesstelford commented 9 years ago

Yeah, better output is definitely needed. Currently it's just a string comparison and fails if they're not equal.

Do you know of any string diffing tools I could use with tape (the test runner which verifies the solution)?

Dannnno commented 9 years ago

Potentially tap-prettify or tap-difflet?

SomeoneWeird commented 9 years ago

I think the difficulty in diff'ing is that we're basically comparing a simpler AST representation to your solution - which doesn't keep formatting etc.