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: * The production ReturnStatement : return Expression; is evaluated as: michael@0: * i) Evaluate Expression. michael@0: * ii) Call GetValue(Result(2)). michael@0: * iii) Return (return, Result(3), empty) michael@0: * michael@0: * @path ch12/12.9/S12.9_A4.js michael@0: * @description Return very sophisticated expression and function michael@0: */ michael@0: michael@0: // second derivative michael@0: function DD_operator(f, delta){return function(x){return (f(x+delta)-2*f(x)+f(x-delta))/(delta*delta)};} michael@0: michael@0: DDsin = DD_operator(Math.sin, 0.00001); michael@0: michael@0: michael@0: ////////////////////////////////////////////////////////////////////////////// michael@0: //CHECK#1 michael@0: // ((sin(x))')' = -sin(x) michael@0: if (DDsin( Math.PI/2 ) + Math.sin( Math.PI/2 ) > 0.00001) { michael@0: $ERROR('#1: return Expression yields to Return (return, GetValue(Evaluate Expression), empty)'); michael@0: } michael@0: // michael@0: ////////////////////////////////////////////////////////////////////////////// michael@0: