Skip to content

Commit 08c045b

Browse files
committed
Convert equals to equal
equals has been deprecated for a long time.
1 parent b4c1739 commit 08c045b

17 files changed

+107
-106
lines changed

topics/about_arrays.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@ module("About Arrays (topics/about_arrays.js)");
22

33
test("array literal syntax and indexing", function() {
44
var favouriteThings = ["cellar door", 42, true]; // note that array elements do not have to be of the same type
5-
equals(favouriteThings[0], __, 'what is in the first position of the array?');
6-
equals(favouriteThings[1], __, 'what is in the second position of the array?');
7-
equals(favouriteThings[2], __, 'what is in the third position of the array?');
5+
equal(__, favouriteThings[0], 'what is in the first position of the array?');
6+
equal(__, favouriteThings[1], 'what is in the second position of the array?');
7+
equal(__, favouriteThings[2], 'what is in the third position of the array?');
88
});
99

1010
test("array type", function() {
11-
equals(typeof([]), __, 'what is the type of an array?');
11+
equal(__, typeof([]), 'what is the type of an array?');
1212
});
1313

1414
test("length", function() {
1515
var collection = ['a','b','c'];
16-
equals(collection.length, __, 'what is the length of the collection array?');
16+
equal(__, collection.length, 'what is the length of the collection array?');
1717
});
1818

