PageRenderTime 40ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/trunk/Examples/test-suite/octave/overload_template_fast_runme.m

#
MATLAB | 188 lines | 141 code | 47 blank | 0 comment | 39 complexity | 6664576d285e969532d77f11764caec9 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. overload_template_fast
  2. # unless explicitly casted via {{u}int{8,16,32,64},double,single},
  3. # octave will take numeric literals as doubles.
  4. f = foo();
  5. a = maximum(3,4);
  6. b = maximum(3.4,5.2);
  7. # mix 1
  8. if (mix1("hi") != 101)
  9. error("mix1(const char*)")
  10. endif
  11. if (mix1(1.1, 1.1) != 102)
  12. error("mix1(double, const double &)")
  13. endif
  14. if (mix1(1.1) != 103)
  15. error("mix1(double)")
  16. endif
  17. # mix 2
  18. if (mix2("hi") != 101)
  19. error("mix2(const char*)")
  20. endif
  21. if (mix2(1.1, 1.1) != 102)
  22. error("mix2(double, const double &)")
  23. endif
  24. if (mix2(1.1) != 103)
  25. error("mix2(double)")
  26. endif
  27. # mix 3
  28. if (mix3("hi") != 101)
  29. error("mix3(const char*)")
  30. endif
  31. if (mix3(1.1, 1.1) != 102)
  32. error("mix3(double, const double &)")
  33. endif
  34. if (mix3(1.1) != 103)
  35. error("mix3(double)")
  36. endif
  37. # Combination 1
  38. if (overtparams1(100) != 10)
  39. error("overtparams1(int)")
  40. endif
  41. if (overtparams1(100.1, 100) != 20)
  42. error("overtparams1(double, int)")
  43. endif
  44. # Combination 2
  45. if (overtparams2(100.1, 100) != 40)
  46. error("overtparams2(double, int)")
  47. endif
  48. # Combination 3
  49. if (overloaded() != 60)
  50. error("overloaded()")
  51. endif
  52. if (overloaded(100.1, 100) != 70)
  53. error("overloaded(double, int)")
  54. endif
  55. # Combination 4
  56. if (overloadedagain("hello") != 80)
  57. error("overloadedagain(const char *)")
  58. endif
  59. if (overloadedagain() != 90)
  60. error("overloadedagain(double)")
  61. endif
  62. # specializations
  63. if (specialization(10) != 202)
  64. error("specialization(int)")
  65. endif
  66. if (specialization(10.1) != 203)
  67. error("specialization(double)")
  68. endif
  69. if (specialization(10, 10) != 204)
  70. error("specialization(int, int)")
  71. endif
  72. if (specialization(10.1, 10.1) != 205)
  73. error("specialization(double, double)")
  74. endif
  75. if (specialization("hi", "hi") != 201)
  76. error("specialization(const char *, const char *)")
  77. endif
  78. # simple specialization
  79. xyz();
  80. xyz_int();
  81. xyz_double();
  82. # a bit of everything
  83. if (overload("hi") != 0)
  84. error("overload()")
  85. endif
  86. if (overload(1) != 10)
  87. error("overload(int t)")
  88. endif
  89. if (overload(1, 1) != 20)
  90. error("overload(int t, const int &)")
  91. endif
  92. if (overload(1, "hello") != 30)
  93. error("overload(int t, const char *)")
  94. endif
  95. k = Klass();
  96. if (overload(k) != 10)
  97. error("overload(Klass t)")
  98. endif
  99. if (overload(k, k) != 20)
  100. error("overload(Klass t, const Klass &)")
  101. endif
  102. if (overload(k, "hello") != 30)
  103. error("overload(Klass t, const char *)")
  104. endif
  105. if (overload(10.1, "hi") != 40)
  106. error("overload(double t, const char *)")
  107. endif
  108. if (overload() != 50)
  109. error("overload(const char *)")
  110. endif
  111. # everything put in a namespace
  112. if (nsoverload("hi") != 1000)
  113. error("nsoverload()")
  114. endif
  115. if (nsoverload(1) != 1010)
  116. error("nsoverload(int t)")
  117. endif
  118. if (nsoverload(1, 1) != 1020)
  119. error("nsoverload(int t, const int &)")
  120. endif
  121. if (nsoverload(1, "hello") != 1030)
  122. error("nsoverload(int t, const char *)")
  123. endif
  124. if (nsoverload(k) != 1010)
  125. error("nsoverload(Klass t)")
  126. endif
  127. if (nsoverload(k, k) != 1020)
  128. error("nsoverload(Klass t, const Klass &)")
  129. endif
  130. if (nsoverload(k, "hello") != 1030)
  131. error("nsoverload(Klass t, const char *)")
  132. endif
  133. if (nsoverload(10.1, "hi") != 1040)
  134. error("nsoverload(double t, const char *)")
  135. endif
  136. if (nsoverload() != 1050)
  137. error("nsoverload(const char *)")
  138. endif
  139. A.foo(1);
  140. b = B();
  141. b.foo(1);