aboutsummaryrefslogtreecommitdiffstats
path: root/test/suite/sputnik_converted/12_Statement/12.9_The_return_Statement/S12.9_A4.js
blob: c9158e76d19e82d3e5f727a0aaf083b74adfcde2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright 2009 the Sputnik authors.  All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/**
* @name: S12.9_A4;
* @section: 12.9;
* @assertion: The production ReturnStatement : return Expression; is evaluated as:
* i)   Evaluate Expression.
* ii)  Call GetValue(Result(2)).
* iii) Return (return, Result(3), empty);
* @description: Return very sophisticated expression and function;
*/



// Converted for Test262 from original Sputnik source

ES5Harness.registerTest( {
id: "S12.9_A4",

path: "TestCases/12_Statement/12.9_The_return_Statement/S12.9_A4.js",

assertion: "The production ReturnStatement : return Expression; is evaluated as:",

description: "Return very sophisticated expression and function",

test: function testcase() {
   // second derivative 
function DD_operator(f, delta){return function(x){return (f(x+delta)-2*f(x)+f(x-delta))/(delta*delta)};}

DDsin = DD_operator(Math.sin, 0.00001);


//////////////////////////////////////////////////////////////////////////////
//CHECK#1
// ((sin(x))')' = -sin(x)
if (DDsin( Math.PI/2 ) + Math.sin( Math.PI/2 ) > 0.00001) {
	$ERROR('#1: return Expression yields to Return (return, GetValue(Evaluate Expression), empty)');
}
//
//////////////////////////////////////////////////////////////////////////////

 }
});