~ubuntu-branches/ubuntu/karmic/pypy/karmic

« back to all changes in this revision

Viewing changes to pypy/lang/js/test/ecma/Math/15.8.2.7.js

  • Committer: Bazaar Package Importer
  • Author(s): Alexandre Fayolle
  • Date: 2007-04-13 09:33:09 UTC
  • Revision ID: james.westby@ubuntu.com-20070413093309-yoojh4jcoocu2krz
Tags: upstream-1.0.0
ImportĀ upstreamĀ versionĀ 1.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 
2
/* ***** BEGIN LICENSE BLOCK *****
 
3
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
 
4
 *
 
5
 * The contents of this file are subject to the Mozilla Public License Version
 
6
 * 1.1 (the "License"); you may not use this file except in compliance with
 
7
 * the License. You may obtain a copy of the License at
 
8
 * http://www.mozilla.org/MPL/
 
9
 *
 
10
 * Software distributed under the License is distributed on an "AS IS" basis,
 
11
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 
12
 * for the specific language governing rights and limitations under the
 
13
 * License.
 
14
 *
 
15
 * The Original Code is Mozilla Communicator client code, released
 
16
 * March 31, 1998.
 
17
 *
 
18
 * The Initial Developer of the Original Code is
 
19
 * Netscape Communications Corporation.
 
20
 * Portions created by the Initial Developer are Copyright (C) 1998
 
21
 * the Initial Developer. All Rights Reserved.
 
22
 *
 
23
 * Contributor(s):
 
24
 *
 
25
 * Alternatively, the contents of this file may be used under the terms of
 
26
 * either the GNU General Public License Version 2 or later (the "GPL"), or
 
27
 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 
28
 * in which case the provisions of the GPL or the LGPL are applicable instead
 
29
 * of those above. If you wish to allow use of your version of this file only
 
30
 * under the terms of either the GPL or the LGPL, and not to allow others to
 
31
 * use your version of this file under the terms of the MPL, indicate your
 
32
 * decision by deleting the provisions above and replace them with the notice
 
33
 * and other provisions required by the GPL or the LGPL. If you do not delete
 
34
 * the provisions above, a recipient may use your version of this file under
 
35
 * the terms of any one of the MPL, the GPL or the LGPL.
 
36
 *
 
37
 * ***** END LICENSE BLOCK ***** */
 
38
 
 
39
/**
 
40
   File Name:          15.8.2.7.js
 
41
   ECMA Section:       15.8.2.7 cos( x )
 
42
   Description:        return an approximation to the cosine of the
 
43
   argument.  argument is expressed in radians
 
44
   Author:             christine@netscape.com
 
45
   Date:               7 july 1997
 
46
 
 
47
*/
 
48
 
 
49
var SECTION = "15.8.2.7";
 
50
var VERSION = "ECMA_1";
 
51
startTest();
 
52
var TITLE   = "Math.cos(x)";
 
53
 
 
54
writeHeaderToLog( SECTION + " "+ TITLE);
 
55
 
 
56
new TestCase( SECTION,
 
57
              "Math.cos.length",
 
58
              1,
 
59
              Math.cos.length );
 
60
 
 
61
new TestCase( SECTION,
 
62
              "Math.cos()",
 
63
              Number.NaN,
 
64
              Math.cos() );
 
65
 
 
66
new TestCase( SECTION,
 
67
              "Math.cos(void 0)",
 
68
              Number.NaN,
 
69
              Math.cos(void 0) );
 
70
 
 
71
new TestCase( SECTION,
 
72
              "Math.cos(false)",
 
73
              1,
 
74
              Math.cos(false) );
 
75
 
 
76
new TestCase( SECTION,
 
77
              "Math.cos(null)",
 
78
              1,
 
79
              Math.cos(null) );
 
80
 
 
81
new TestCase( SECTION,
 
82
              "Math.cos('0')",
 
83
              1,
 
84
              Math.cos('0') );
 
