|
15 | 15 | [num] > real |
16 | 16 | num > @ |
17 | 17 |
|
18 | | - # Returns the positive square root of a `num` as `org.eolang.number`. |
19 | | - # @todo #4751:15min Move `sqrt` to a separate object with it's tests. |
20 | | - # It's atom, don't forget change `EOreal$EOsqrt`. |
21 | | - # For more information check this ticket: |
22 | | - # https://github.com/objectionary/eo/issues/4751 |
23 | | - [] > sqrt ? |
24 | | - |
25 | 18 | # Returns the natural logarithm `e` of a `num` as `org.eolang.number`. |
26 | 19 | # @todo #4751:15min Move `ln` to a separate object with it's tests. |
27 | 20 | # It's atom, don't forget change `EOreal$EOln`. |
|
89 | 82 | pow 4 5 |
90 | 83 | 1024 |
91 | 84 |
|
92 | | - # Tests that square root of zero equals zero. |
93 | | - [] +> tests-sqrt-check-zero-input |
94 | | - lt. +> @ |
95 | | - abs |
96 | | - real |
97 | | - minus. |
98 | | - 0 |
99 | | - sqrt. |
100 | | - real 0 |
101 | | - 0.00000000001 |
102 | | - |
103 | | - # Tests that square root of negative number returns NaN. |
104 | | - [] +> tests-sqrt-check-negative-input |
105 | | - is-nan. +> @ |
106 | | - sqrt. |
107 | | - real -0.1 |
108 | | - |
109 | | - # Tests that square root calculation works correctly for float input. |
110 | | - [] +> tests-sqrt-check-float-input |
111 | | - lt. +> @ |
112 | | - abs |
113 | | - real |
114 | | - minus. |
115 | | - 2 |
116 | | - sqrt. |
117 | | - real |
118 | | - 4 |
119 | | - 0.00000000001 |
120 | | - |
121 | | - # Tests that square root calculation works correctly for integer input. |
122 | | - [] +> tests-sqrt-check-int-input |
123 | | - lt. +> @ |
124 | | - abs |
125 | | - real |
126 | | - minus. |
127 | | - 9 |
128 | | - sqrt. |
129 | | - real |
130 | | - 81 |
131 | | - 0.00000000001 |
132 | | - |
133 | | - # Tests that square root of NaN returns NaN. |
134 | | - [] +> tests-sqrt-check-nan-input |
135 | | - is-nan. +> @ |
136 | | - sqrt. |
137 | | - real nan |
138 | | - |
139 | | - # Tests that square root of positive infinity equals positive infinity. |
140 | | - [] +> tests-sqrt-check-infinity-n1 |
141 | | - eq. +> @ |
142 | | - sqrt. |
143 | | - real positive-infinity |
144 | | - positive-infinity |
145 | | - |
146 | | - # Tests that square root of negative infinity returns NaN. |
147 | | - [] +> tests-sqrt-check-infinity-n2 |
148 | | - is-nan. +> @ |
149 | | - sqrt. |
150 | | - real negative-infinity |
151 | | - |
152 | 85 | # Tests that natural logarithm of negative float returns NaN. |
153 | 86 | [] +> tests-ln-of-negative-float-is-nan |
154 | 87 | is-nan. +> @ |
|
0 commit comments