js/src/tests/test262/ch12/12.9/S12.9_A4.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/tests/test262/ch12/12.9/S12.9_A4.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,28 @@
     1.4 +// Copyright 2009 the Sputnik authors.  All rights reserved.
     1.5 +// This code is governed by the BSD license found in the LICENSE file.
     1.6 +
     1.7 +/**
     1.8 + * The production ReturnStatement : return Expression; is evaluated as:
     1.9 + * i)   Evaluate Expression.
    1.10 + * ii)  Call GetValue(Result(2)).
    1.11 + * iii) Return (return, Result(3), empty)
    1.12 + *
    1.13 + * @path ch12/12.9/S12.9_A4.js
    1.14 + * @description Return very sophisticated expression and function
    1.15 + */
    1.16 +
    1.17 +// second derivative 
    1.18 +function DD_operator(f, delta){return function(x){return (f(x+delta)-2*f(x)+f(x-delta))/(delta*delta)};}
    1.19 +
    1.20 +DDsin = DD_operator(Math.sin, 0.00001);
    1.21 +
    1.22 +
    1.23 +//////////////////////////////////////////////////////////////////////////////
    1.24 +//CHECK#1
    1.25 +// ((sin(x))')' = -sin(x)
    1.26 +if (DDsin( Math.PI/2 ) + Math.sin( Math.PI/2 ) > 0.00001) {
    1.27 +	$ERROR('#1: return Expression yields to Return (return, GetValue(Evaluate Expression), empty)');
    1.28 +}
    1.29 +//
    1.30 +//////////////////////////////////////////////////////////////////////////////
    1.31 +

mercurial