michael@0: // Copyright 2009 the Sputnik authors. All rights reserved. michael@0: // This code is governed by the BSD license found in the LICENSE file. michael@0: michael@0: /** michael@0: * Closures are admitted michael@0: * michael@0: * @path ch13/13.0/S13_A18.js michael@0: * @description Using a function declaration as a function parameter michael@0: */ michael@0: michael@0: ////////////////////////////////////////////////////////////////////////////// michael@0: //CHECK#1 michael@0: if (typeof sinx !== 'undefined') { michael@0: $ERROR('#1: typeof sinx === \'undefined\'. Actual: typeof sinx ==='+typeof sinx); michael@0: } michael@0: // michael@0: ////////////////////////////////////////////////////////////////////////////// michael@0: michael@0: var __val = function derivative(f, dx) { michael@0: return function(x) { michael@0: return (f(x + dx) - f(x)) / dx; michael@0: }; michael@0: }(function sinx(x){return Math.sin(x);},.0001)(0.5); michael@0: michael@0: ////////////////////////////////////////////////////////////////////////////// michael@0: //CHECK#2 michael@0: if (typeof sinx !== 'undefined') { michael@0: $ERROR('#2: typeof sinx === \'undefined\'. Actual: typeof sinx ==='+typeof sinx); michael@0: } michael@0: // michael@0: ////////////////////////////////////////////////////////////////////////////// michael@0: