xref: /PHP-5.3/ext/standard/tests/math/cos_basic.phpt (revision b78b25a3)
1--TEST--
2Test return type and value for expected input cos()
3--INI--
4precision = 14
5--FILE--
6<?php
7/*
8 * proto float cos(float number)
9 * Function is implemented in ext/standard/math.c
10*/
11
12$file_path = dirname(__FILE__);
13require($file_path."/allowed_rounding_error.inc");
14
15
16// Use known values to test
17
18$sixty = M_PI / 3.0;
19$thirty = M_PI / 6.0;
20$ninety = M_PI /2.0;
21$oneeighty = M_PI;
22$twoseventy = M_PI * 1.5;
23$threesixty = M_PI * 2.0;
24
25
26echo "cos 30 = ";
27var_dump(cos($thirty));
28if (allowed_rounding_error(cos($thirty),0.86602540378444)) {
29	echo "Pass\n";
30}
31else {
32	echo "Fail\n";
33}
34
35echo "cos 60 = ";
36var_dump(cos($sixty));
37if (allowed_rounding_error(cos($sixty),0.5)) {
38	echo "Pass\n";
39}
40else {
41	echo "Fail\n";
42}
43
44echo "cos 90 = ";
45var_dump(cos($ninety));
46if (allowed_rounding_error(cos($ninety),0.0)) {
47	echo "Pass\n";
48}
49else {
50	echo "Fail\n";
51}
52
53echo "cos 180 = ";
54var_dump(cos($oneeighty));
55if (allowed_rounding_error(cos($oneeighty),-1.0)) {
56	echo "Pass\n";
57}
58else {
59	echo "Fail\n";
60}
61
62echo "cos 270 = ";
63var_dump(cos($twoseventy));
64if (allowed_rounding_error(cos($twoseventy),0.0)) {
65	echo "Pass\n";
66}
67else {
68	echo "Fail\n";
69}
70
71echo "cos 360 = ";
72var_dump(cos($threesixty));
73if (allowed_rounding_error(cos($threesixty),1.0)) {
74	echo "Pass\n";
75}
76else {
77	echo "Fail\n";
78}
79?>
80--EXPECTF--
81cos 30 = float(%f)
82Pass
83cos 60 = float(%f)
84Pass
85cos 90 = float(%f)
86Pass
87cos 180 = float(%f)
88Pass
89cos 270 = float(%f)
90Pass
91cos 360 = float(%f)
92Pass
93