Skip to content

Commit

Permalink
Rename __ to FILL_ME_IN to avoid confusion with underscore.js' _()
Browse files Browse the repository at this point in the history
Signed-off-by: David Laing <[email protected]>
  • Loading branch information
mrdavidlaing committed May 30, 2011
1 parent 6465c2a commit 7fa4fa2
Show file tree
Hide file tree
Showing 12 changed files with 111 additions and 111 deletions.
2 changes: 1 addition & 1 deletion KoansRunner.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<script type="text/javascript" src="lib/underscore-min.js"></script>

<script type="text/javascript" src="lib/__.js"></script>
<script type="text/javascript" src="lib/FILL_ME_IN.js"></script>

<script type="text/javascript" src="koans/AboutExpects.js"></script>
<script type="text/javascript" src="koans/AboutArrays.js"></script>
Expand Down
14 changes: 7 additions & 7 deletions koans/AboutApplyingWhatWeHaveLearnt.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe("About Applying What We Have Learnt", function() {
}
}

expect(productsICanEat.length).toBe(__);
expect(productsICanEat.length).toBe(FILL_ME_IN);
});

it("given I'm allergic to nuts and hate mushrooms, it should find a pizza I can eat (functional)", function () {
Expand All @@ -41,7 +41,7 @@ describe("About Applying What We Have Learnt", function() {

/* solve using filter() & all() / any() */

expect(productsICanEat.length).toBe(__);
expect(productsICanEat.length).toBe(FILL_ME_IN);
});

/*********************************************************************************/
Expand All @@ -55,14 +55,14 @@ describe("About Applying What We Have Learnt", function() {
}
}

expect(sum).toBe(__);
expect(sum).toBe(FILL_ME_IN);
});

it("should add all the natural numbers below 1000 that are multiples of 3 or 5 (functional)", function () {

var sum = __; /* try chaining range() and reduce() */
var sum = FILL_ME_IN; /* try chaining range() and reduce() */

expect(234168).toBe(__);
expect(234168).toBe(FILL_ME_IN);
});

/*********************************************************************************/
Expand All @@ -75,15 +75,15 @@ describe("About Applying What We Have Learnt", function() {
}
}

expect(ingredientCount['mushrooms']).toBe(__);
expect(ingredientCount['mushrooms']).toBe(FILL_ME_IN);
});

it("should count the ingredient occurrence (functional)", function () {
var ingredientCount = { "{ingredient name}": 0 };

/* chain() together map(), flatten() and reduce() */

expect(ingredientCount['mushrooms']).toBe(__);
expect(ingredientCount['mushrooms']).toBe(FILL_ME_IN);
});

