We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent cd0db4e commit 6d67680Copy full SHA for 6d67680
t/nqp/83-log.t
@@ -0,0 +1,20 @@
1
+plan(2);
2
+
3
+# Basic tests for nqp::log_n
4
5
+my $log_5 := 940945/584642;
6
+my $log_one_tenth := -254834/110673;
7
8
+sub is_approx($got, $expected, $descr = "$got is approximately $expected") {
9
+ my $tol := nqp::abs_n($expected) < 1e-6 ?? 1e-5 !! nqp::abs_n($expected) * 1e-6;
10
+ my $test := nqp::abs_n($got - $expected) <= $tol;
11
+ ok(?$test, $descr);
12
+ unless $test {
13
+ say("#got: $got");
14
+ say("#expected: $expected");
15
+ }
16
+ ?$test;
17
+}
18
19
+is_approx(nqp::log_n(5), $log_5, 'got the log of 5');
20
+is_approx(nqp::log_n(0.1), $log_one_tenth, 'got the log of 0.1');
0 commit comments