michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: "use strict"; michael@0: michael@0: let someObject = { michael@0: a: 1, michael@0: func: function() michael@0: { michael@0: this.b = 2; michael@0: } michael@0: }; michael@0: michael@0: let anotherObject = { michael@0: _finalize: function() michael@0: { michael@0: someObject.c = 3; michael@0: } michael@0: }; michael@0: michael@0: function test() { michael@0: ok(TiltUtils, "The TiltUtils object doesn't exist."); michael@0: michael@0: TiltUtils.bindObjectFunc(someObject, "", anotherObject); michael@0: someObject.func(); michael@0: michael@0: is(someObject.a, 1, michael@0: "The bindObjectFunc() messed the non-function members of the object."); michael@0: isnot(someObject.b, 2, michael@0: "The bindObjectFunc() didn't ignore the old scope correctly."); michael@0: is(anotherObject.b, 2, michael@0: "The bindObjectFunc() didn't set the new scope correctly."); michael@0: michael@0: michael@0: TiltUtils.destroyObject(anotherObject); michael@0: is(someObject.c, 3, michael@0: "The finalize function wasn't called when an object was destroyed."); michael@0: michael@0: michael@0: TiltUtils.destroyObject(someObject); michael@0: is(typeof someObject.a, "undefined", michael@0: "Not all members of the destroyed object were deleted."); michael@0: is(typeof someObject.func, "undefined", michael@0: "Not all function members of the destroyed object were deleted."); michael@0: }