|
1 // Copyright 2009 the Sputnik authors. All rights reserved. |
|
2 // This code is governed by the BSD license found in the LICENSE file. |
|
3 |
|
4 /** |
|
5 * The production ReturnStatement : return Expression; is evaluated as: |
|
6 * i) Evaluate Expression. |
|
7 * ii) Call GetValue(Result(2)). |
|
8 * iii) Return (return, Result(3), empty) |
|
9 * |
|
10 * @path ch12/12.9/S12.9_A4.js |
|
11 * @description Return very sophisticated expression and function |
|
12 */ |
|
13 |
|
14 // second derivative |
|
15 function DD_operator(f, delta){return function(x){return (f(x+delta)-2*f(x)+f(x-delta))/(delta*delta)};} |
|
16 |
|
17 DDsin = DD_operator(Math.sin, 0.00001); |
|
18 |
|
19 |
|
20 ////////////////////////////////////////////////////////////////////////////// |
|
21 //CHECK#1 |
|
22 // ((sin(x))')' = -sin(x) |
|
23 if (DDsin( Math.PI/2 ) + Math.sin( Math.PI/2 ) > 0.00001) { |
|
24 $ERROR('#1: return Expression yields to Return (return, GetValue(Evaluate Expression), empty)'); |
|
25 } |
|
26 // |
|
27 ////////////////////////////////////////////////////////////////////////////// |
|
28 |