Updated kn translations
[gcalctool.git] / src / test-number.vala
blob5c5da62702e2af467a1f62b8e62d62c381bf85a4
1 /*
2 * Copyright (C) 2008-2012 Robert Ancell.
4 * This program is free software: you can redistribute it and/or modify it under
5 * the terms of the GNU General Public License as published by the Free Software
6 * Foundation, either version 2 of the License, or (at your option) any later
7 * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
8 * license.
9 */
11 private int fail_count = 0;
12 private int pass_count = 0;
14 private void pass (string? text = null)
16 //stdout.printf ("PASS: %s\n", text);
17 pass_count++;
20 private void fail (string text)
22 stdout.printf ("*FAIL: %s\n", text);
23 fail_count++;
26 private void test_integer ()
28 for (var a = -10; a <= 10; a++)
30 var z = new Number.integer (a);
31 if (z.to_integer () != a)
33 fail ("Number.integer (%d).to_integer () -> %lli, expected %i".printf (a, z.to_integer (), a));
34 return;
38 pass ();
41 private void test_unsigned_integer ()
43 for (var a = 0; a <= 10; a++)
45 var z = new Number.unsigned_integer (a);
46 if (z.to_unsigned_integer () != a)
48 fail ("Number.unsigned_integer (%d).to_unsigned_integer () -> %i, expected %i".printf (a, (int) z.to_unsigned_integer (), a));
49 return;
53 pass ();
56 private void test_fraction ()
58 for (var a = 0; a <= 10; a++)
60 for (var b = 1; b <= 10; b++)
62 var z = new Number.fraction (a, b);
63 var expected = (double) a / b;
64 if (!double_matches (z, expected))
66 fail ("Number.fraction (%d, %d) -> %f, expected %f".printf (a, b, z.to_double (), expected));
67 return;
72 pass ();
75 private void test_float ()
77 for (var a = -10.0f; a <= 10.0f; a += 0.5f)
79 var z = new Number.float (a);
80 if (z.to_float () != a)
82 fail ("Number.float (%f).to_float () -> %f, expected %f".printf (a, z.to_float (), a));
83 return;
87 pass ();
90 private void test_double ()
92 for (var a = -10.0; a <= 10.0; a += 0.5)
94 var z = new Number.double (a);
95 if (z.to_double () != a)
97 fail ("Number.double (%f).to_double () -> %f, expected %f".printf (a, z.to_double (), a));
98 return;
102 pass ();
105 private void test_complex ()
107 for (var a = -10; a <= 10; a++)
109 for (var b = -10; b <= 10; b++)
111 var z = new Number.complex (new Number.integer (a), new Number.integer (b));
112 var re_expected = a;
113 var im_expected = b;
114 if (z.real_component ().to_integer () != re_expected || z.imaginary_component ().to_integer () != im_expected)
116 fail ("Number.complex (%d%+di) -> %d%+di, expected %d%+di".printf (a, b, (int) z.real_component ().to_integer (), (int) z.imaginary_component ().to_integer (), re_expected, im_expected));
117 return;
123 private void test_polar ()
125 for (var ri = -10; ri <= 10; ri++)
127 for (var theta_i = -10; theta_i <= 10; theta_i++)
129 var r = (double) ri;
130 var theta = 2 * Math.PI * theta_i / 10.0;
131 var z = new Number.polar (new Number.double (r), new Number.double (theta));
132 var re_expected = r * Math.cos (theta);
133 var im_expected = r * Math.sin (theta);
134 if (!double_matches (z.real_component (), re_expected) || !double_matches (z.imaginary_component (), im_expected))
136 fail ("Number.polar (%f, %f) -> %f%+fi, expected %f%+fi".printf (r, theta, z.real_component ().to_double (), z.imaginary_component ().to_double (), re_expected, im_expected));
137 return;
143 private void test_i ()
145 var z = new Number.i ();
146 if (z.real_component ().to_integer () != 0 && z.imaginary_component ().to_integer () != 1)
148 fail ("Number.i () -> %d%+di, expected i".printf ((int) z.real_component ().to_integer (), (int) z.imaginary_component ().to_integer ()));
149 return;
152 pass ();
155 private void test_pi ()
157 var z = new Number.pi ();
158 var expected = Math.PI;
159 if (!double_matches (z, expected))
161 fail ("Number.pi () -> %f, expected %f".printf (z.to_double (), expected));
162 return;
165 pass ();
168 private void test_eulers ()
170 var z = new Number.eulers ();
171 var expected = Math.E;
172 if (!double_matches (z, expected))
174 fail ("Number.eulers () -> %f, expected %f".printf (z.to_double (), expected));
175 return;
178 pass ();
181 private void test_string ()
183 for (var a = -10; a <= 10; a++)
185 var s = "%d".printf (a);
186 var z = mp_set_from_string (s);
187 if (z == null)
189 fail ("mp_set_from_string (\"%s\") -> null".printf (s));
190 return;
193 if (z.to_integer () != a)
195 fail ("mp_set_from_string (\"%s\").to_integer () -> %d, expected %d".printf (s, (int) z.to_integer (), a));
196 return;
200 pass ();
203 private void test_sgn ()
205 for (var a = -10; a <= 10; a++)
207 var z = new Number.integer (a);
208 var expected = 0;
209 if (a < 0)
210 expected = -1;
211 if (a > 0)
212 expected = 1;
213 if (z.sgn ().to_integer () != expected)
215 fail ("(%d).sgn () -> %d, expected %d".printf (a, (int) z.sgn ().to_integer (), expected));
216 return;
220 pass ();
223 private void test_invert_sign ()
225 for (var a = -10; a <= 10; a++)
227 var z = new Number.integer (a);
228 var expected = -a;
229 if (z.invert_sign ().to_integer () != expected)
231 fail ("(%d).invert_sign () -> %d, expected %d".printf (a, (int) z.invert_sign ().to_integer (), expected));
232 return;
236 pass ();
239 private void test_abs ()
241 for (var a = -10; a <= 10; a++)
243 var z = new Number.integer (a);
244 var expected = a.abs ();
245 if (z.abs ().to_integer () != expected)
247 fail ("(%d).abs () -> %d, expected %d".printf (a, (int) z.abs ().to_integer (), expected));
248 return;
252 pass ();
255 private void test_arg ()
257 for (var a = -10; a <= 10; a++)
259 for (var b = -10; b <= 10; b++)
261 var z = new Number.complex (new Number.integer (a), new Number.integer (b));
262 z = z.arg ();
263 var expected = Math.atan2 (b, a);
264 if (!double_matches (z.real_component (), expected) || !z.imaginary_component ().is_zero ())
266 fail ("(%d%+di).arg () -> %f%+fi, expected %f".printf (a, b, z.real_component ().to_double (), z.imaginary_component ().to_double (), expected));
267 return;
273 private void test_conjugate ()
275 for (var a = -10; a <= 10; a++)
277 for (var b = -10; b <= 10; b++)
279 var z = new Number.complex (new Number.integer (a), new Number.integer (b));
280 z = z.conjugate ();
281 var re_expected = a;
282 var im_expected = -b;
283 if (z.real_component ().to_integer () != re_expected || z.imaginary_component ().to_integer () != im_expected)
285 fail ("(%d%+di).real_component () -> %d%+di, expected %d%+di".printf (a, b, (int) z.real_component ().to_integer (), (int) z.imaginary_component ().to_integer (), re_expected, im_expected));
286 return;
292 private void test_real_component ()
294 for (var a = -10; a <= 10; a++)
296 for (var b = -10; b <= 10; b++)
298 var z = new Number.complex (new Number.integer (a), new Number.integer (b));
299 var expected = a;
300 if (z.real_component ().to_integer () != expected)
302 fail ("(%d+%di).real_component () -> %d, expected %d".printf (a, b, (int) z.real_component ().to_integer (), expected));
303 return;
308 pass ();
311 private void test_imaginary_component ()
313 for (var a = -10; a <= 10; a++)
315 for (var b = -10; b <= 10; b++)
317 var z = new Number.complex (new Number.integer (a), new Number.integer (b));
318 var expected = b;
319 if (z.imaginary_component ().to_integer () != expected)
321 fail ("(%d+%di).imaginary_component () -> %d, expected %d".printf (a, b, (int) z.imaginary_component ().to_integer (), expected));
322 return;
327 pass ();
330 private bool double_matches (Number a, double b)
332 return double_string (a.to_double ()) == double_string (b);
335 private string double_string (double x)
337 var value = "%.6f".printf (x);
338 if (value == "-0.000000")
339 return "0.000000";
340 else
341 return value;
344 private void test_integer_component ()
346 for (var ai = -100; ai <= 100; ai++)
348 var a = ai / 10.0;
349 var z = new Number.double (a).integer_component ();
350 var expected = Math.trunc (a);
351 if (!double_matches (z, expected))
353 fail ("(%f).integer_component () -> %f, expected %f".printf (a, z.to_double (), expected));
354 return;
358 pass ();
361 private void test_fractional_component ()
363 for (var ai = -100; ai <= 100; ai++)
365 var a = ai / 10.0;
366 var z = new Number.double (a).fractional_component ();
367 var expected = a - Math.trunc (a);
368 if (!double_matches (z, expected))
370 fail ("(%f).fractional_component () -> %f, expected %f".printf (a, z.to_double (), expected));
371 return;
375 pass ();
378 private void test_fractional_part ()
380 for (var ai = -100; ai <= 100; ai++)
382 var a = ai / 10.0;
383 var z = new Number.double (a).fractional_part ();
384 var expected = a - Math.floor (a);
385 if (!double_matches (z, expected))
387 fail ("(%f).fractional_part () -> %f, expected %f".printf (a, z.to_double (), expected));
388 return;
392 pass ();
395 private void test_floor ()
397 for (var ai = -100; ai <= 100; ai++)
399 var a = ai / 10.0;
400 var z = new Number.double (a).floor ();
401 var expected = Math.floor (a);
402 if (!double_matches (z, expected))
404 fail ("(%f).floor () -> %f, expected %f".printf (a, z.to_double (), expected));
405 return;
409 pass ();
412 private void test_ceiling ()
414 for (var ai = -100; ai <= 100; ai++)
416 var a = ai / 10.0;
417 var z = new Number.double (a).ceiling ();
418 var expected = Math.ceil (a);
419 if (!double_matches (z, expected))
421 fail ("(%f).ceiling () -> %f, expected %f".printf (a, z.to_double (), expected));
422 return;
426 pass ();
429 private void test_round ()
431 for (var ai = -100; ai <= 100; ai++)
433 var a = ai / 10.0;
434 var z = new Number.double (a).round ();
435 var expected = Math.round (a);
436 if (!double_matches (z, expected))
438 fail ("(%f).round () -> %f, expected %f".printf (a, z.to_double (), expected));
439 return;
443 pass ();
446 private void test_reciprocal ()
448 for (var a = -10; a <= 10; a++)
450 if (a == 0)
451 continue;
453 var z = new Number.double (a).reciprocal ();
454 var expected = 1.0 / a;
455 if (!double_matches (z, expected))
457 fail ("(%f).reciprocal () -> %f, expected %f".printf (a, z.to_double (), expected));
458 return;
461 z = new Number.double (expected).reciprocal ();
462 if (!double_matches (z, a))
464 fail ("(%f).reciprocal () -> %f, expected %f".printf (expected, z.to_double (), a));
465 return;
469 pass ();
472 private void test_epowy ()
474 for (var ai = -100; ai <= 100; ai++)
476 var a = ai / 10.0;
477 var z = new Number.double (a).epowy ();
478 var expected = Math.exp (a);
479 if (!double_matches (z, expected))
481 fail ("(%f).epowy () -> %f, expected %f".printf (a, z.to_double (), expected));
482 return;
486 pass ();
489 private void test_xpowy ()
491 for (var a = -10; a <= 10; a++)
493 for (var b = -10; b <= 10; b++)
495 var z = new Number.integer (a).xpowy (new Number.integer (b));
496 var expected = 1.0;
497 if (a == 0)
499 if (b != 0)
500 expected = 0.0;
502 else
504 if (b < 0)
505 for (var i = 0; i > b; i--)
506 expected /= a;
507 else if (b > 0)
508 for (var i = 0; i < b; i++)
509 expected *= a;
512 if (!double_matches (z, expected))
514 fail ("(%d).xpowy (%d) -> %f, expected %f".printf (a, b, z.to_double (), expected));
515 return;
520 pass ();
523 private void test_xpowy_integer ()
525 for (var a = -10; a <= 10; a++)
527 for (var b = -10; b <= 10; b++)
529 var z = new Number.integer (a).xpowy_integer (b);
530 var expected = 1.0;
531 if (a == 0)
533 if (b != 0)
534 expected = 0.0;
536 else
538 if (b < 0)
539 for (var i = 0; i > b; i--)
540 expected /= a;
541 else if (b > 0)
542 for (var i = 0; i < b; i++)
543 expected *= a;
546 if (!double_matches (z, expected))
548 fail ("(%d).xpowy_integer (%d) -> %f, expected %f".printf (a, b, z.to_double (), expected));
549 return;
554 pass ();
557 private void test_root3 ()
559 for (var a = -10; a <= 10; a++)
561 var z = new Number.double (a).root (3);
562 var expected = Math.cbrt (a);
563 if (!double_matches (z, expected))
565 fail ("(%f).root (3) -> %f, expected %f".printf (a, z.to_double (), expected));
566 return;
570 pass ();
573 private void test_sqrt ()
575 for (var a = 0; a <= 10; a++)
577 var z = new Number.double (a).sqrt ();
578 var expected = Math.sqrt (a);
579 if (!double_matches (z, expected))
581 fail ("(%f).sqrt () -> %f, expected %f".printf (a, z.to_double (), expected));
582 return;
586 pass ();
589 private void test_ln ()
591 for (var a = 1; a <= 10; a++)
593 var z = new Number.double (a).ln ();
594 var expected = Math.log (a);
595 if (!double_matches (z, expected))
597 fail ("(%f).ln () -> %f, expected %f".printf (a, z.to_double (), expected));
598 return;
602 pass ();
605 private void test_logarithm2 ()
607 for (var a = 1; a <= 10; a++)
609 var z = new Number.double (a).logarithm (2);
610 var expected = Math.log2 (a);
611 if (!double_matches (z, expected))
613 fail ("(%f).logarithm (2) -> %f, expected %f".printf (a, z.to_double (), expected));
614 return;
618 pass ();
621 private void test_logarithm10 ()
623 for (var a = 1; a <= 10; a++)
625 var z = new Number.double (a).logarithm (10);
626 var expected = Math.log10 (a);
627 if (!double_matches (z, expected))
629 fail ("(%f).logarithm (10) -> %f, expected %f".printf (a, z.to_double (), expected));
630 return;
634 pass ();
637 private void test_is_zero ()
639 for (var a = -10; a <= 10; a++)
641 var z = new Number.integer (a);
642 var expected = a == 0;
643 if (z.is_zero () != expected)
645 fail ("(%d).is_zero () -> %s, expected %s".printf (a, z.is_zero () ? "true" : "false", expected ? "true" : "false"));
646 return;
650 pass ();
653 private void test_is_negative ()
655 for (var a = -10; a <= 10; a++)
657 var z = new Number.integer (a);
658 var expected = a < 0;
659 if (z.is_negative () != expected)
661 fail ("(%d).is_negative () -> %s, expected %s".printf (a, z.is_negative () ? "true" : "false", expected ? "true" : "false"));
662 return;
666 pass ();
669 private void test_is_integer ()
671 for (var a = -10; a <= 10; a++)
673 var z = new Number.integer (a);
674 var expected = true;
675 if (z.is_integer () != expected)
677 fail ("(%d).is_integer () -> %s, expected %s".printf (a, z.is_integer () ? "true" : "false", expected ? "true" : "false"));
678 return;
682 pass ();
685 private void test_is_positive_integer ()
687 for (var a = -10; a <= 10; a++)
689 var z = new Number.integer (a);
690 var expected = a >= 0;
691 if (z.is_positive_integer () != expected)
693 fail ("(%d).is_positive_integer () -> %s, expected %s".printf (a, z.is_positive_integer () ? "true" : "false", expected ? "true" : "false"));
694 return;
698 pass ();
701 private void test_is_natural ()
703 for (var a = -10; a <= 10; a++)
705 var z = new Number.integer (a);
706 var expected = a > 0;
707 if (z.is_natural () != expected)
709 fail ("(%d).is_natural () -> %s, expected %s".printf (a, z.is_natural () ? "true" : "false", expected ? "true" : "false"));
710 return;
714 pass ();
717 private void test_is_complex ()
719 for (var a = -10; a <= 10; a++)
721 for (var b = -10; b <= 10; b++)
723 var z = new Number.complex (new Number.integer (a), new Number.integer (b));
724 var expected = b != 0;
725 if (z.is_complex () != expected)
727 fail ("(%d+%di).is_complex () -> %s, expected %s".printf (a, b, z.is_complex () ? "true" : "false", expected ? "true" : "false"));
728 return;
733 pass ();
736 private void test_factorial ()
738 for (var a = 0; a <= 10; a++)
740 var z = new Number.integer (a);
741 var expected = 1;
742 for (var i = 2; i <= a; i++)
743 expected *= i;
744 if (z.factorial ().to_integer () != expected)
746 fail ("(%d).factorial () -> %lli, expected %lli".printf (a, z.factorial ().to_integer (), expected));
747 return;
751 pass ();
754 private void test_add ()
756 for (var a = -10; a <= 10; a++)
758 for (var b = -10; b <= 10; b++)
760 var z = (new Number.integer (a)).add (new Number.integer (b));
761 var expected = a + b;
762 if (z.to_integer () != expected)
764 fail ("(%d).add (%d) -> %lli, expected %d".printf (a, b, z.to_integer (), expected));
765 return;
770 pass ();
773 private void test_subtract ()
775 for (var a = -10; a <= 10; a++)
777 for (var b = -10; b <= 10; b++)
779 var z = (new Number.integer (a)).subtract (new Number.integer (b));
780 var expected = a - b;
781 if (z.to_integer () != expected)
783 fail ("(%d).subtract (%d) -> %lli, expected %d".printf (a, b, z.to_integer (), expected));
784 return;
789 pass ();
792 private void test_multiply ()
794 for (var a = -10; a <= 10; a++)
796 for (var b = -10; b <= 10; b++)
798 var z = (new Number.integer (a)).multiply (new Number.integer (b));
799 var expected = a * b;
800 if (z.to_integer () != expected)
802 fail ("(%d).multiply (%d) -> %lli, expected %d".printf (a, b, z.to_integer (), expected));
803 return;
808 pass ();
811 private void test_multiply_integer ()
813 for (var a = -10; a <= 10; a++)
815 for (var b = -10; b <= 10; b++)
817 var z = (new Number.integer (a)).multiply_integer (b);
818 var expected = a * b;
819 if (z.to_integer () != expected)
821 fail ("(%d).multiply_integer (%d) -> %lli, expected %d".printf (a, b, z.to_integer (), expected));
822 return;
827 pass ();
830 private void test_divide ()
832 for (var a = -10; a <= 10; a++)
834 for (var b = -10; b <= 10; b++)
836 if (b == 0)
837 continue;
839 var z = (new Number.integer (a * b)).divide (new Number.integer (b));
840 var expected = a;
841 if (z.to_integer () != expected)
843 fail ("(%d).divide (%d) -> %lli, expected %d".printf (a * b, b, z.to_integer (), expected));
844 return;
849 pass ();
852 private void test_divide_integer ()
854 for (var a = -10; a <= 10; a++)
856 for (var b = -10; b <= 10; b++)
858 if (b == 0)
859 continue;
861 var z = (new Number.integer (a * b)).divide_integer (b);
862 var expected = a;
863 if (z.to_integer () != expected)
865 fail ("(%d).divide_integer (%d) -> %lli, expected %d".printf (a * b, b, z.to_integer (), expected));
866 return;
871 pass ();
874 private void test_modulus_divide ()
876 for (var a = 0; a <= 10; a++)
878 for (var b = 1; b <= 10; b++)
880 var z = (new Number.integer (a)).modulus_divide (new Number.integer (b));
881 var expected = a % b;
882 if (z.to_integer () != expected)
884 fail ("(%d).modulus_divide (%d) -> %lli, expected %d".printf (a, b, z.to_integer (), expected));
885 return;
890 pass ();
893 static void test_sin ()
895 for (var a = -Math.PI; a <= Math.PI; a += Math.PI / 16)
897 var z = new Number.double (a).sin ();
898 var expected = Math.sin (a);
899 if (!double_matches (z, expected))
901 fail ("(%f).sin () -> %f, expected %f".printf (a, z.to_double (), expected));
902 return;
906 pass ();
909 static void test_cos ()
911 for (var a = -Math.PI; a <= Math.PI; a += Math.PI / 16)
913 var z = new Number.double (a).cos ();
914 var expected = Math.cos (a);
915 if (!double_matches (z, expected))
917 fail ("(%f).cos () -> %f, expected %f".printf (a, z.to_double (), expected));
918 return;
922 pass ();
925 private void test_and ()
927 for (var a = 0; a < 10; a++)
929 for (var b = 0; b < 10; b++)
931 var z = (new Number.integer (a)).and (new Number.integer (b));
932 var expected = a & b;
933 if (z.to_integer () != expected)
935 fail ("(%d).and (%d) -> %lli, expected %d".printf (a, b, z.to_integer (), expected));
936 return;
941 pass ();
944 private void test_or ()
946 for (var a = 0; a < 10; a++)
948 for (var b = 0; b < 10; b++)
950 var z = (new Number.integer (a)).or (new Number.integer (b));
951 var expected = a | b;
952 if (z.to_integer () != expected)
954 fail ("(%d).or (%d) -> %lli, expected %d".printf (a, b, z.to_integer (), expected));
955 return;
960 pass ();
963 private void test_xor ()
965 for (var a = 0; a < 10; a++)
967 for (var b = 0; b < 10; b++)
969 var z = (new Number.integer (a)).xor (new Number.integer (b));
970 var expected = a ^ b;
971 if (z.to_integer () != expected)
973 fail ("(%d).xor (%d) -> %lli, expected %d".printf (a, b, z.to_integer (), expected));
974 return;
979 pass ();
982 private void test_not ()
984 for (var a = 0; a < 10; a++)
986 var z = (new Number.integer (a)).not (8);
987 var expected = ~a & 0xFF;
988 if (z.to_integer () != expected)
990 fail ("(%d).not () -> %lli, expected %d".printf (a, z.to_integer (), expected));
991 return;
995 pass ();
998 private void test_shift ()
1000 for (var a = 0; a < 10; a++)
1002 for (var b = -10; b < 10; b++)
1004 var z = (new Number.integer (a)).shift (b);
1005 var expected = a << b;
1006 if (b < 0)
1007 expected = a >> -b;
1008 if (z.to_integer () != expected)
1010 fail ("(%d).shift (%d) -> %lli, expected %d".printf (a, b, z.to_integer (), expected));
1011 return;
1016 pass ();
1019 private void test_factorize ()
1021 for (var a = 0; a < 100; a++)
1023 var factors = (new Number.integer (a)).factorize ();
1024 var expected = factorize (a);
1026 var matches = false;
1027 if (factors.length () == expected.length ())
1029 matches = true;
1030 for (var i = 0 ; i < factors.length (); i++)
1031 if (factors.nth_data (i).to_integer () != expected.nth_data (i))
1032 matches = false;
1035 if (!matches)
1037 var factors_string = "";
1038 foreach (var f in factors)
1040 if (factors_string != "")
1041 factors_string += ", ";
1042 factors_string += "%d".printf ((int) f.to_integer ());
1044 var expected_string = "";
1045 foreach (var f in expected)
1047 if (expected_string != "")
1048 expected_string += ", ";
1049 expected_string += "%d".printf (f);
1051 fail ("(%d).factorize () -> (%s), expected (%s)".printf (a, factors_string, expected_string));
1052 return;
1056 pass ();
1059 private List<int> factorize (int number)
1061 var factors = new List<int> ();
1062 if (number < 2)
1064 factors.append (number);
1065 return factors;
1068 var n = number;
1069 while (true)
1071 for (var factor = 2; factor <= n; factor++)
1073 if (n % factor == 0)
1075 factors.append (factor);
1076 n /= factor;
1077 if (n == 1)
1078 return factors;
1079 break;
1085 static int main (string[] args)
1087 Intl.setlocale (LocaleCategory.ALL, "C");
1089 test_integer ();
1090 test_unsigned_integer ();
1091 test_fraction ();
1092 test_float ();
1093 test_double ();
1094 test_complex ();
1095 test_polar ();
1096 test_string ();
1097 test_eulers ();
1098 test_i ();
1099 test_pi ();
1100 //test_random ();
1101 test_is_zero ();
1102 test_is_negative ();
1103 test_is_integer ();
1104 test_is_positive_integer ();
1105 test_is_natural ();
1106 test_is_complex ();
1107 test_sgn ();
1108 test_invert_sign ();
1109 test_abs ();
1110 test_arg ();
1111 test_conjugate ();
1112 test_real_component ();
1113 test_imaginary_component ();
1114 test_integer_component ();
1115 test_fractional_component ();
1116 test_fractional_part ();
1117 test_floor ();
1118 test_ceiling ();
1119 test_round ();
1120 test_reciprocal ();
1121 test_epowy ();
1122 test_xpowy ();
1123 test_xpowy_integer ();
1124 test_root3 (); // FIXME: should check other roots
1125 test_sqrt ();
1126 test_ln ();
1127 test_logarithm2 (); // FIXME: Should check other bases
1128 test_logarithm10 (); // FIXME: Should check other bases
1129 test_factorial ();
1130 test_add ();
1131 test_subtract ();
1132 test_multiply ();
1133 test_multiply_integer ();
1134 test_divide ();
1135 test_divide_integer ();
1136 test_modulus_divide ();
1137 test_sin ();
1138 test_cos ();
1139 //test_tan ();
1140 //test_asin ();
1141 //test_acos ();
1142 //test_atan ();
1143 //test_sinh ();
1144 //test_cosh ();
1145 //test_tanh ();
1146 //test_asinh ();
1147 //test_acosh ();
1148 //test_atanh ();
1149 test_and ();
1150 test_or ();
1151 test_xor ();
1152 test_not ();
1153 //test_mask ();
1154 test_shift ();
1155 //test_ones_complement ();
1156 //test_twos_complement ();
1157 test_factorize ();
1159 if (fail_count == 0)
1160 stdout.printf ("Passed all %i tests\n", pass_count);
1161 else
1162 stdout.printf ("Failed %i/%d tests\n", fail_count, pass_count + fail_count);
1164 return fail_count;