1919
test("splice", function() {
@@ -28,8 +28,8 @@ test("stack methods", function() {
2828
stack.push("first");
2929
stack.push("second");
3030

31-
equals(stack.pop(), __, 'what will be the first value popped off the stack?');
32-
equals(stack.pop(), __, 'what will be the second value popped off the stack?');
31+
equal(__, stack.pop(), 'what will be the first value popped off the stack?');
32+
equal(__, stack.pop(), 'what will be the second value popped off the stack?');
3333
});
3434

3535
test("queue methods", function() {
@@ -38,6 +38,6 @@ test("queue methods", function() {
3838
queue.push("second");
3939
queue.unshift("third");
4040

41-
equals(queue.shift(), "__", 'what will be shifted out first?');
42-
equals(queue.shift(), "__", 'what will be shifted out second?');
41+
equal(__, queue.shift(), 'what will be shifted out first?');
42+
equal(__, queue.shift(), 'what will be shifted out second?');
4343
});

topics/about_asserts.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ test("not ok", function() {
99
ok(__ === false, 'what is a false value?');
1010
});
1111

12-
test("equals", function() {
13-
equals(1+1, __, 'what will satisfy the equals assertion?');
12+
test("equal", function() {
13+
equal(__, 1 + 1, 'what will satisfy the equal assertion?');
1414
});

topics/about_assignment.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ module("About Assignment (topics/about_assignment.js)");
33

44
test("local variables", function() {
55
var temp = __;
6-
equals(1, temp, "Assign a value to the variable temp");
6+
equal(temp, 1, "Assign a value to the variable temp");
77
});
88

99
test("global variables", function() {
10-
temp = 1;
11-
equals(temp, window.__, 'global variables are assigned to the window object');
10+
temp = 1; // Not using var is an example. Always use var in practise.
11+
equal(window.__, temp, 'global variables are assigned to the window object');
1212
});

topics/about_control_structures.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ test("if", function() {
55
if (2 > 0) {
66
isPositive = true;
77
}
8-
equals(isPositive, __, 'what is the value of isPositive?');
8+
equal(__, isPositive, 'what is the value of isPositive?');
99
});
1010

1111
test("for", function() {
1212
var counter = 10;
1313
for (var i = 1; i <= 3; i++) {
1414
counter = counter + i;
1515
}
16-
equals(counter, __, 'what is the value of counter?');
16+
equal(__, counter, 'what is the value of counter?');
1717
});
1818

1919
test("for in", function() {
@@ -27,15 +27,15 @@ test("for in", function() {
2727
for (var property_name in person) {
2828
result = result + property_name;
2929
};
30-
equals(result, __, 'what is the value of result?');
30+
equal(__, result, 'what is the value of result?');
3131
});
3232

3333
test("ternary operator", function() {
3434
var fruit = true ? "apple" : "orange";
35-
equals(fruit, __, 'what is the value of fruit?');
35+
equal(__, fruit, 'what is the value of fruit?');
3636

3737
fruit = false ? "apple" : "orange";
38-
equals(fruit, __, 'now what is the value of fruit?');
38+
equal(__, fruit, 'now what is the value of fruit?');
3939
});
4040

4141
test("switch", function() {
@@ -48,7 +48,7 @@ test("switch", function() {
4848
result = 2;
4949
break;
5050
}
51-
equals(result, __, 'what is the value of result?');
51+
equal(__, result, 'what is the value of result?');
5252
});
5353

5454
test("switch default case", function() {
@@ -64,10 +64,10 @@ test("switch default case", function() {
6464
result = "Merry";
6565
break;
6666
}
67-
equals(result, __, 'what is the value of result?');
67+
equal(__, result, 'what is the value of result?');
6868
});
6969

7070
test("null coalescing", function() {
7171
var result = null || "a value";
72-
equals(result, __, 'what is the value of result?');
72+
equal(__, result, 'what is the value of result?');
7373
});

topics/about_equality.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
module("About Equality (topics/about_equality.js)");
33

44
test("numeric equality", function() {
5-
equals(3 + __, 7, 'hmmmm?');
5+
equal(3 + __, 7, "");
66
});
77

88
test("string equality", function() {
9-
equals("3" + __, "37", "concatenate the strings");
9+
equal("3" + __, "37", "concatenate the strings");
1010
});
1111

1212
test("equality without type coercion", function() {
@@ -18,5 +18,6 @@ test("equality with type coercion", function() {
1818
});
1919

2020
test("string literals", function() {
21-
equals("frankenstein", '__', "quote types are interchangable, but must match.");
21+
equal(__, "frankenstein", "quote types are interchangable, but must match.");
22+
equal(__, 'frankenstein', "quote types can use both single and double quotes.");
2223
});

topics/about_functions_and_closure.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,31 @@ test("defining functions directly", function() {
55
function changeResult() {
66
// the ability to access a variables defined in the same scope as the function is known as 'closure'
77
result = "b";
8-
};
8+
};
99
changeResult();
10-
equals(result, __, 'what is the value of result?');
10+
equal(__, result, 'what is the value of result?');
1111
});
1212

1313
test("assigning functions to variables", function() {
1414
var triple = function(input) {
1515
return input * 3;
1616
};
17-
equals(triple(4), __, 'what is triple 4?');
17+
equal(__, triple(4), 'what is triple 4?');
1818
});
1919

20-
test("self invoking functions", function() {
20+
test("self invoking functions", function() {
2121
var publicValue = "shared";
2222

2323
// self invoking functions are used to provide scoping and to alias variables
2424
(function(pv) {
2525
var secretValue = "password";
26-
equals(pv, __, 'what is the value of pv?');
27-
equals(typeof(secretValue), "__", "is secretValue available in this context?");
28-
equals(typeof(publicValue), "__", "is publicValue available in this context?");
26+
equal(__, pv, 'what is the value of pv?');
27+
equal("__", typeof(secretValue), "is secretValue available in this context?");
28+
equal("__", typeof(publicValue), "is publicValue available in this context?");
2929
})(publicValue);
3030

31-
equals(typeof(secretValue), "__", "is secretValue available in this context?");
32-
equals(typeof(publicValue), "__", "is publicValue available in this context?");
31+
equal("__", typeof(secretValue), "is secretValue available in this context?");
32+
equal("__", typeof(publicValue), "is publicValue available in this context?");
3333
});
3434

3535
test("arguments array", function() {
@@ -42,8 +42,8 @@ test("arguments array", function() {
4242
// __
4343
};
4444

45-
equals(add(1,2,3,4,5), 15, "add 1,2,3,4,5");
46-
equals(add(4,7,-2), 9, "add 4,7,-2");
45+
equal(15, add(1,2,3,4,5), "add 1,2,3,4,5");
46+
equal(9, add(4,7,-2), "add 4,7,-2");
4747
});
4848

4949
test("using call to invoke function",function(){
@@ -57,7 +57,7 @@ test("using call to invoke function",function(){
5757
//function, and the arguments to be sent to the function,multiple arguments are separated by commas.
5858
var result = invokee.call("I am this!", "Where did it come from?");
5959

60-
equals(result,__,"what will the value of invokee's this be?");
60+
equal(__, result, "what will the value of invokee's this be?");
6161
});
6262

6363
test("using apply to invoke function",function(){
@@ -70,6 +70,6 @@ test("using apply to invoke function",function(){
7070
//function and and array of arguments to be passed into the called function.
7171
var result = invokee.apply("I am this!", ["I am arg1","I am arg2"]);
7272

73-
equals(result,__,"what will the value of invokee's this be?");
73+
equal(__, result, "what will the value of invokee's this be?");
7474
});
7575

topics/about_numbers.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ module("About Numbers (topics/about_numbers.js)");
44
test("types", function() {
55
var typeOfIntegers = typeof(6);
66
var typeOfFloats = typeof(3.14159);
7-
equals(typeOfIntegers === typeOfFloats, __, 'are ints and floats the same type?');
8-
equals(typeOfIntegers, __, 'what is the javascript numeric type?');
9-
equals(1.0, __, 'what is a integer number equivalent to 1.0?');
7+
equal(__, typeOfIntegers === typeOfFloats, 'are ints and floats the same type?');
8+
equal(__, typeOfIntegers, 'what is the javascript numeric type?');
9+
equal(__, 1.0, 'what is a integer number equivalent to 1.0?');
1010
});
1111

1212
test("NaN", function() {
1313
var resultOfFailedOperations = 7/'apple';
14-
equals(isNaN(resultOfFailedOperations), __, 'what will satisfy the equals assertion?');
15-
equals(resultOfFailedOperations == NaN, __, 'is NaN == NaN?');
14+
equal(__, isNaN(resultOfFailedOperations), 'what will satisfy the equals assertion?');
15+
equal(__, resultOfFailedOperations == NaN, 'is NaN == NaN?');
1616
});

topics/about_objects.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,32 @@ module("About Objects (topics/about_objects.js)");
33

44
test("object type", function() {
55
var empty_object = {};
6-
equals(typeof(empty_object), __, 'what is the type of an object?');
6+
equal(__, typeof(empty_object), 'what is the type of an object?');
77
});
88

99
test("object literal notation", function() {
1010
var person = {
1111
__:__,
1212
__:__
13-
};
14-
equals(person.name, "Amory Blaine", 'what is the person\'s name?');
15-
equals(person.age, 102, 'what is the person\'s age?');
13+
};
14+
equal("Amory Blaine", person.name, "what is the person's name?");
15+
equal(102, person.age, "what is the person's age?");
1616
});
1717

1818
test("dynamically adding properties", function() {
1919
var person = {};
2020
person.__ = "Amory Blaine";
2121
person.__ = 102;
22-
equals(person.name, "Amory Blaine", 'what is the person\'s name?');
23-
equals(person.age, 102, 'what is the person\'s age?');
22+
equal("Amory Blaine", person.name, "what is the person's name?");
23+
equal(102, person.age, "what is the person's age?");
2424
});
2525

2626
test("adding properties from strings", function() {
2727
var person = {};
2828
person["__"] = "Amory Blaine";
2929
person["__"] = 102;
30-
equals(person.name, "Amory Blaine", 'what is the person\'s name?');
31-
equals(person.age, 102, 'what is the person\'s age?');
30+
equal("Amory Blaine", person.name, "what is the person's name?");
31+
equal(102, person.age, "what is the person's age?");
3232
});
3333

3434
test("adding functions", function() {
@@ -39,5 +39,5 @@ test("adding functions", function() {
3939
return __; // HINT: use the 'this' keyword to refer to the person object.
4040
}
4141
};
42-
equals(person.toString(), "I Amory Blaine am 102 years old.", 'what should the toString function be?');
42+
equal("I Amory Blaine am 102 years old.", person.toString(), "what should the toString function be?");
4343
});

topics/about_operators.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ test("addition", function() {
77
for (var i = 0; i <= 5; i++) {
88
result = result + i;
99
}
10-
equals(result, __, "What is the value of result?");
10+
equal(__, result, "What is the value of result?");
1111
});
1212

1313
test("assignment addition", function() {
@@ -16,23 +16,23 @@ test("assignment addition", function() {
1616
//the code below is just like saying result = result + i; but is more concise
1717
result += i;
1818
}
19-
equals(result, __, "What is the value of result?");
19+
equal(__, result, "What is the value of result?");
2020
});
2121

2222
test("subtraction", function() {
2323
var result = 5;
2424
for (var i = 0; i <= 2; i++) {
2525
result = result - i;
2626
}
27-
equals(result, __, "What is the value of result?");
27+
equal(__, result, "What is the value of result?");
2828
});
2929

3030
test("assignment subtraction", function() {
3131
var result = 5;
3232
for (var i = 0; i <= 2; i++) {
3333
result -= i;
3434
}
35-
equals(result, __, "What is the value of result?");
35+
equal(__, result, "What is the value of result?");
3636
});
3737

3838
//Assignment operators are available for multiplication and division as well
@@ -43,5 +43,5 @@ test("modulus", function() {
4343
var x = 5;
4444
//again this is exactly the same as result = result % x
4545
result %= x;
46-
equals(result, __, "What is the value of result?");
46+
equal(__, result, "What is the value of result?");
4747
});

topics/about_prototypal_inheritance.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Mammal.prototype = {
1616

1717
test("defining a 'class'", function() {
1818
var eric = new Mammal("Eric");
19-
equals(eric.sayHi(), __, 'what will Eric say?');
19+
equal(__, eric.sayHi(), 'what will Eric say?');
2020
});
2121

2222
// add another function to the Mammal 'type' that uses the sayHi function
@@ -26,7 +26,7 @@ Mammal.prototype.favouriteSaying = function() {
2626

2727
test("more functions", function() {
2828
var bobby = new Mammal("Bobby");
29-
equals(bobby.favouriteSaying(), __, "what is Bobby's favourite saying?");
29+
equal(__, bobby.favouriteSaying(), "what is Bobby's favourite saying?");
3030
});
3131

3232
test("calling functions added to a prototype after an object was created", function() {
@@ -36,7 +36,7 @@ test("calling functions added to a prototype after an object was created", funct
3636
};
3737
// the following statement asks the paul object to call a function that was added
3838
// to the Mammal prototype after paul was constructed.
39-
equals(paul.numberOfLettersInName(), __, "how long is Paul's name?");
39+
equal(__, paul.numberOfLettersInName(), "how long is Paul's name?");
4040
});
4141

4242
// helper function for inheritance.
@@ -56,6 +56,6 @@ extend(Bat, Mammal);
5656

5757
test("Inheritance", function() {
5858
var lenny = new Bat("Lenny", "1.5m");
59-
equals(lenny.sayHi(), __, "what does Lenny say?");
60-
equals(lenny.wingspan, __, "what is Lenny's wingspan?");
59+
equal(__, lenny.sayHi(), "what does Lenny say?");
60+
equal(__, lenny.wingspan, "what is Lenny's wingspan?");
6161
});

0 commit comments

Comments
 (0)