38-compare-call.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /* -*-comment-start: "//";comment-end:""-*-
  2. * GNU Mes --- Maxwell Equations of Software
  3. * Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
  4. *
  5. * This file is part of GNU Mes.
  6. *
  7. * GNU Mes is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 3 of the License, or (at
  10. * your option) any later version.
  11. *
  12. * GNU Mes is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. #include <mes/lib-mini.h>
  21. enum type_t
  22. { TCHAR, TCLOSURE, TCONTINUATION, TFUNCTION, TKEYWORD, TMACRO, TNUMBER, TPAIR, TREF, TSPECIAL, TSTRING,
  23. TSYMBOL, TVALUES, TVECTOR, TBROKEN_HEART };
  24. int
  25. add (int a, int b)
  26. {
  27. return a + b;
  28. }
  29. int
  30. inc (int i)
  31. {
  32. return i + 1;
  33. }
  34. int
  35. identity (int i)
  36. {
  37. return i;
  38. }
  39. int
  40. main ()
  41. {
  42. int i = 0;
  43. int f = 0;
  44. int t = 1;
  45. int one = t;
  46. char *p = "mes";
  47. oputs ("\n");
  48. oputs ("t: if (strlen (\"\"))\n");
  49. if (strlen (""))
  50. return 1;
  51. oputs ("t: if (strlen (p) != 3)\n");
  52. if (strlen (p) != 3)
  53. return 2;
  54. oputs ("t: if (!strlen (\".\"))\n");
  55. if (!strlen ("."))
  56. return 3;
  57. oputs ("t: identity (p[i]) != 'm'\n");
  58. if (identity (p[i]) != 'm')
  59. return identity (p[i]);
  60. oputs ("t: inc (0)\n");
  61. if (inc (0) != 1)
  62. return 4;
  63. oputs ("t: inc (inc (0))\n");
  64. if (inc (inc (0)) != 2)
  65. return 5;
  66. oputs ("t: inc (inc (inc (0)))\n");
  67. if (inc (inc (inc (0))) != 3)
  68. return 6;
  69. oputs ("t: add (1, 2)\n");
  70. if (add (1, 2) != 3)
  71. return 7;
  72. // broken x86, x86_64
  73. oputs ("t: add (inc (0), inc (1))\n");
  74. if (add (inc (0), inc (1)) != 3)
  75. return 8;
  76. // end broken x86, x86_64
  77. oputs ("t: add (TSTRING, 3)\n");
  78. if (add (TSTRING, 3) != 13)
  79. return 9;
  80. // broken x86_64
  81. oputs ("t: add (inc (inc (0)), inc (inc (1)))\n");
  82. if (add (inc (inc (0)), inc (inc (1))) != 5)
  83. return 10;
  84. // end broken x86_64
  85. oputs ("t: if (strlen (\".\"))\n");
  86. if (strlen ("."))
  87. goto ok1;
  88. return 11;
  89. ok1:
  90. oputs ("t: if (strlen (p) == 3)\n");
  91. if (strlen (p) == 3)
  92. goto ok2;
  93. return 12;
  94. ok2:
  95. return 0;
  96. }