xref: /PHP-7.1/ext/standard/tests/math/sin_basic.phpt (revision 7af945e2)
1--TEST--
2Test return type and value for expected input sin()
3--INI--
4precision = 14
5--FILE--
6<?php
7/*
8 * proto float sin(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 "sin 30 = ";
27var_dump(sin($thirty));
28if (allowed_rounding_error(sin($thirty),0.5)) {
29	echo "Pass\n";
30}
31else {
32	echo "Fail\n";
33}
34
35echo "sin 60 = ";
36var_dump(sin($sixty));
37if (allowed_rounding_error(sin($sixty),0.86602540378444)) {
38	echo "Pass\n";
39}
40else {
41	echo "Fail\n";
42}
43
44echo "sin 90 = ";
45var_dump(sin($ninety));
46if (allowed_rounding_error(sin($ninety),1.0)) {
47	echo "Pass\n";
48}
49else {
50	echo "Fail\n";
51}
52
53echo "sin 180 = ";
54var_dump(sin($oneeighty));
55if (allowed_rounding_error(sin($oneeighty),0.0)) {
56	echo "Pass\n";
57}
58else {
59	echo "Fail\n";
60}
61
62echo "sin 270 = ";
63var_dump(sin($twoseventy));
64if (allowed_rounding_error(sin($twoseventy),-1.0)) {
65	echo "Pass\n";
66}
67else {
68	echo "Fail\n";
69}
70
71echo "sin 360 = ";
72var_dump(sin($threesixty));
73if (allowed_rounding_error(sin($threesixty),0.0)) {
74	echo "Pass\n";
75}
76else {
77	echo "Fail\n";
78}
79?>
80--EXPECTF--
81sin 30 = float(%f)
82Pass
83sin 60 = float(%f)
84Pass
85sin 90 = float(%f)
86Pass
87sin 180 = float(%f)
88Pass
89sin 270 = float(%f)
90Pass
91sin 360 = float(%f)
92Pass
93