/*********************************************************************************/
Expand Down
60 changes: 30 additions & 30 deletions koans/AboutArrays.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ describe("About Arrays", function() {
//We shall contemplate truth by testing reality, via spec expectations.
it("should create arrays", function() {
var emptyArray = [];
expect(typeof(emptyArray)).toBe(__); //A mistake? - http:javascript.crockford.com/remedial.html
expect(emptyArray.length).toBe(__);
expect(typeof(emptyArray)).toBe(FILL_ME_IN); //A mistake? - http:javascript.crockford.com/remedial.html
expect(emptyArray.length).toBe(FILL_ME_IN);

var multiTypeArray = [0, 1, "two", function () { return 3; }, {value1: 4, value2: 5}, [6, 7]];
expect(multiTypeArray[0]).toBe(__);
expect(multiTypeArray[2]).toBe(__);
expect(multiTypeArray[3]()).toBe(__);
expect(multiTypeArray[4].value1).toBe(__);
expect(multiTypeArray[4]["value2"]).toBe(__);
expect(multiTypeArray[5][0]).toBe(__);
expect(multiTypeArray[0]).toBe(FILL_ME_IN);
expect(multiTypeArray[2]).toBe(FILL_ME_IN);
expect(multiTypeArray[3]()).toBe(FILL_ME_IN);
expect(multiTypeArray[4].value1).toBe(FILL_ME_IN);
expect(multiTypeArray[4]["value2"]).toBe(FILL_ME_IN);
expect(multiTypeArray[5][0]).toBe(FILL_ME_IN);
});

it("should understand array literals", function () {
Expand All @@ -23,36 +23,36 @@ describe("About Arrays", function() {
expect(array).toEqual([1]);

array[1] = 2;
expect(array).toEqual([1, __]);
expect(array).toEqual([1, FILL_ME_IN]);

array.push(3);
expect(array).toEqual(__);
expect(array).toEqual(FILL_ME_IN);
});

it("should understand array length", function () {
var fourNumberArray = [1, 2, 3, 4];

expect(fourNumberArray.length).toBe(__);
expect(fourNumberArray.length).toBe(FILL_ME_IN);
fourNumberArray.push(5, 6);
expect(fourNumberArray.length).toBe(__);
expect(fourNumberArray.length).toBe(FILL_ME_IN);

var tenEmptyElementArray = new Array(10);
expect(tenEmptyElementArray.length).toBe(__);
expect(tenEmptyElementArray.length).toBe(FILL_ME_IN);

tenEmptyElementArray.length = 5;
expect(tenEmptyElementArray.length).toBe(__);
expect(tenEmptyElementArray.length).toBe(FILL_ME_IN);
});

it("should slice arrays", function () {
var array = ["peanut", "butter", "and", "jelly"];

expect(array.slice(0, 1)).toEqual(__);
expect(array.slice(0, 2)).toEqual(__);
expect(array.slice(2, 2)).toEqual(__);
expect(array.slice(2, 20)).toEqual(__);
expect(array.slice(3, 0)).toEqual(__);
expect(array.slice(3, 100)).toEqual(__);
expect(array.slice(5, 1)).toEqual(__);
expect(array.slice(0, 1)).toEqual(FILL_ME_IN);
expect(array.slice(0, 2)).toEqual(FILL_ME_IN);
expect(array.slice(2, 2)).toEqual(FILL_ME_IN);
expect(array.slice(2, 20)).toEqual(FILL_ME_IN);
expect(array.slice(3, 0)).toEqual(FILL_ME_IN);
expect(array.slice(3, 100)).toEqual(FILL_ME_IN);
expect(array.slice(5, 1)).toEqual(FILL_ME_IN);
});

it("should know array references", function () {
Expand All @@ -62,36 +62,36 @@ describe("About Arrays", function() {
refArray[1] = "changed in function";
}
passedByReference(array);
expect(array[1]).toBe(__);
expect(array[1]).toBe(FILL_ME_IN);

var assignedArray = array;
assignedArray[5] = "changed in assignedArray";
expect(array[5]).toBe(__);
expect(array[5]).toBe(FILL_ME_IN);

var copyOfArray = array.slice();
copyOfArray[3] = "changed in copyOfArray";
expect(array[3]).toBe(__);
expect(array[3]).toBe(FILL_ME_IN);
});

it("should push and pop", function () {
var array = [1, 2];
array.push(3);

expect(array).toEqual(__);
expect(array).toEqual(FILL_ME_IN);

var poppedValue = array.pop();
expect(poppedValue).toBe(__);
expect(array).toEqual(__);
expect(poppedValue).toBe(FILL_ME_IN);
expect(array).toEqual(FILL_ME_IN);
});

it("should know about shifting arrays", function () {
var array = [1, 2];

array.unshift(3);
expect(array).toEqual(__);
expect(array).toEqual(FILL_ME_IN);

var shiftedValue = array.shift();
expect(shiftedValue).toEqual(__);
expect(array).toEqual(__);
expect(shiftedValue).toEqual(FILL_ME_IN);
expect(array).toEqual(FILL_ME_IN);
});
});
8 changes: 4 additions & 4 deletions koans/AboutExpects.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ describe("About Expects", function() {

//To understand reality, we must compare our expectations against reality.
it("should expect equality", function () {
var expectedValue = __;
var expectedValue = FILL_ME_IN;
var actualValue = 1 + 1;

expect(actualValue === expectedValue).toBeTruthy();
});

//Some ways of asserting equality are better than others.
it("should assert equality a better way", function () {
var expectedValue = __;
var expectedValue = FILL_ME_IN;
var actualValue = 1 + 1;

// toEqual() compares using common sense equality.
Expand All @@ -24,7 +24,7 @@ describe("About Expects", function() {

//Sometimes you need to be really exact about what you "type".
it("should assert equality with ===", function () {
var expectedValue = __;
var expectedValue = FILL_ME_IN;
var actualValue = (1 + 1).toString();

// toBe() will always use === to compare.
Expand All @@ -33,6 +33,6 @@ describe("About Expects", function() {

//Sometimes we will ask you to fill in the values.
it("should have filled in values", function () {
expect(1 + 1).toEqual(__);
expect(1 + 1).toEqual(FILL_ME_IN);
});
});
26 changes: 13 additions & 13 deletions koans/AboutFunctions.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ describe("About Functions", function() {
return a + b;
}

expect(add(1, 2)).toBe(__);
expect(add(1, 2)).toBe(FILL_ME_IN);
});

it("should know internal variables override outer variables", function () {
Expand All @@ -21,9 +21,9 @@ describe("About Functions", function() {
return message;
}

expect(getMessage()).toBe(__);
expect(overrideMessage()).toBe(__);
expect(message).toBe(__);
expect(getMessage()).toBe(FILL_ME_IN);
expect(overrideMessage()).toBe(FILL_ME_IN);
expect(message).toBe(FILL_ME_IN);
});

it("should have lexical scoping", function () {
Expand All @@ -35,7 +35,7 @@ describe("About Functions", function() {
}
return childfunction();
}
expect(parentfunction()).toBe(__);
expect(parentfunction()).toBe(FILL_ME_IN);
});

it("should use lexical scoping to synthesise functions", function () {
Expand All @@ -52,7 +52,7 @@ describe("About Functions", function() {
var increaseBy3 = makeIncreaseByFunction(3);
var increaseBy5 = makeIncreaseByFunction(5);

expect(increaseBy3(10) + increaseBy5(10)).toBe(__);
expect(increaseBy3(10) + increaseBy5(10)).toBe(FILL_ME_IN);
});

it("should allow extra function arguments", function () {
Expand All @@ -62,14 +62,14 @@ describe("About Functions", function() {
return firstArg;
}

expect(returnFirstArg("first", "second", "third")).toBe(__);
expect(returnFirstArg("first", "second", "third")).toBe(FILL_ME_IN);

function returnSecondArg(firstArg, secondArg)
{
return secondArg;
}

expect(returnSecondArg("only give first arg")).toBe(__);
expect(returnSecondArg("only give first arg")).toBe(FILL_ME_IN);

function returnAllArgs()
{
Expand All @@ -80,7 +80,7 @@ describe("About Functions", function() {
return argsArray.join(",");
}

expect(returnAllArgs("first", "second", "third")).toBe(__);
expect(returnAllArgs("first", "second", "third")).toBe(FILL_ME_IN);
});

it("should pass functions as values", function () {
Expand All @@ -94,21 +94,21 @@ describe("About Functions", function() {
};

var praiseSinger = { givePraise: appendRules };
expect(praiseSinger.givePraise("John")).toBe(__);
expect(praiseSinger.givePraise("John")).toBe(FILL_ME_IN);

praiseSinger.givePraise = appendDoubleRules;
expect(praiseSinger.givePraise("Mary")).toBe(__);
expect(praiseSinger.givePraise("Mary")).toBe(FILL_ME_IN);

});

it("should use function body as a string", function () {
var add = new Function("a", "b", "return a + b;");
expect(add(1, 2)).toBe(__);
expect(add(1, 2)).toBe(FILL_ME_IN);

var multiply = function (a, b) {
//An internal comment
return a * b;
};
expect(multiply.toString()).toBe(__);
expect(multiply.toString()).toBe(FILL_ME_IN);
});
});
Loading

0 comments on commit 7fa4fa2

Please sign in to comment.