Skip to content

Commit 8ff1a11

Browse files
committed
added 'constructor property' test to about_reflection
1 parent cdfda79 commit 8ff1a11

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

topics/about_reflection.js

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
module("About Reflection (topics/about_reflection.js)");
22

3+
var A = function() {
4+
this.aprop = "A";
5+
};
6+
7+
var B = function() {
8+
this.bprop = "B";
9+
};
10+
11+
B.prototype = new A();
12+
313
test("typeof", function() {
414
equals(typeof({}), __, 'what is the type of an empty object?');
515
equals(typeof('apple'), __, 'what is the type of a string?');
@@ -20,17 +30,6 @@ test("property enumeration", function() {
2030
});
2131

2232
test("hasOwnProperty", function() {
23-
24-
var A = function() {
25-
this.aprop = "A";
26-
};
27-
28-
var B = function() {
29-
this.bprop = "B";
30-
};
31-
32-
B.prototype = new A();
33-
3433
var b = new B();
3534

3635
var keys = [];
@@ -52,6 +51,14 @@ test("hasOwnProperty", function() {
5251
ok(ownKeys.equalTo([__, __]), 'what are the own properties of the array?');
5352
});
5453

54+
test("constructor property", function () {
55+
var a = new A();
56+
var b = new B();
57+
equals(typeof(a.constructor), __, "what is the type of a's constructor?");
58+
equals(a.constructor.name, __, "what is the name of a's constructor?");
59+
equals(a.constructor.name, __, "what is the name of b's constructor?");
60+
});
61+
5562
test("eval", function() {
5663
// eval executes a string
5764
var result = "";

0 commit comments

Comments
 (0)