module("About Reflection (topics/about_reflection.js)");

var A = function() {
    this.aprop = "A";    
};

var B = function() {
    this.bprop = "B";
};

B.prototype = new A();

test("typeof", function() {
    equal(__, typeof({}), 'what is the type of an empty object?');
    equal(__, typeof('apple'), 'what is the type of a string?');
    equal(__, typeof(-5), 'what is the type of -5?');
    equal(__, typeof(false), 'what is the type of false?');		
});

test("property enumeration", function() {
    var keys = [];
    var values = [];
    var person = {name: 'Amory Blaine', age: 102, unemployed: true};
    for(var propertyName in person) {
        keys.push(propertyName);
        values.push(person[propertyName]);
    }
    ok(keys.equalTo(['__','__','__']), 'what are the property names of the object?');
    ok(values.equalTo(['__',__,__]), 'what are the property values of the object?');
});

test("hasOwnProperty", function() {
    var b = new B();
    var propertyName;

    var keys = [];
    for (propertyName in b) {
        keys.push(propertyName);
    }
    equal(__, keys.length, 'how many elements are in the keys array?');
    deepEqual([__, __], keys, 'what are the properties of the array?');

    // hasOwnProperty returns true if the parameter is a property directly on the object, 
    // but not if it is a property accessible via the prototype chain.
    var ownKeys = [];
    for(propertyName in b) {
        if (b.hasOwnProperty(propertyName)) {
            ownKeys.push(propertyName);
        }
    }
    equal(__, ownKeys.length, 'how many elements are in the ownKeys array?');
    deepEqual([__], ownKeys, 'what are the own properties of the array?');
});

test("constructor property", function () {
    var a = new A();
    var b = new B();
    equal(__, typeof(a.constructor), "what is the type of a's constructor?");
    equal(__, a.constructor.name, "what is the name of a's constructor?");    
    equal(__, b.constructor.name, "what is the name of b's constructor?");    
});

test("eval", function() {
    // eval executes a string
    var result = "";
    eval("result = 'apple' + ' ' + 'pie'");
    equal(__, result, 'what is the value of result?');
});

@@ -203,34 +203,40 @@
 n() %7B%0A    equal(
-__
+%22object%22
 , typeof(%7B%7D), 'w
@@ -276,34 +276,40 @@
 t?');%0A    equal(
-__
+%22string%22
 , typeof('apple'
@@ -347,34 +347,40 @@
 g?');%0A    equal(
-__
+%22number%22
 , typeof(-5), 'w
@@ -407,34 +407,41 @@
 5?');%0A    equal(
-__
+%22boolean%22
 , typeof(false),
@@ -776,20 +776,31 @@
 o(%5B'
-__','__','__
+name','age','unemployed
 '%5D),
@@ -875,17 +875,30 @@
 o(%5B'
-__',__,__
+Amory Blaine',102,true
 %5D), 
@@ -1128,18 +1128,17 @@
   equal(
-__
+2
 , keys.l
@@ -1208,14 +1208,24 @@
 al(%5B
-__, __
+%22bprop%22, %22aprop%22
 %5D, k
@@ -1597,18 +1597,17 @@
   equal(
-__
+1
 , ownKey
@@ -1679,18 +1679,23 @@
 pEqual(%5B
-__
+%22bprop%22
 %5D, ownKe
@@ -1844,18 +1844,26 @@
   equal(
-__
+%22function%22
 , typeof
@@ -1930,18 +1930,18 @@
   equal(
-__
+%22%22
 , a.cons
@@ -2009,18 +2009,18 @@
   equal(
-__
+%22%22
 , b.cons
@@ -2218,10 +2218,19 @@
 ual(
-__
+%22apple pie%22
 , re
@@ -2263,17 +2263,16 @@
 f result?');%0A%7D);
-%0A

Resolve about reflection