85
 
 
86
new TestCase( SECTION,
 
87
              "Math.cos('Infinity')",
 
88
              Number.NaN,
 
89
              Math.cos("Infinity") );
 
90
 
 
91
new TestCase( SECTION,
 
92
              "Math.cos('3.14159265359')",
 
93
              -1,
 
94
              Math.cos('3.14159265359') );
 
95
 
 
96
new TestCase( SECTION,
 
97
              "Math.cos(NaN)",
 
98
              Number.NaN,
 
99
              Math.cos(Number.NaN)        );
 
100
 
 
101
new TestCase( SECTION,
 
102
              "Math.cos(0)",
 
103
              1,
 
104
              Math.cos(0)                 );
 
105
 
 
106
new TestCase( SECTION,
 
107
              "Math.cos(-0)",
 
108
              1,
 
109
              Math.cos(-0)                );
 
110
 
 
111
new TestCase( SECTION,
 
112
              "Math.cos(Infinity)",
 
113
              Number.NaN,
 
114
              Math.cos(Number.POSITIVE_INFINITY) );
 
115
 
 
116
new TestCase( SECTION,
 
117
              "Math.cos(-Infinity)",
 
118
              Number.NaN,
 
119
              Math.cos(Number.NEGATIVE_INFINITY) );
 
120
 
 
121
new TestCase( SECTION,
 
122
              "Math.cos(0.7853981633974)",
 
123
              0.7071067811865,
 
124
              Math.cos(0.7853981633974)   );
 
125
 
 
126
new TestCase( SECTION,
 
127
              "Math.cos(1.570796326795)",
 
128
              0,
 
129
              Math.cos(1.570796326795)    );
 
130
 
 
131
new TestCase( SECTION,
 
132
              "Math.cos(2.356194490192)",
 
133
              -0.7071067811865,
 
134
              Math.cos(2.356194490192)    );
 
135
 
 
136
new TestCase( SECTION,
 
137
              "Math.cos(3.14159265359)",
 
138
              -1,
 
139
              Math.cos(3.14159265359)     );
 
140
 
 
141
new TestCase( SECTION,
 
142
              "Math.cos(3.926990816987)",
 
143
              -0.7071067811865,
 
144
              Math.cos(3.926990816987)    );
 
145
 
 
146
new TestCase( SECTION,
 
147
              "Math.cos(4.712388980385)",
 
148
              0,
 
149
              Math.cos(4.712388980385)    );
 
150
 
 
151
new TestCase( SECTION,
 
152
              "Math.cos(5.497787143782)",
 
153
              0.7071067811865,
 
154
              Math.cos(5.497787143782)    );
 
155
 
 
156
new TestCase( SECTION,
 
157
              "Math.cos(Math.PI*2)",
 
158
              1,
 
159
              Math.cos(Math.PI*2)         );
 
160
 
 
161
new TestCase( SECTION,
 
162
              "Math.cos(Math.PI/4)",
 
163
              Math.SQRT2/2,
 
164
              Math.cos(Math.PI/4)         );
 
165
 
 
166
new TestCase( SECTION,
 
167
              "Math.cos(Math.PI/2)",
 
168
              0,
 
169
              Math.cos(Math.PI/2)         );
 
170
 
 
171
new TestCase( SECTION,
 
172
              "Math.cos(3*Math.PI/4)",
 
173
              -Math.SQRT2/2,
 
174
              Math.cos(3*Math.PI/4)       );
 
175
 
 
176
new TestCase( SECTION,
 
177
              "Math.cos(Math.PI)",
 
178
              -1,
 
179
              Math.cos(Math.PI)           );
 
180
 
 
181
new TestCase( SECTION,
 
182
              "Math.cos(5*Math.PI/4)",
 
183
              -Math.SQRT2/2,
 
184
              Math.cos(5*Math.PI/4)       );
 
