OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 15 matching lines...) Expand all Loading... |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 // Test Math.sin and Math.cos. | 28 // Test Math.sin and Math.cos. |
29 | 29 |
30 function sinTest() { | 30 function sinTest() { |
31 assertEquals(0, Math.sin(0)); | 31 assertEquals(0, Math.sin(0)); |
32 assertEquals(1, Math.sin(Math.PI / 2)); | 32 assertEquals(1, Math.sin(Math.PI / 2)); |
33 } | 33 } |
34 | 34 |
35 function cosTest() { | 35 function cosTest() { |
36 assertEquals(0, Math.cos(1)); | 36 assertEquals(1, Math.cos(0)); |
37 assertEquals(-1, Math.cos(Math.PI)); | 37 assertEquals(-1, Math.cos(Math.PI)); |
38 } | 38 } |
39 | 39 |
40 sinTest(); | 40 sinTest(); |
41 cosTest(); | 41 cosTest(); |
42 | 42 |
43 // By accident, the slow case for sine and cosine were both sine at | 43 // By accident, the slow case for sine and cosine were both sine at |
44 // some point. This is a regression test for that issue. | 44 // some point. This is a regression test for that issue. |
45 var x = Math.pow(2, 70); | 45 var x = Math.pow(2, 70); |
46 assertTrue(Math.sin(x) != Math.cos(x)); | 46 assertTrue(Math.sin(x) != Math.cos(x)); |
47 | 47 |
48 // Ensure that sine and log are not the same. | 48 // Ensure that sine and log are not the same. |
49 x = 0.5; | 49 x = 0.5; |
50 assertTrue(Math.sin(x) != Math.log(x)); | 50 assertTrue(Math.sin(x) != Math.log(x)); |
OLD | NEW |