File indexing completed on 2024-04-28 15:28:37

0001 // Created by Vladimir Olexa  <vladimir.olexa@gmail.com>
0002 
0003 // This tests for caller property in functions. Only functions that
0004 // are called from inside of other functions and have a parent should
0005 // have this property set. Tests return true when caller is found and
0006 // false when the caller is null.
0007 
0008 function child()
0009 {
0010     return child.caller;
0011 }
0012 
0013 function parent()
0014 {
0015     return child();
0016 }
0017 
0018 var childHasCallerWhenCalledFromGlobalCode = (child.caller !== null);
0019 var childHasCallerWhenCalledWithoutParent = (child() !== null);
0020 var childHasCallerWhenCalledFromWithinParent = parent() == parent;
0021 
0022 shouldBe('childHasCallerWhenCalledFromGlobalCode', 'false');
0023 shouldBe('childHasCallerWhenCalledWithoutParent', 'false');
0024 shouldBe('childHasCallerWhenCalledFromWithinParent', 'true')
0025 
0026 var successfullyParsed = true;