Skip to content

Commit ffa2837

Browse files
committed
implemented reflection
1 parent b4e0754 commit ffa2837

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

topics/about_reflection.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ var B = function() {
1111
B.prototype = new A();
1212

1313
test("typeof", function() {
14-
equals(typeof({}), __, 'what is the type of an empty object?');
15-
equals(typeof('apple'), __, 'what is the type of a string?');
16-
equals(typeof(-5), __, 'what is the type of -5?');
17-
equals(typeof(false), __, 'what is the type of false?');
14+
equals(typeof({}), "object", 'what is the type of an empty object?');
15+
equals(typeof('apple'), "string", 'what is the type of a string?');
16+
equals(typeof(-5), "number", 'what is the type of -5?');
17+
equals(typeof(false), "boolean", 'what is the type of false?');
1818
});
1919

2020
test("property enumeration", function() {
@@ -25,8 +25,8 @@ test("property enumeration", function() {
2525
keys.push(propertyName);
2626
values.push(person[propertyName]);
2727
}
28-
ok(keys.equalTo(['__','__','__']), 'what are the property names of the object?');
29-
ok(values.equalTo(['__',__,__]), 'what are the property values of the object?');
28+
ok(keys.equalTo(['name','age','unemployed']), 'what are the property names of the object?');
29+
ok(values.equalTo(['Amory Blaine',102,true]), 'what are the property values of the object?');
3030
});
3131

3232
test("hasOwnProperty", function() {
@@ -36,8 +36,8 @@ test("hasOwnProperty", function() {
3636
for (propertyName in b) {
3737
keys.push(propertyName);
3838
}
39-
equals(keys.length, __, 'how many elements are in the keys array?');
40-
deepEqual(keys, [__, __], 'what are the properties of the array?');
39+
equals(keys.length, 2, 'how many elements are in the keys array?');
40+
deepEqual(keys, ["bprop", "aprop"], 'what are the properties of the array?');
4141

4242
// hasOwnProperty returns true if the parameter is a property directly on the object,
4343
// but not if it is a property accessible via the prototype chain.
@@ -47,21 +47,21 @@ test("hasOwnProperty", function() {
4747
ownKeys.push(propertyName);
4848
}
4949
}
50-
equals(ownKeys.length, __, 'how many elements are in the ownKeys array?');
51-
deepEqual(ownKeys, [__], 'what are the own properties of the array?');
50+
equals(ownKeys.length, 1, 'how many elements are in the ownKeys array?');
51+
deepEqual(ownKeys, ["bprop"], 'what are the own properties of the array?');
5252
});
5353

5454
test("constructor property", function () {
5555
var a = new A();
5656
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(b.constructor.name, __, "what is the name of b's constructor?");
57+
equals(typeof(a.constructor), "object", "what is the type of a's constructor?");
58+
equals(a.constructor.name, "constructor" "what is the name of a's constructor?");
59+
equals(b.constructor.name, "constructor", "what is the name of b's constructor?");
6060
});
6161

6262
test("eval", function() {
6363
// eval executes a string
6464
var result = "";
6565
eval("result = 'apple' + ' ' + 'pie'");
66-
equals(result, __, 'what is the value of result?');
66+
equals(result, "apple pie", 'what is the value of result?');
6767
});

0 commit comments

Comments
 (0)