16 lines
387 B
JavaScript
16 lines
387 B
JavaScript
description(
|
|
"Tests that using an argument as a captured variable, in the legitimate sense rather than the function.arguments sense, works as expected."
|
|
);
|
|
|
|
function makeCounter(x) {
|
|
return function() {
|
|
return ++x;
|
|
};
|
|
}
|
|
|
|
for (var i = 0; i < 100; ++i) {
|
|
var counter = makeCounter(i);
|
|
for (var j = 0; j < 10; ++j)
|
|
shouldBe("counter()", "" + (i + j + 1));
|
|
}
|