185
 
 
186
new TestCase( SECTION,
 
187
              "Math.cos(3*Math.PI/2)",
 
188
              0,
 
189
              Math.cos(3*Math.PI/2)       );
 
190
 
 
191
new TestCase( SECTION,
 
192
              "Math.cos(7*Math.PI/4)",
 
193
              Math.SQRT2/2,
 
194
              Math.cos(7*Math.PI/4)       );
 
195
 
 
196
new TestCase( SECTION,
 
197
              "Math.cos(Math.PI*2)",
 
198
              1,
 
199
              Math.cos(2*Math.PI)         );
 
200
 
 
201
new TestCase( SECTION,
 
202
              "Math.cos(-0.7853981633974)",
 
203
              0.7071067811865,
 
204
              Math.cos(-0.7853981633974)  );
 
205
 
 
206
new TestCase( SECTION,
 
207
              "Math.cos(-1.570796326795)",
 
208
              0,
 
209
              Math.cos(-1.570796326795)   );
 
210
 
 
211
new TestCase( SECTION,
 
212
              "Math.cos(-2.3561944901920)",
 
213
              -.7071067811865,
 
214
              Math.cos(2.3561944901920)   );
 
215
 
 
216
new TestCase( SECTION,
 
217
              "Math.cos(-3.14159265359)",
 
218
              -1,
 
219
              Math.cos(3.14159265359)     );
 
220
 
 
221
new TestCase( SECTION,
 
222
              "Math.cos(-3.926990816987)",
 
223
              -0.7071067811865,
 
224
              Math.cos(3.926990816987)    );
 
225
 
 
226
new TestCase( SECTION,
 
227
              "Math.cos(-4.712388980385)",
 
228
              0,
 
229
              Math.cos(4.712388980385)    );
 
230
 
 
231
new TestCase( SECTION,
 
232
              "Math.cos(-5.497787143782)",
 
233
              0.7071067811865,
 
234
              Math.cos(5.497787143782)    );
 
235
 
 
236
new TestCase( SECTION,
 
237
              "Math.cos(-6.28318530718)",
 
238
              1,
 
239
              Math.cos(6.28318530718)     );
 
240
 
 
241
new TestCase( SECTION,
 
242
              "Math.cos(-Math.PI/4)",
 
243
              Math.SQRT2/2,
 
244
              Math.cos(-Math.PI/4)        );
 
245
 
 
246
new TestCase( SECTION,
 
247
              "Math.cos(-Math.PI/2)",
 
248
              0,
 
249
              Math.cos(-Math.PI/2)        );
 
250
 
 
251
new TestCase( SECTION,
 
252
              "Math.cos(-3*Math.PI/4)",
 
253
              -Math.SQRT2/2,
 
254
              Math.cos(-3*Math.PI/4)      );
 
255
 
 
256
new TestCase( SECTION,
 
257
              "Math.cos(-Math.PI)",
 
258
              -1,
 
259
              Math.cos(-Math.PI)          );
 
260
 
 
261
new TestCase( SECTION,
 
262
              "Math.cos(-5*Math.PI/4)",
 
263
              -Math.SQRT2/2,
 
264
              Math.cos(-5*Math.PI/4)      );
 
265
 
 
266
new TestCase( SECTION,
 
267
              "Math.cos(-3*Math.PI/2)",
 
268
              0,
 
269
              Math.cos(-3*Math.PI/2)      );
 
270
 
 
271
new TestCase( SECTION,
 
272
              "Math.cos(-7*Math.PI/4)",
 
273
              Math.SQRT2/2,
 
274
              Math.cos(-7*Math.PI/4)      );
 
275
 
 
276
new TestCase( SECTION,
 
277
              "Math.cos(-Math.PI*2)",
 
278
              1,
 
279
              Math.cos(-Math.PI*2)        );
 
280
 
 
281
test();