y_remote_tests.inc 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. TODO(000, "Support localfunc and targetfunc");
  2. REMOTE_FUNC__ stock yrt_1(hi);
  3. REMOTE_FUNC__ stock yrt_3(hi, string:you[], there[], len)
  4. {
  5. #pragma unused hi, you, there, len
  6. // Impl...
  7. return 99;
  8. }
  9. REMOTE_FUNC__ Float:yrt_335(hi, string:you[], there[], len)
  10. {
  11. #pragma unused hi, you, there, len
  12. // Impl...
  13. ASSERT_SAME(you, "the string passed");
  14. return float(hi);
  15. }
  16. REMOTE_FUNC__ stock static void:yrt_4(hi)
  17. {
  18. #pragma unused hi
  19. }
  20. REMOTE_FUNC__ static stock string:yrt_5(hi, const string:you[], there[], tt, &other, const len = 7)
  21. {
  22. //printf("yrt_5 called");
  23. #pragma unused hi, you, there, tt, len
  24. new str[144];
  25. str = "Hello World";
  26. other += 5;
  27. return str;
  28. }
  29. REMOTE_FUNC__ stock Float:yrt_6(hi, string:you[], there[], len);
  30. REMOTE_FUNC__ static void:yrt_7(&a, &b, c, &d)
  31. {
  32. //printf("yrt_7 called");
  33. a = 8;
  34. b = a;
  35. c += d;
  36. d -= 4;
  37. }
  38. REMOTE_FUNC__ stock string:yrt_8();
  39. TEST__ y_remote_1()
  40. {
  41. }
  42. TODO(244, "Allocates too much heap with `len`.");
  43. REMOTE_FUNC__ static stock yrt_2(const hi, string:you[], there[], &other, &len = 7);
  44. REMOTE_FUNC__ static stock string:yrt_2b(const hi, string:you[], there[], &other, &len = 7);
  45. TEST__ y_remote_2()
  46. {
  47. new arr[89], oo = sizeof (arr);
  48. ASSERT_ZE(broadcastfunc yrt_2(789, "string", arr, oo));
  49. ASSERT_ZE(strlen(broadcastfunc yrt_2b(789, "string", arr, oo)));
  50. ASSERT_EQ(oo, sizeof (arr));
  51. }
  52. TEST__ y_remote_3()
  53. {
  54. new
  55. other = 1111111,
  56. arr[10],
  57. str[YSI_MAX_STRING];
  58. str = localfunc yrt_5(5, "string", arr, sizeof (arr), other);
  59. ASSERT_SAME(str, "Hello World");
  60. ASSERT_EQ(other, 1111116);
  61. new
  62. a = 6789,
  63. b = 6789,
  64. c = 6789,
  65. d = 6789;
  66. localfunc yrt_7(a, b, c, d);
  67. ASSERT_EQ(a, 8);
  68. ASSERT_EQ(b, 8);
  69. ASSERT_EQ(c, 6789);
  70. ASSERT_EQ(d, 6785);
  71. }
  72. TEST__ y_remote_335()
  73. {
  74. // Impl...
  75. new arr[3];
  76. ASSERT_EQ(yrt_335(89, "the string passed", arr, sizeof (arr)), 89.0);
  77. }
  78. TEST__ y_remote_4()
  79. {
  80. new
  81. other = 1111111,
  82. arr[10],
  83. str[YSI_MAX_STRING];
  84. str = broadcastfunc yrt_5(5, "string", arr, sizeof (arr), other);
  85. ASSERT_SAME(str, "Hello World");
  86. ASSERT_EQ(other, 1111116);
  87. new
  88. a = 6789,
  89. b = 6789,
  90. c = 6789,
  91. d = 6789;
  92. broadcastfunc yrt_7(a, b, c, d);
  93. ASSERT_EQ(a, 8);
  94. ASSERT_EQ(b, 8);
  95. ASSERT_EQ(c, 6789);
  96. ASSERT_EQ(d, 6785);
  97. }
  98. TEST__ y_remote_5()
  99. {
  100. new other = 42, arr[] = {5, 6, 7};
  101. ASSERT_SAME(yrt_5(10, "hi", arr, sizeof (arr), other), "Hello World");
  102. ASSERT_EQ(other, 47);
  103. }
  104. #if __COMPILER_MODIFIED
  105. REMOTE_FUNC__ Float:yrt_55(hi, const string:you[], there[], tt, &other, const len = 7)
  106. {
  107. // Figure out why this fails with the "len" parameter (allocates too much
  108. // heap data and doesn't fully clear it).
  109. #pragma unused you, there, tt, len
  110. other = hi + 5;
  111. return 5.5;
  112. }
  113. TEST__ y_remote_55()
  114. {
  115. new other = 42, arr[] = {5, 6, 7};
  116. ASSERT_EQ(yrt_55(10, "hi", arr, sizeof (arr), other), 5.5);
  117. ASSERT_EQ(other, 15);
  118. }
  119. #endif
  120. TEST__ y_remote_6()
  121. {
  122. }
  123. TEST__ y_remote_7()
  124. {
  125. new a, b, c = 123, d = 456;
  126. yrt_7(a, b, c, d);
  127. ASSERT_EQ(a, 8);
  128. ASSERT_EQ(b, 8);
  129. ASSERT_EQ(c, 123);
  130. ASSERT_EQ(d, 452);
  131. }
  132. TEST__ y_remote_8()
  133. {
  134. }
  135. REMOTE_FUNC__ Float:yrt_9();
  136. TEST__ y_remote_9()
  137. {
  138. X@(_:(55.8));
  139. ASSERT_EQ(broadcastfunc yrt_9(), 0.0);
  140. }