dom Works with codebases that have fallen victim to Greenspan’s 10th Rule. Yes, they have implemented a user customization system. It is “an ad-hoc, informally specified, buggy, and slow implementation of half of Common Lisp”.
Lisp implementations started life as Java backends, but over the years have been ported to Flash apps, iOS, and more recently JavaScript frontends.
While reviewing some tests for the JavaScript parser, Dom realizes that he has doubts about his understanding of JavaScript.
test("Returned objects arguments immutable (a b)", function()
var result = lispParser("(a b)");
expect(3);
ok(typeof(result) === 'object', "result is an object");
var children = result.arguments;
var newValue = 2;
var firstChild = children[0];
if (children[0] == newValue)
firstChild = ++newValue;
notEqual(result.arguments[0], newValue, "Underlying array was immutable");
equal(result.arguments[0], firstChild, "Underlying array was immutable");
);
lispParser
Returns an object representing a syntax tree. This example returns something like this:
"function": "a",
"arguments": [
"function": "b",
"arguments": []
]
So we start by expecting 3
.That’s, uh, usually expect
The function starts a series of assertions. expect(returnValue).toBe(3)
. Here, we only expect three things.there is nothing about 3, we just expect it.
got it. Check if it is an object. That’s great.Then the first argument is (a b)
be equivalent to 2
.Well, it’s not, so we won’t operate on it. firstChild
not at all. Then, if the argument has not changed (it has not), then the test passes and we call the argument immutable.
Apparently someone didn’t understand how references work.They didn’t understand how either lispParser
It worked because there are never any arguments 2
. They wrote unintelligible tests for unintelligible code, but at least the tests look like this: everytime Passed.
Otter – Automatically provision servers without logging into a command prompt. Get started today!