extern Pid_t getpid (void);
#endif
+/*
+ * Some BSDs and Cygwin default to POSIX math instead of IEEE.
+ * This switches them over to IEEE.
+ */
+#if defined(LIBM_LIB_VERSION)
+ _LIB_VERSION_TYPE _LIB_VERSION = _IEEE_;
+#endif
+
/* variations on pp_null */
PP(pp_stub)
require './test.pl';
}
-plan tests => 6;
+plan tests => 22;
# compile time evaluation
is(substr($s,0,7), '2.71828');
ok(exp(log($x1)) == 1);
+
+# tests for transcendental functions
+
+my $pi = 3.1415926535897931160;
+my $pi_2 = 1.5707963267948965580;
+
+sub round {
+ my $result = shift;
+ return sprintf("%.9f", $result);
+}
+
+# sin() tests
+ok(sin(0) == 0.0);
+ok(round(sin($pi)) == 0.0);
+ok(round(sin(-1 * $pi)) == 0.0);
+ok(round(sin($pi_2)) == 1.0);
+ok(round(sin(-1 * $pi_2)) == -1.0);
+
+# cos() tests
+ok(cos(0) == 1.0);
+ok(round(cos($pi)) == -1.0);
+ok(round(cos(-1 * $pi)) == -1.0);
+ok(round(cos($pi_2)) == 0.0);
+ok(round(cos(-1 * $pi_2)) == 0.0);
+
+# atan2() tests
+ok(round(atan2(-0.0, 0.0)) == 0);
+ok(round(atan2(0.0, 0.0)) == 0);
+ok(round(atan2(-0.0, -0.0)) == round(-1 * $pi));
+ok(round(atan2(0.0, -0.0)) == round($pi));
+ok(round(atan2(-1.0, 0.0)) == round(-1 * $pi_2));
+ok(round(atan2(1.0, 0.0)) == round($pi_2));