Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Git clone of Ilya's #122

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 58 additions & 30 deletions topics/about_arrays.js
Original file line number Diff line number Diff line change
@@ -1,45 +1,73 @@
module("About Arrays (topics/about_arrays.js)");
module('About Arrays (topics/about_arrays.js)');

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

test("array type", function() {
equal(__, typeof([]), 'what is the type of an array?');
test('array type', function () {
equal('object', typeof [], 'what is the type of an array?');
});

test("length", function() {
var collection = ['a','b','c'];
equal(__, collection.length, 'what is the length of the collection array?');
test('length', function () {
var collection = ['a', 'b', 'c'];
equal(3, collection.length, 'what is the length of the collection array?');
});

test("splice", function() {
var daysOfWeek = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];
var workingWeek = daysOfWeek.splice(__, __);
var weekend = daysOfWeek;
test('splice', function () {
var daysOfWeek = [
'Monday',
'Tuesday',
'Wednesday',
'Thursday',
'Friday',
'Saturday',
'Sunday',
];
var workingWeek = daysOfWeek.splice(0, 5);
var weekend = daysOfWeek;

deepEqual(workingWeek, ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'], 'what is the value of workingWeek?');
deepEqual(weekend, ['Saturday', 'Sunday'], 'what is the value of weekend?');
deepEqual(
workingWeek,
['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'],
'what is the value of workingWeek?',
);
deepEqual(weekend, ['Saturday', 'Sunday'], 'what is the value of weekend?');
});

test("stack methods", function() {
var stack = [];
stack.push("first");
stack.push("second");
test('stack methods', function () {
var stack = [];
stack.push('first');
stack.push('second');

equal(__, stack.pop(), 'what will be the first value popped off the stack?');
equal(__, stack.pop(), 'what will be the second value popped off the stack?');
equal(
'second',
stack.pop(),
'what will be the first value popped off the stack?',
);
equal(
'first',
stack.pop(),
'what will be the second value popped off the stack?',
);
});

test("queue methods", function() {
var queue = [];
queue.push("first");
queue.push("second");
queue.unshift("third");
test('queue methods', function () {
var queue = [];
queue.push('first');
queue.push('second');
queue.unshift('third');

equal(__, queue.shift(), 'what will be shifted out first?');
equal(__, queue.shift(), 'what will be shifted out second?');
equal('third', queue.shift(), 'what will be shifted out first?');
equal('first', queue.shift(), 'what will be shifted out second?');
});
15 changes: 7 additions & 8 deletions topics/about_asserts.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
module('About Asserts (topics/about_asserts.js)');

module("About Asserts (topics/about_asserts.js)");

test("ok", function() {
ok(__ === true, 'what will satisfy the ok assertion?');
test('ok', function () {
ok(true === true, 'what will satisfy the ok assertion?');
});

test("not ok", function() {
ok(__ === false, 'what is a false value?');
test('not ok', function () {
ok(false === false, 'what is a false value?');
});

test("equal", function() {
equal(__, 1 + 1, 'what will satisfy the equal assertion?');
test('equal', function () {
equal(2, 1 + 1, 'what will satisfy the equal assertion?');
});
19 changes: 11 additions & 8 deletions topics/about_assignment.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
module('About Assignment (topics/about_assignment.js)');

module("About Assignment (topics/about_assignment.js)");

test("local variables", function() {
var temp = __;
equal(temp, 1, "Assign a value to the variable temp");
test('local variables', function () {
var temp = 1;
equal(temp, 1, 'Assign a value to the variable temp');
});

test("global variables", function() {
temp = 1; // Not using var is an example. Always use var in practise.
equal(window.__, temp, 'global variables are assigned to the window object');
test('global variables', function () {
temp = 1; // Not using var is an example. Always use var in practise.
equal(
window.temp,
temp,
'global variables are assigned to the window object',
);
});
116 changes: 58 additions & 58 deletions topics/about_control_structures.js
Original file line number Diff line number Diff line change
@@ -1,73 +1,73 @@
module("About Control Structures (topics/about_control_structures.js)");
module('About Control Structures (topics/about_control_structures.js)');

test("if", function() {
var isPositive = false;
if (2 > 0) {
isPositive = true;
}
equal(__, isPositive, 'what is the value of isPositive?');
test('if', function () {
var isPositive = false;
if (2 > 0) {
isPositive = true;
}
equal(true, isPositive, 'what is the value of isPositive?');
});

test("for", function() {
var counter = 10;
for (var i = 1; i <= 3; i++) {
counter = counter + i;
}
equal(__, counter, 'what is the value of counter?');
test('for', function () {
var counter = 10;
for (var i = 1; i <= 3; i++) {
counter = counter + i;
}
equal(16, counter, 'what is the value of counter?');
});

test("for in", function() {
// this syntax will be explained in about objects
var person = {
name: "Amory Blaine",
age: 102
};
var result = "";
// for in enumerates the property names of an object
for (var property_name in person) {
result = result + property_name;
}
equal(__, result, 'what is the value of result?');
test('for in', function () {
// this syntax will be explained in about objects
var person = {
name: 'Amory Blaine',
age: 102,
};
var result = '';
// for in enumerates the property names of an object
for (var property_name in person) {
result = result + property_name;
}
equal('nameage', result, 'what is the value of result?');
});

test("ternary operator", function() {
var fruit = true ? "apple" : "orange";
equal(__, fruit, 'what is the value of fruit?');
test('ternary operator', function () {
var fruit = true ? 'apple' : 'orange';
equal('apple', fruit, 'what is the value of fruit?');

fruit = false ? "apple" : "orange";
equal(__, fruit, 'now what is the value of fruit?');
fruit = false ? 'apple' : 'orange';
equal('orange', fruit, 'now what is the value of fruit?');
});

test("switch", function() {
var result = 0;
switch (2) {
case 1:
result = 1;
break;
case 1+1:
result = 2;
break;
}
equal(__, result, 'what is the value of result?');
test('switch', function () {
var result = 0;
switch (2) {
case 1:
result = 1;
break;
case 1 + 1:
result = 2;
break;
}
equal(2, result, 'what is the value of result?');
});

test("switch default case", function() {
var result = "Pippin";
switch ("m") {
case "f":
result = "Frodo";
break;
case "s":
result = "Samwise";
break;
default:
result = "Merry";
break;
}
equal(__, result, 'what is the value of result?');
test('switch default case', function () {
var result = 'Pippin';
switch ('m') {
case 'f':
result = 'Frodo';
break;
case 's':
result = 'Samwise';
break;
default:
result = 'Merry';
break;
}
equal('Merry', result, 'what is the value of result?');
});

test("null coalescing", function() {
var result = null || "a value";
equal(__, result, 'what is the value of result?');
test('null coalescing', function () {
var result = null || 'a value';
equal('a value', result, 'what is the value of result?');
});
33 changes: 20 additions & 13 deletions topics/about_equality.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,30 @@
module('About Equality (topics/about_equality.js)');

module("About Equality (topics/about_equality.js)");

test("numeric equality", function() {
equal(3 + __, 7, "");
test('numeric equality', function () {
equal(3 + 4, 7, '');
});

test("string equality", function() {
equal("3" + __, "37", "concatenate the strings");
test('string equality', function () {
equal('3' + 7, '37', 'concatenate the strings');
});

test("equality without type coercion", function() {
ok(3 === __, 'what is exactly equal to 3?');
test('equality without type coercion', function () {
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?');
test('equality with type coercion', function () {
ok(3 == '3', 'what string is equal to 3, with type coercion?');
});

test("string literals", function() {
equal(__, "frankenstein", "quote types are interchangable, but must match.");
equal(__, 'frankenstein', "quote types can use both single and double quotes.");
test('string literals', function () {
equal(
'frankenstein',
'frankenstein',
'quote types are interchangable, but must match.',
);
equal(
'frankenstein',
'frankenstein',
'quote types can use both single and double quotes.',
);
});
Loading