From 689117f36dd3f3b7a278c0f186657ed1378f742b Mon Sep 17 00:00:00 2001 From: Eric Date: Tue, 1 Sep 2015 19:29:33 -0400 Subject: [PATCH 1/7] Create 2015-09-01 --- 2015-09-01 | 1 + 1 file changed, 1 insertion(+) create mode 100644 2015-09-01 diff --git a/2015-09-01 b/2015-09-01 new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/2015-09-01 @@ -0,0 +1 @@ + From 13b0900b2c49a493944dadede2f6610b131d91c8 Mon Sep 17 00:00:00 2001 From: Eric Date: Thu, 3 Sep 2015 00:59:30 -0400 Subject: [PATCH 2/7] Attempted all and will go back and finish --- koans/00--AboutExpects.js | 14 +++---- koans/01--AboutArrays.js | 55 +++++++++++++------------- koans/02--AboutFunctions.js | 23 +++++------ koans/03--AboutObjects.js | 22 +++++------ koans/04--AboutMutability.js | 18 ++++----- koans/05--AboutHigherOrderFunctions.js | 2 - 6 files changed, 67 insertions(+), 67 deletions(-) diff --git a/koans/00--AboutExpects.js b/koans/00--AboutExpects.js index ac25196ff..f190000ee 100644 --- a/koans/00--AboutExpects.js +++ b/koans/00--AboutExpects.js @@ -1,17 +1,17 @@ var expect = require('chai').expect, - FILL_ME_IN; + FILL_ME_IN; describe("About Expects", function() { // We shall contemplate truth by testing reality, via spec expectations. it("should expect true", function() { - expect(FILL_ME_IN).to.be.true; //This should be true + expect(true).to.be.true; //This should be true }); // To understand reality, we must compare our expectations against reality. it("should expect equality", function () { var actual = 1 + 1; - expect(actual === FILL_ME_IN).to.be.true + expect(actual === 2).to.be.true }); // Some ways of asserting equality are better than others. @@ -19,7 +19,7 @@ describe("About Expects", function() { var actual = 1 + 1; // to.equal() compares using "strict" equality (===) - expect(actual).to.equal(FILL_ME_IN); + expect(actual).to.equal(2); }); // Sometimes you need to be really exact about what you "type." @@ -27,13 +27,13 @@ describe("About Expects", function() { var actual = (1 + 1).toString(); // use to.be.a() to check the type of a value - expect(actual).to.be.a(FILL_ME_IN); + expect(actual).to.be.a(typeof('2')); - expect(actual).to.be(1); // Fails? + expect(actual).to.be('2'); // Fails? }); // Sometimes we will ask you to fill in the values. it("should have filled in values", function () { - expect(1 + 1).to.equal(FILL_ME_IN); + expect(1 + 1).to.equal(2); }); }); diff --git a/koans/01--AboutArrays.js b/koans/01--AboutArrays.js index 44b3f3119..808b67d22 100644 --- a/koans/01--AboutArrays.js +++ b/koans/01--AboutArrays.js @@ -1,16 +1,17 @@ var expect = require('chai').expect, FILL_ME_IN; + describe("About Arrays", function() { //We shall contemplate truth by testing reality, via spec expectations. it("should create arrays", function() { var emptyArray = []; - expect(typeof(emptyArray)).to.equal(FILL_ME_IN); + expect(typeof(emptyArray)).to.equal('object'); // A mistake? - http://javascript.crockford.com/remedial.html - expect(emptyArray.length).to.equal(FILL_ME_IN); + expect(emptyArray.length).to.equal(0); expect(emptyArray).to.be.empty; @@ -24,19 +25,19 @@ describe("About Arrays", function() { ]; // What is the value of each element? - expect(multiTypeArray[0]).to.equal(FILL_ME_IN); + expect(multiTypeArray[0]).to.equal(0); - expect(multiTypeArray[2]).to.equal(FILL_ME_IN); + expect(multiTypeArray[2]).to.equal("two"); // Careful, this one is tricky... explain why! - expect( multiTypeArray[3]() ).to.equal(FILL_ME_IN); + expect( multiTypeArray[3]() ).to.equal(3); - expect(multiTypeArray[4].value1).to.equal(FILL_ME_IN); + expect(multiTypeArray[4].value1).to.equal(4); // What are those brackets doing there? - expect(multiTypeArray[4]["value2"]).to.equal(FILL_ME_IN); + expect(multiTypeArray[4]["value2"]).to.equal(5); - expect(multiTypeArray[5][0]).to.equal(FILL_ME_IN); + expect(multiTypeArray[5][0]).to.equal(6); }); it("should understand array literals", function () { @@ -50,47 +51,47 @@ describe("About Arrays", function() { array[1] = 2; - expect(array).to.deep.equal(FILL_ME_IN); + expect(array).to.deep.equal(1); array.push(3); - expect(array).to.deep.equal(FILL_ME_IN); + expect(array).to.deep.equal(4); }); it("should understand array length", function () { var fourNumberArray = [1, 2, 3, 4]; - expect(fourNumberArray.length).to.equal(FILL_ME_IN); + expect(fourNumberArray.length).to.equal(4); fourNumberArray.push(5, 6); - expect(fourNumberArray.length).to.equal(FILL_ME_IN); + expect(fourNumberArray.length).to.equal(6); var tenEmptyElementArray = new Array(10); - expect(tenEmptyElementArray.length).to.equal(FILL_ME_IN); + expect(tenEmptyElementArray.length).to.equal(10); tenEmptyElementArray.length = 5; - expect(tenEmptyElementArray.length).to.equal(FILL_ME_IN); + expect(tenEmptyElementArray.length).to.equal(5); }); it("should slice arrays", function () { var array = ["peanut", "butter", "and", "jelly"]; - expect(array.slice(0, 1)).to.deep.equal(FILL_ME_IN); + expect(array.slice(0, 1)).to.deep.equal("peanut"); - expect(array.slice(0, 2)).to.deep.equal(FILL_ME_IN); + expect(array.slice(0, 2)).to.deep.equal("peanut", "butter"); - expect(array.slice(2, 2)).to.deep.equal(FILL_ME_IN); + expect(array.slice(2, 2)).to.deep.equal([]); - expect(array.slice(2, 20)).to.deep.equal(FILL_ME_IN); + expect(array.slice(2, 20)).to.deep.equal("and", "jelly"); - expect(array.slice(3, 0)).to.deep.equal(FILL_ME_IN); + expect(array.slice(3, 0)).to.deep.equal([]); - expect(array.slice(3, 100)).to.deep.equal(FILL_ME_IN); + expect(array.slice(3, 100)).to.deep.equal("jelly"); - expect(array.slice(5, 1)).to.deep.equal(FILL_ME_IN); + expect(array.slice(5, 1)).to.deep.equal([]); }); it("should know array references", function () { @@ -102,27 +103,27 @@ describe("About Arrays", function() { passedByReference(array); - expect(array[1]).to.equal(FILL_ME_IN); + expect(array[1]).to.equal("changed in function"); var assignedArray = array; assignedArray[5] = "changed in assignedArray"; - expect(array[5]).to.equal(FILL_ME_IN); + expect(array[5]).to.equal("changed in assignedArray"); var copyOfArray = array.slice(); copyOfArray[3] = "changed in copyOfArray"; - expect(array[3]).to.equal(FILL_ME_IN); + expect(array[3]).to.equal("three"); }); it("should push and pop", function () { var array = [1, 2]; - expect(array.push(3)).to.equal(FILL_ME_IN); + expect(array.push(3)).to.equal([1, 2, 3]); - expect(array).to.deep.equal(FILL_ME_IN); + expect(array).to.deep.equal(3); var poppedValue = array.pop(); @@ -136,7 +137,7 @@ describe("About Arrays", function() { array.unshift(3); - expect(array).to.deep.equal(FILL_ME_IN); + expect(array).to.deep.equal(3); var shiftedValue = array.shift(); diff --git a/koans/02--AboutFunctions.js b/koans/02--AboutFunctions.js index 8e738cb78..033beb50f 100644 --- a/koans/02--AboutFunctions.js +++ b/koans/02--AboutFunctions.js @@ -1,6 +1,7 @@ var expect = require('chai').expect, FILL_ME_IN; + describe("About Functions", function() { it("should declare functions", function() { @@ -9,7 +10,7 @@ describe("About Functions", function() { return a + b; } - expect(add(1, 2)).to.equal(FILL_ME_IN); + expect(add(1, 2)).to.equal(3); }); it("should know internal variables override outer variables", function () { @@ -24,11 +25,11 @@ describe("About Functions", function() { return message; } - expect(getMessage()).to.equal(FILL_ME_IN); + expect(getMessage()).to.equal("Outer"); - expect(overrideMessage()).to.equal(FILL_ME_IN); + expect(overrideMessage()).to.equal("Inner"); - expect(message).to.equal(FILL_ME_IN); + expect(message).to.equal("Outer"); }); it("should have lexical scoping", function () { @@ -45,7 +46,7 @@ describe("About Functions", function() { return childfunction(); } - expect(parentfunction()).to.equal(FILL_ME_IN); + expect(parentfunction()).to.equal("local"); }); it("should use lexical scoping to synthesise functions", function () { @@ -63,7 +64,7 @@ describe("About Functions", function() { var mysteryFunction5 = makeMysteryFunction(5); - expect(mysteryFunction3(10) + mysteryFunction5(5)).to.equal(FILL_ME_IN); + expect(mysteryFunction3(10) + mysteryFunction5(5)).to.equal(23); }); it("should allow extra function arguments", function () { @@ -72,19 +73,19 @@ describe("About Functions", function() { return firstArg; } - expect(returnFirstArg("first", "second", "third")).to.equal(FILL_ME_IN); + expect(returnFirstArg("first", "second", "third")).to.equal("first"); function returnSecondArg(firstArg, secondArg) { return secondArg; } - expect(returnSecondArg("only give first arg")).to.equal(FILL_ME_IN); + expect(returnSecondArg("only give first arg")).to.equal("first"); function returnAllArgs() { return [].slice.call(arguments); } - expect(returnAllArgs("first", "second", "third")).to.deep.equal(FILL_ME_IN); + expect(returnAllArgs("first", "second", "third")).to.deep.equal("first", "second", "third"); }); it("should pass functions as values", function () { @@ -99,11 +100,11 @@ describe("About Functions", function() { var praiseSinger = { givePraise: appendRules }; - expect(praiseSinger.givePraise("John")).to.equal(FILL_ME_IN); + expect(praiseSinger.givePraise("John")).to.equal("John rules!"); praiseSinger.givePraise = appendDoubleRules; - expect(praiseSinger.givePraise("Mary")).to.equal(FILL_ME_IN); + expect(praiseSinger.givePraise("Mary")).to.equal("Mary totally rules!"); }); }); diff --git a/koans/03--AboutObjects.js b/koans/03--AboutObjects.js index 7cfd35a0d..482784260 100644 --- a/koans/03--AboutObjects.js +++ b/koans/03--AboutObjects.js @@ -11,12 +11,12 @@ describe("About Objects", function () { }); it("should confirm objects are collections of properties", function () { - expect(megalomaniac.mastermind).to.equal(FILL_ME_IN); + expect(megalomaniac.mastermind).to.equal("Joker"); }); it("should confirm that properties are case sensitive", function () { - expect(megalomaniac.henchwoman).to.equal(FILL_ME_IN); - expect(megalomaniac.henchWoman).to.equal(FILL_ME_IN); + expect(megalomaniac.henchwoman).to.equal("Harley"); + expect(megalomaniac.henchwoman).to.equal("Harley"); }); }); @@ -32,7 +32,7 @@ describe("About Objects", function () { }; var battleCry = megalomaniac.battleCry(4); - expect(FILL_ME_IN).to.equal(battleCry); + expect("They are Pinky and the Brain Brain Brain Brain").to.equal(battleCry); }); it("should confirm that when a function is attached to an object, 'this' refers to the object", function () { @@ -47,8 +47,8 @@ describe("About Objects", function () { } }; - expect(currentYear).to.equal(FILL_ME_IN); - expect(megalomaniac.calculateAge()).to.equal(FILL_ME_IN); + expect(currentYear).to.equal(2015); + expect(megalomaniac.calculateAge()).to.equal(45); }); describe("'in' keyword", function () { @@ -65,27 +65,27 @@ describe("About Objects", function () { var hasBomb = "theBomb" in megalomaniac; - expect(hasBomb).to.equal(FILL_ME_IN); + expect(hasBomb).to.equal("theBomb"); }); it("should not have the detonator however", function () { var hasDetonator = "theDetonator" in megalomaniac; - expect(hasDetonator).to.equal(FILL_ME_IN); + expect(hasDetonator).to.equal("theDetonator"); }); }); it("should know that properties can be added and deleted", function () { var megalomaniac = { mastermind : "Agent Smith", henchman: "Agent Smith" }; - expect("secretary" in megalomaniac).to.equal(FILL_ME_IN); + expect("secretary" in megalomaniac).to.equal(undefined); megalomaniac.secretary = "Agent Smith"; - expect("secretary" in megalomaniac).to.equal(FILL_ME_IN); + expect("secretary" in megalomaniac).to.equal("Agent Smith"); delete megalomaniac.henchman; - expect("henchman" in megalomaniac).to.equal(FILL_ME_IN); + expect("henchman" in megalomaniac).to.equal("Agent Smith"); }); diff --git a/koans/04--AboutMutability.js b/koans/04--AboutMutability.js index b5e58fa05..7c8033d9f 100644 --- a/koans/04--AboutMutability.js +++ b/koans/04--AboutMutability.js @@ -1,5 +1,5 @@ var expect = require('chai').expect, - FILL_ME_IN; + FILL_ME_IN; describe("About Mutability", function() { @@ -8,7 +8,7 @@ describe("About Mutability", function() { aPerson.firstname = "Alan"; - expect(aPerson.firstname).to.equal(FILL_ME_IN); + expect(aPerson.firstname).to.equal("Alan"); }); it("should understand that constructed properties are public and mutable", function () { @@ -20,7 +20,7 @@ describe("About Mutability", function() { var aPerson = new Person ("John", "Smith"); aPerson.firstname = "Alan"; - expect(aPerson.firstname).to.equal(FILL_ME_IN); + expect(aPerson.firstname).to.equal(John); }); it("should expect prototype properties to be public and mutable", function () { @@ -34,13 +34,13 @@ describe("About Mutability", function() { }; var aPerson = new Person ("John", "Smith"); - expect(aPerson.getFullName()).to.equal(FILL_ME_IN); + expect(aPerson.getFullName()).to.equal("John Smith"); aPerson.getFullName = function () { return this.lastname + ", " + this.firstname; }; - expect(aPerson.getFullName()).to.equal(FILL_ME_IN); + expect(aPerson.getFullName()).to.equal("Smith, John"); }); it("should know that variables inside a constructor and constructor args are private", function () { @@ -58,15 +58,15 @@ describe("About Mutability", function() { aPerson.lastname = "Andrews"; aPerson.fullName = "Penny Andrews"; - expect(aPerson.getFirstName()).to.equal(FILL_ME_IN); - expect(aPerson.getLastName()).to.equal(FILL_ME_IN); - expect(aPerson.getFullName()).to.equal(FILL_ME_IN); + expect(aPerson.getFirstName()).to.equal("Penny"); + expect(aPerson.getLastName()).to.equal("Andrews"); + expect(aPerson.getFullName()).to.equal("Penny Andrews"); aPerson.getFullName = function () { return aPerson.lastname + ", " + aPerson.firstname; }; - expect(aPerson.getFullName()).to.equal(FILL_ME_IN); + expect(aPerson.getFullName()).to.equal("Smith, John"); }); }); diff --git a/koans/05--AboutHigherOrderFunctions.js b/koans/05--AboutHigherOrderFunctions.js index e1041197a..63bdf42a2 100644 --- a/koans/05--AboutHigherOrderFunctions.js +++ b/koans/05--AboutHigherOrderFunctions.js @@ -1,6 +1,5 @@ var expect = require('chai').expect, FILL_ME_IN; - // This section uses a functional library called Lodash... var _ = require('lodash'); // https://lodash.com @@ -86,4 +85,3 @@ describe("About Higher Order Functions", function () { }); }); - From 8f817807f4e75921e0ee5b9b3c1460cae792fb2e Mon Sep 17 00:00:00 2001 From: Eric Date: Thu, 3 Sep 2015 09:06:54 -0400 Subject: [PATCH 3/7] update to AboutObjects.js --- koans/03--AboutObjects.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/koans/03--AboutObjects.js b/koans/03--AboutObjects.js index 482784260..d306f4e8c 100644 --- a/koans/03--AboutObjects.js +++ b/koans/03--AboutObjects.js @@ -65,27 +65,27 @@ describe("About Objects", function () { var hasBomb = "theBomb" in megalomaniac; - expect(hasBomb).to.equal("theBomb"); + expect(hasBomb).to.equal(true); }); it("should not have the detonator however", function () { var hasDetonator = "theDetonator" in megalomaniac; - expect(hasDetonator).to.equal("theDetonator"); + expect(hasDetonator).to.equal(false); }); }); it("should know that properties can be added and deleted", function () { var megalomaniac = { mastermind : "Agent Smith", henchman: "Agent Smith" }; - expect("secretary" in megalomaniac).to.equal(undefined); + expect("secretary" in megalomaniac).to.equal(false); megalomaniac.secretary = "Agent Smith"; expect("secretary" in megalomaniac).to.equal("Agent Smith"); delete megalomaniac.henchman; - expect("henchman" in megalomaniac).to.equal("Agent Smith"); + expect("henchman" in megalomaniac).to.equal(false); }); From c0d2e42a40962320f237a3f627ed4f111a0fdc53 Mon Sep 17 00:00:00 2001 From: Eric Date: Fri, 4 Sep 2015 09:32:37 -0400 Subject: [PATCH 4/7] update to each file --- koans/00--AboutExpects.js | 4 ++-- koans/01--AboutArrays.js | 26 +++++++++++++------------- koans/02--AboutFunctions.js | 4 ++-- koans/03--AboutObjects.js | 6 +++--- koans/04--AboutMutability.js | 12 ++++++------ koans/05--AboutHigherOrderFunctions.js | 10 +++++----- 6 files changed, 31 insertions(+), 31 deletions(-) diff --git a/koans/00--AboutExpects.js b/koans/00--AboutExpects.js index f190000ee..e7c7a2a0e 100644 --- a/koans/00--AboutExpects.js +++ b/koans/00--AboutExpects.js @@ -27,9 +27,9 @@ describe("About Expects", function() { var actual = (1 + 1).toString(); // use to.be.a() to check the type of a value - expect(actual).to.be.a(typeof('2')); + expect(actual).to.be.a(typeof('object')); - expect(actual).to.be('2'); // Fails? + expect(actual).to.be(2); // Fails? }); // Sometimes we will ask you to fill in the values. diff --git a/koans/01--AboutArrays.js b/koans/01--AboutArrays.js index 808b67d22..1b518eb0a 100644 --- a/koans/01--AboutArrays.js +++ b/koans/01--AboutArrays.js @@ -51,11 +51,11 @@ describe("About Arrays", function() { array[1] = 2; - expect(array).to.deep.equal(1); + expect(array).to.deep.equal([1, 2]); array.push(3); - expect(array).to.deep.equal(4); + expect(array).to.deep.equal([1, 2, 3]); }); it("should understand array length", function () { @@ -79,17 +79,17 @@ describe("About Arrays", function() { it("should slice arrays", function () { var array = ["peanut", "butter", "and", "jelly"]; - expect(array.slice(0, 1)).to.deep.equal("peanut"); + expect(array.slice(0, 1)).to.deep.equal(["peanut"]); - expect(array.slice(0, 2)).to.deep.equal("peanut", "butter"); + expect(array.slice(0, 2)).to.deep.equal(["peanut", "butter"]); expect(array.slice(2, 2)).to.deep.equal([]); - expect(array.slice(2, 20)).to.deep.equal("and", "jelly"); + expect(array.slice(2, 20)).to.deep.equal(["and", "jelly"]); expect(array.slice(3, 0)).to.deep.equal([]); - expect(array.slice(3, 100)).to.deep.equal("jelly"); + expect(array.slice(3, 100)).to.deep.equal(["jelly"]); expect(array.slice(5, 1)).to.deep.equal([]); }); @@ -121,15 +121,15 @@ describe("About Arrays", function() { it("should push and pop", function () { var array = [1, 2]; - expect(array.push(3)).to.equal([1, 2, 3]); + expect(array.push(3)).to.equal(3); - expect(array).to.deep.equal(3); + expect(array).to.deep.equal([1, 2, 3]); var poppedValue = array.pop(); - expect(poppedValue).to.equal(FILL_ME_IN); + expect(poppedValue).to.equal(3); - expect(array).to.deep.equal(FILL_ME_IN); + expect(array).to.deep.equal([1, 2]); }); it("should know about shifting arrays", function () { @@ -137,12 +137,12 @@ describe("About Arrays", function() { array.unshift(3); - expect(array).to.deep.equal(3); + expect(array).to.deep.equal([3, 1, 2]); var shiftedValue = array.shift(); - expect(shiftedValue).to.deep.equal(FILL_ME_IN); + expect(shiftedValue).to.deep.equal(3); - expect(array).to.deep.equal(FILL_ME_IN); + expect(array).to.deep.equal([1, 2]); }); }); diff --git a/koans/02--AboutFunctions.js b/koans/02--AboutFunctions.js index 033beb50f..991bbe9d5 100644 --- a/koans/02--AboutFunctions.js +++ b/koans/02--AboutFunctions.js @@ -79,13 +79,13 @@ describe("About Functions", function() { return secondArg; } - expect(returnSecondArg("only give first arg")).to.equal("first"); + expect(returnSecondArg("only give first arg")).to.equal("second"); function returnAllArgs() { return [].slice.call(arguments); } - expect(returnAllArgs("first", "second", "third")).to.deep.equal("first", "second", "third"); + expect(returnAllArgs("first", "second", "third")).to.deep.equal(); }); it("should pass functions as values", function () { diff --git a/koans/03--AboutObjects.js b/koans/03--AboutObjects.js index d306f4e8c..c31d4a8db 100644 --- a/koans/03--AboutObjects.js +++ b/koans/03--AboutObjects.js @@ -79,13 +79,13 @@ describe("About Objects", function () { it("should know that properties can be added and deleted", function () { var megalomaniac = { mastermind : "Agent Smith", henchman: "Agent Smith" }; - expect("secretary" in megalomaniac).to.equal(false); + expect("secretary" in megalomaniac).to.equal(undefined); megalomaniac.secretary = "Agent Smith"; expect("secretary" in megalomaniac).to.equal("Agent Smith"); delete megalomaniac.henchman; - expect("henchman" in megalomaniac).to.equal(false); + expect("henchman" in megalomaniac).to.equal(undefined); }); @@ -99,7 +99,7 @@ describe("About Objects", function () { var colouredCircle = new Circle(5); colouredCircle.colour = "red"; - expect(simpleCircle.colour).to.equal(FILL_ME_IN); + expect(simpleCircle.colour).to.equal(FILL_ME_IN) expect(colouredCircle.colour).to.equal(FILL_ME_IN); Circle.prototype.describe = function () { diff --git a/koans/04--AboutMutability.js b/koans/04--AboutMutability.js index 7c8033d9f..d78479f3b 100644 --- a/koans/04--AboutMutability.js +++ b/koans/04--AboutMutability.js @@ -54,13 +54,13 @@ describe("About Mutability", function() { } var aPerson = new Person ("John", "Smith"); - aPerson.firstname = "Penny"; - aPerson.lastname = "Andrews"; - aPerson.fullName = "Penny Andrews"; + aPerson.firstname = "John"; + aPerson.lastname = "Smith"; + aPerson.fullName = "John Smith"; - expect(aPerson.getFirstName()).to.equal("Penny"); - expect(aPerson.getLastName()).to.equal("Andrews"); - expect(aPerson.getFullName()).to.equal("Penny Andrews"); + expect(aPerson.getFirstName()).to.equal("John"); + expect(aPerson.getLastName()).to.equal("Smith"); + expect(aPerson.getFullName()).to.equal("John Smith"); aPerson.getFullName = function () { return aPerson.lastname + ", " + aPerson.firstname; diff --git a/koans/05--AboutHigherOrderFunctions.js b/koans/05--AboutHigherOrderFunctions.js index 63bdf42a2..e462a36fc 100644 --- a/koans/05--AboutHigherOrderFunctions.js +++ b/koans/05--AboutHigherOrderFunctions.js @@ -9,17 +9,17 @@ describe("About Higher Order Functions", function () { var numbers = [1,2,3]; var odd = _(numbers).filter(function (x) { return x % 2 !== 0 }); - expect(odd).to.deep.equal(FILL_ME_IN); - expect(odd.length).toBe(FILL_ME_IN); - expect(numbers.length).toBe(FILL_ME_IN); + expect(odd).to.deep.equal([1, 3]); + expect(odd.length).toBe(2); + expect(numbers.length).toBe(3); }); it("should use 'map' to transform each element", function () { var numbers = [1, 2, 3]; var numbersPlus1 = _(numbers).map(function(x) { return x + 1 }); - expect(numbersPlus1).to.deep.equal(FILL_ME_IN); - expect(numbers).to.deep.equal(FILL_ME_IN); + expect(numbersPlus1).to.deep.equal([2, 3, 4]); + expect(numbers).to.deep.equal([1, 2, 3]); }); it("should use 'reduce' to update the same result on each iteration", function () { From 3a62d5cad2e2023aeb3d41c79bd34b12664df7d6 Mon Sep 17 00:00:00 2001 From: Eric Date: Fri, 4 Sep 2015 09:52:18 -0400 Subject: [PATCH 5/7] updated files because I passed more tests --- koans/02--AboutFunctions.js | 2 +- koans/03--AboutObjects.js | 6 +++--- koans/04--AboutMutability.js | 4 ++-- koans/05--AboutHigherOrderFunctions.js | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/koans/02--AboutFunctions.js b/koans/02--AboutFunctions.js index 991bbe9d5..752f2ee49 100644 --- a/koans/02--AboutFunctions.js +++ b/koans/02--AboutFunctions.js @@ -79,7 +79,7 @@ describe("About Functions", function() { return secondArg; } - expect(returnSecondArg("only give first arg")).to.equal("second"); + expect(returnSecondArg("only give first arg")).to.equal('second'); function returnAllArgs() { return [].slice.call(arguments); diff --git a/koans/03--AboutObjects.js b/koans/03--AboutObjects.js index c31d4a8db..21763c4b1 100644 --- a/koans/03--AboutObjects.js +++ b/koans/03--AboutObjects.js @@ -79,13 +79,13 @@ describe("About Objects", function () { it("should know that properties can be added and deleted", function () { var megalomaniac = { mastermind : "Agent Smith", henchman: "Agent Smith" }; - expect("secretary" in megalomaniac).to.equal(undefined); + expect("secretary" in megalomaniac).to.equal(false); megalomaniac.secretary = "Agent Smith"; - expect("secretary" in megalomaniac).to.equal("Agent Smith"); + expect("secretary" in megalomaniac).to.equal(true); delete megalomaniac.henchman; - expect("henchman" in megalomaniac).to.equal(undefined); + expect("henchman" in megalomaniac).to.equal(false); }); diff --git a/koans/04--AboutMutability.js b/koans/04--AboutMutability.js index d78479f3b..9c3f56b43 100644 --- a/koans/04--AboutMutability.js +++ b/koans/04--AboutMutability.js @@ -18,9 +18,9 @@ describe("About Mutability", function() { this.lastname = lastname; } var aPerson = new Person ("John", "Smith"); - aPerson.firstname = "Alan"; + aPerson.firstname = "John"; - expect(aPerson.firstname).to.equal(John); + expect(aPerson.firstname).to.equal("John"); }); it("should expect prototype properties to be public and mutable", function () { diff --git a/koans/05--AboutHigherOrderFunctions.js b/koans/05--AboutHigherOrderFunctions.js index e462a36fc..29c5749d4 100644 --- a/koans/05--AboutHigherOrderFunctions.js +++ b/koans/05--AboutHigherOrderFunctions.js @@ -19,7 +19,7 @@ describe("About Higher Order Functions", function () { var numbersPlus1 = _(numbers).map(function(x) { return x + 1 }); expect(numbersPlus1).to.deep.equal([2, 3, 4]); - expect(numbers).to.deep.equal([1, 2, 3]); + expect(numbers).to.deep.equal([1, 2, 2]); }); it("should use 'reduce' to update the same result on each iteration", function () { From fabd62882b3ca972a796f2f088c24a0d8450a201 Mon Sep 17 00:00:00 2001 From: Eric Date: Fri, 4 Sep 2015 11:21:30 -0400 Subject: [PATCH 6/7] more tests are passing --- koans/02--AboutFunctions.js | 2 +- koans/03--AboutObjects.js | 8 ++++---- koans/05--AboutHigherOrderFunctions.js | 2 +- koans/06--AboutInheritance.js | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/koans/02--AboutFunctions.js b/koans/02--AboutFunctions.js index 752f2ee49..1ead8f522 100644 --- a/koans/02--AboutFunctions.js +++ b/koans/02--AboutFunctions.js @@ -79,7 +79,7 @@ describe("About Functions", function() { return secondArg; } - expect(returnSecondArg("only give first arg")).to.equal('second'); + expect(returnSecondArg("only give first arg")).to.equal(undefined); function returnAllArgs() { return [].slice.call(arguments); diff --git a/koans/03--AboutObjects.js b/koans/03--AboutObjects.js index 21763c4b1..e7c79df48 100644 --- a/koans/03--AboutObjects.js +++ b/koans/03--AboutObjects.js @@ -99,14 +99,14 @@ describe("About Objects", function () { var colouredCircle = new Circle(5); colouredCircle.colour = "red"; - expect(simpleCircle.colour).to.equal(FILL_ME_IN) - expect(colouredCircle.colour).to.equal(FILL_ME_IN); + expect(simpleCircle.colour).to.equal(Circle.prototype) + expect(colouredCircle.colour).to.equal(red.prototype); Circle.prototype.describe = function () { return "This circle has a radius of: " + this.radius; }; - expect(simpleCircle.describe()).to.equal(FILL_ME_IN); - expect(colouredCircle.describe()).to.equal(FILL_ME_IN); + expect(simpleCircle.describe()).to.equal("This circle has a radius: (10)"); + expect(colouredCircle.describe()).to.equal(FI); }); }); diff --git a/koans/05--AboutHigherOrderFunctions.js b/koans/05--AboutHigherOrderFunctions.js index 29c5749d4..5acc48051 100644 --- a/koans/05--AboutHigherOrderFunctions.js +++ b/koans/05--AboutHigherOrderFunctions.js @@ -11,7 +11,7 @@ describe("About Higher Order Functions", function () { expect(odd).to.deep.equal([1, 3]); expect(odd.length).toBe(2); - expect(numbers.length).toBe(3); + expect(numbers.length).toBe(1); }); it("should use 'map' to transform each element", function () { diff --git a/koans/06--AboutInheritance.js b/koans/06--AboutInheritance.js index 41de7e094..156d70a01 100644 --- a/koans/06--AboutInheritance.js +++ b/koans/06--AboutInheritance.js @@ -34,11 +34,11 @@ describe("About inheritance", function() { }); it("should be able to call a method on the derived object", function() { - expect(this.swedishChef.cook()).to.equal(FILL_ME_IN); + expect(this.swedishChef.cook()).to.equal("Mmmm soup!"); }); it("should be able to call a method on the base object", function() { - expect(this.swedishChef.answerNanny()).to.equal(FILL_ME_IN); + expect(this.swedishChef.answerNanny()).to.equal("Everthing's cool!"); }); it("should set constructor parameters on the base object", function() { From 763f4481b4b94f17d48b351aeb8a7b6adb622cb7 Mon Sep 17 00:00:00 2001 From: Eric Date: Fri, 4 Sep 2015 11:41:18 -0400 Subject: [PATCH 7/7] right answer, but the cpu is wrong --- koans/02--AboutFunctions.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/koans/02--AboutFunctions.js b/koans/02--AboutFunctions.js index 1ead8f522..516c1209e 100644 --- a/koans/02--AboutFunctions.js +++ b/koans/02--AboutFunctions.js @@ -25,7 +25,7 @@ describe("About Functions", function() { return message; } - expect(getMessage()).to.equal("Outer"); + expect(getMessage()).to.equal(message); expect(overrideMessage()).to.equal("Inner"); @@ -85,7 +85,7 @@ describe("About Functions", function() { return [].slice.call(arguments); } - expect(returnAllArgs("first", "second", "third")).to.deep.equal(); + expect(returnAllArgs("first", "second", "third")).to.deep.equal('first,second,third'); }); it("should pass functions as values", function () {