From b1bf05c04fd289e95268396b8b968bb12f21e02a Mon Sep 17 00:00:00 2001 From: Seb Date: Mon, 22 Apr 2013 20:10:46 +0100 Subject: [PATCH 1/4] commit message --- topics/about_asserts.js | 10 +++++----- topics/about_operators.js | 25 +++++++++++++++---------- topics/about_reflection.js | 4 ++-- topics/about_scope.js | 3 ++- 4 files changed, 24 insertions(+), 18 deletions(-) diff --git a/topics/about_asserts.js b/topics/about_asserts.js index f94dde46..2cdf4722 100644 --- a/topics/about_asserts.js +++ b/topics/about_asserts.js @@ -2,13 +2,13 @@ module("About Asserts (topics/about_asserts.js)"); test("ok", function() { - ok(__, 'what will satisfy the ok assertion?'); + ok(true, 'what will satisfy the ok assertion?'); }); test("not", function() { - not(__, 'what is a false value?'); + not(false, 'what is a false value?'); }); -test("equals", function() { - equals(1+1, __, 'what will satisfy the equals assertion?'); -}); +test("equals", function() { + equals(1+1, 2, 'what will satisfy the equals assertion?'); +}); \ No newline at end of file diff --git a/topics/about_operators.js b/topics/about_operators.js index 09df716b..a43b457e 100644 --- a/topics/about_operators.js +++ b/topics/about_operators.js @@ -1,14 +1,17 @@ module("About Operators (topics/about_operators.js)"); -test("addition", function() { +test("addition", + function() { var result = 0; //starting i at 0, add i to result and increment i by 1 until i is equal to 5 for (var i = 0; i <= 5; i++) { - result = result + i; - } - equals(result, __, "What is the value of result?"); -}); + result = result + i; + } + + equals(result, 15, "What is the value of result?"); +} +); test("assignment addition", function() { var result = 0; @@ -16,15 +19,17 @@ test("assignment addition", function() { //the code below is just like saying result = result + i; but is more concise result += i; } - equals(result, __, "What is the value of result?"); + + equals(result, 15, "What is the value of result?"); }); test("subtraction", function() { var result = 5; for (var i = 0; i <= 2; i++) { - result = result - i; + result = result - i; } - equals(result, __, "What is the value of result?"); + + equals(result, 2, "What is the value of result?"); }); test("assignment subtraction", function() { @@ -32,7 +37,7 @@ test("assignment subtraction", function() { for (var i = 0; i <= 2; i++) { result -= i; } - equals(result, __, "What is the value of result?"); + equals(result, 2, "What is the value of result?"); }); //Assignment operators are available for multiplication and division as well @@ -43,5 +48,5 @@ test("modulus", function() { var x = 5; //again this is exactly the same as result = result % x result %= x; - equals(result, __, "What is the value of result?"); + equals(result, 0, "What is the value of result?"); }); diff --git a/topics/about_reflection.js b/topics/about_reflection.js index c75c70f9..30b716c1 100644 --- a/topics/about_reflection.js +++ b/topics/about_reflection.js @@ -37,7 +37,7 @@ test("hasOwnProperty", function() { keys.push(propertyName); } equals(keys.length, __, 'how many elements are in the keys array?'); - deepEqual(keys, [__, __], 'what are the properties of the array?'); + ok(keys.equalTo([__, __]), 'what are the properties of the array?'); // hasOwnProperty returns true if the parameter is a property directly on the object, // but not if it is a property accessible via the prototype chain. @@ -48,7 +48,7 @@ test("hasOwnProperty", function() { } } equals(ownKeys.length, __, 'how many elements are in the ownKeys array?'); - deepEqual(ownKeys, [__], 'what are the own properties of the array?'); + ok(ownKeys.equalTo([__, __]), 'what are the own properties of the array?'); }); test("constructor property", function () { diff --git a/topics/about_scope.js b/topics/about_scope.js index 02e5f70d..3be52396 100644 --- a/topics/about_scope.js +++ b/topics/about_scope.js @@ -1,3 +1,4 @@ + module("About Scope (topics/about_scope.js)"); thisIsAGlobalVariable = 77; @@ -17,5 +18,5 @@ test("variables declared inside of a function", function() { })(); equals(outerVariable, __, 'is outerVariable defined in this scope?'); - equals(typeof(innerVariable), __, 'is innerVariable defined in this scope?'); + equals(typeof(innerVariable), "undefined", 'is innerVariable defined in this scope?'); }); From 337d90dffb1cbd1785d02aed6461647a7f6e4804 Mon Sep 17 00:00:00 2001 From: Seb Date: Mon, 22 Apr 2013 20:14:01 +0100 Subject: [PATCH 2/4] test commit --- topics/about_asserts.js | 10 +++++----- topics/about_operators.js | 25 +++++++++++++++---------- topics/about_reflection.js | 4 ++-- topics/about_scope.js | 3 ++- 4 files changed, 24 insertions(+), 18 deletions(-) diff --git a/topics/about_asserts.js b/topics/about_asserts.js index f94dde46..2cdf4722 100644 --- a/topics/about_asserts.js +++ b/topics/about_asserts.js @@ -2,13 +2,13 @@ module("About Asserts (topics/about_asserts.js)"); test("ok", function() { - ok(__, 'what will satisfy the ok assertion?'); + ok(true, 'what will satisfy the ok assertion?'); }); test("not", function() { - not(__, 'what is a false value?'); + not(false, 'what is a false value?'); }); -test("equals", function() { - equals(1+1, __, 'what will satisfy the equals assertion?'); -}); +test("equals", function() { + equals(1+1, 2, 'what will satisfy the equals assertion?'); +}); \ No newline at end of file diff --git a/topics/about_operators.js b/topics/about_operators.js index 09df716b..a43b457e 100644 --- a/topics/about_operators.js +++ b/topics/about_operators.js @@ -1,14 +1,17 @@ module("About Operators (topics/about_operators.js)"); -test("addition", function() { +test("addition", + function() { var result = 0; //starting i at 0, add i to result and increment i by 1 until i is equal to 5 for (var i = 0; i <= 5; i++) { - result = result + i; - } - equals(result, __, "What is the value of result?"); -}); + result = result + i; + } + + equals(result, 15, "What is the value of result?"); +} +); test("assignment addition", function() { var result = 0; @@ -16,15 +19,17 @@ test("assignment addition", function() { //the code below is just like saying result = result + i; but is more concise result += i; } - equals(result, __, "What is the value of result?"); + + equals(result, 15, "What is the value of result?"); }); test("subtraction", function() { var result = 5; for (var i = 0; i <= 2; i++) { - result = result - i; + result = result - i; } - equals(result, __, "What is the value of result?"); + + equals(result, 2, "What is the value of result?"); }); test("assignment subtraction", function() { @@ -32,7 +37,7 @@ test("assignment subtraction", function() { for (var i = 0; i <= 2; i++) { result -= i; } - equals(result, __, "What is the value of result?"); + equals(result, 2, "What is the value of result?"); }); //Assignment operators are available for multiplication and division as well @@ -43,5 +48,5 @@ test("modulus", function() { var x = 5; //again this is exactly the same as result = result % x result %= x; - equals(result, __, "What is the value of result?"); + equals(result, 0, "What is the value of result?"); }); diff --git a/topics/about_reflection.js b/topics/about_reflection.js index c75c70f9..30b716c1 100644 --- a/topics/about_reflection.js +++ b/topics/about_reflection.js @@ -37,7 +37,7 @@ test("hasOwnProperty", function() { keys.push(propertyName); } equals(keys.length, __, 'how many elements are in the keys array?'); - deepEqual(keys, [__, __], 'what are the properties of the array?'); + ok(keys.equalTo([__, __]), 'what are the properties of the array?'); // hasOwnProperty returns true if the parameter is a property directly on the object, // but not if it is a property accessible via the prototype chain. @@ -48,7 +48,7 @@ test("hasOwnProperty", function() { } } equals(ownKeys.length, __, 'how many elements are in the ownKeys array?'); - deepEqual(ownKeys, [__], 'what are the own properties of the array?'); + ok(ownKeys.equalTo([__, __]), 'what are the own properties of the array?'); }); test("constructor property", function () { diff --git a/topics/about_scope.js b/topics/about_scope.js index 02e5f70d..3be52396 100644 --- a/topics/about_scope.js +++ b/topics/about_scope.js @@ -1,3 +1,4 @@ + module("About Scope (topics/about_scope.js)"); thisIsAGlobalVariable = 77; @@ -17,5 +18,5 @@ test("variables declared inside of a function", function() { })(); equals(outerVariable, __, 'is outerVariable defined in this scope?'); - equals(typeof(innerVariable), __, 'is innerVariable defined in this scope?'); + equals(typeof(innerVariable), "undefined", 'is innerVariable defined in this scope?'); }); From 9dbd6e7645a104bc811a386903c2e7632161e233 Mon Sep 17 00:00:00 2001 From: Seb Date: Mon, 22 Apr 2013 20:31:33 +0100 Subject: [PATCH 3/4] completed about equality --- topics/about_equality.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/topics/about_equality.js b/topics/about_equality.js index 797a653e..82b9905a 100644 --- a/topics/about_equality.js +++ b/topics/about_equality.js @@ -2,21 +2,21 @@ module("About Equality (topics/about_equality.js)"); test("numeric equality", function() { - equals(3 + __, 7, 'hmmmm?'); + equals(3 + 4, 7, 'hmmmm?'); }); test("string equality", function() { - equals("3" + __, "37", "concatenate the strings"); + equals("3" + "7", "37", "concatenate the strings"); }); test("equality without type coercion", function() { - ok(3 === __, 'what is exactly equal to 3?'); + ok(3 === 3, 'what is exactly equal to 3?'); }); test("equality with type coercion", function() { - ok(3 == "__", 'what string is equal to 3, with type coercion?'); + ok(3 == "03", 'what string is equal to 3, with type coercion?'); }); test("string literals", function() { - equals("frankenstein", '__', "quote types are interchangable, but must match."); -}); + equals('frankenstein', "frankenstein", "quote types are interchangable, but must match."); +}); \ No newline at end of file From db629ca34e4179f8d413dd03a7a76e50ded5289c Mon Sep 17 00:00:00 2001 From: Seb Date: Mon, 22 Apr 2013 21:14:23 +0100 Subject: [PATCH 4/4] About control structures --- topics/about_assignment.js | 8 ++++---- topics/about_control_structures.js | 10 +++++----- topics/about_truthyness.js | 10 +++++----- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/topics/about_assignment.js b/topics/about_assignment.js index 3b5c9831..0c4e5d7a 100644 --- a/topics/about_assignment.js +++ b/topics/about_assignment.js @@ -1,12 +1,12 @@ - module("About Assignment (topics/about_assignment.js)"); test("local variables", function() { - var temp = __; + var temp = 1; equals(1, temp, "Assign a value to the variable temp"); }); test("global variables", function() { - temp = 1; - equals(temp, window.__, 'global variables are assigned to the window object'); + temp = 1; + equals(temp, window.temp, 'global variables are assigned to the window object'); }); + diff --git a/topics/about_control_structures.js b/topics/about_control_structures.js index 8d2007df..2dcc52eb 100644 --- a/topics/about_control_structures.js +++ b/topics/about_control_structures.js @@ -5,7 +5,7 @@ test("if", function() { if (2 > 0) { isPositive = true; } - equals(isPositive, __, 'what is the value of isPositive?'); + equals(isPositive, true, 'what is the value of isPositive?'); }); test("for", function() { @@ -13,7 +13,7 @@ test("for", function() { for (var i = 1; i <= 3; i++) { counter = counter + i; } - equals(counter, __, 'what is the value of counter?'); + equals(counter, 16, 'what is the value of counter?'); }); test("for in", function() { @@ -24,10 +24,10 @@ test("for in", function() { }; var result = ""; // for in enumerates the property names of an object - for (property_name in person) { - result = result + property_name; + for (property_name in person) { + result = result + property_name; }; - equals(result, __, 'what is the value of result?'); + equals(result, 'nameage', 'what is the value of result?'); }); test("ternary operator", function() { diff --git a/topics/about_truthyness.js b/topics/about_truthyness.js index 9c3f2319..99db937a 100644 --- a/topics/about_truthyness.js +++ b/topics/about_truthyness.js @@ -2,21 +2,21 @@ module("About Truthyness (topics/about_truthyness.js)"); test("truthyness of positive numbers", function() { - var oneIsTruthy = 1 ? true : false; - equals(oneIsTruthy, __, 'is one truthy?'); + var oneIsTruthy = 1 ? true : false; + equals(oneIsTruthy, true, 'is one truthy?'); }); test("truthyness of negative numbers", function() { var negativeOneIsTruthy = -1 ? true : false; - equals(negativeOneIsTruthy, __, 'is -1 truthy?'); + equals(negativeOneIsTruthy, true, 'is -1 truthy?'); }); test("truthyness of zero", function() { var zeroIsTruthy = 0 ? true : false; - equals(zeroIsTruthy, __, 'is 0 truthy?'); + equals(zeroIsTruthy, false, 'is 0 truthy?'); }); test("truthyness of null", function() { var nullIsTruthy = null ? true : false; - equals(nullIsTruthy, __, 'is null truthy?'); + equals(nullIsTruthy, false, 'is null truthy?'); });