@@ -8,27 +8,27 @@ $(document).ready(function(){
8
8
// this 'class' pattern defines a class by its constructor
9
9
var Mammal = function ( name ) {
10
10
this . name = name ;
11
- }
11
+ } ;
12
12
// things that don't need to be set in the constructor should be added to the constructor's prototype property.
13
13
Mammal . prototype = {
14
14
sayHi : function ( ) {
15
15
return "Hello, my name is " + this . name ;
16
16
}
17
- }
17
+ } ;
18
18
19
19
test ( "defining a 'class'" , function ( ) {
20
20
var eric = new Mammal ( "Eric" ) ;
21
- equals ( eric . sayHi ( ) , __ , 'what will Eric say?' ) ;
21
+ equals ( eric . sayHi ( ) , "Hello, my name is Eric" , 'what will Eric say?' ) ;
22
22
} ) ;
23
23
24
24
// add another function to the Mammal 'type' that uses the sayHi function
25
25
Mammal . prototype . favouriteSaying = function ( ) {
26
26
return this . name + "'s favourite saying is " + this . sayHi ( ) ;
27
- }
27
+ } ;
28
28
29
29
test ( "more functions" , function ( ) {
30
30
var bobby = new Mammal ( "Bobby" ) ;
31
- equals ( bobby . favouriteSaying ( ) , __ , "what is Bobby's favourite saying?" ) ;
31
+ equals ( bobby . favouriteSaying ( ) , "Bobby's favourite saying is Hello, my name is Bobby" , "what is Bobby's favourite saying?" ) ;
32
32
} ) ;
33
33
34
34
test ( "calling functions added to a prototype after an object was created" , function ( ) {
@@ -37,7 +37,7 @@ $(document).ready(function(){
37
37
return this . name . length ;
38
38
} ;
39
39
// for the following statement asks the paul object to call a function that was added to the Mammal prototype after paul was constructed.
40
- equals ( paul . numberOfLettersInName ( ) , __ , "how long is Paul's name?" ) ;
40
+ equals ( paul . numberOfLettersInName ( ) , 4 , "how long is Paul's name?" ) ;
41
41
} ) ;
42
42
43
43
// helper function for inheritance.
@@ -57,8 +57,8 @@ $(document).ready(function(){
57
57
58
58
test ( "Inheritance" , function ( ) {
59
59
var lenny = new Bat ( "Lenny" , "1.5m" ) ;
60
- equals ( lenny . sayHi ( ) , __ , "what does Lenny say?" ) ;
61
- equals ( lenny . wingspan , __ , "what is Lenny's wingspan?" ) ;
60
+ equals ( lenny . sayHi ( ) , "Hello, my name is Lenny" , "what does Lenny say?" ) ;
61
+ equals ( lenny . wingspan , "1.5m" , "what is Lenny's wingspan?" ) ;
62
62
} ) ;
63
63
64
64
0 commit comments