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