PageRenderTime 52ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 0ms

/tags/rel-1.3.35/Examples/test-suite/octave/overload_simple_runme.m

#
MATLAB | 125 lines | 93 code | 32 blank | 0 comment | 25 complexity | 31f3b04c341abd9a6622d27e9f544795 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. overload_simple
  2. # unless explicitly casted via {{u}int{8,16,32,64},double,single},
  3. # octave will take numeric literals as doubles.
  4. if (!strcmp(foo(3),"foo:int"))
  5. error("foo(int)")
  6. endif
  7. if (!strcmp(foo(3.1),"foo:double"))
  8. error("foo(double)")
  9. endif
  10. if (!strcmp(foo("hello"),"foo:char *"))
  11. error("foo(char *)")
  12. endif
  13. f = Foo();
  14. b = Bar();
  15. if (!strcmp(foo(f),"foo:Foo *"))
  16. error("foo(Foo *)")
  17. endif
  18. if (!strcmp(foo(b),"foo:Bar *"))
  19. error("foo(Bar *)")
  20. endif
  21. v = malloc_void(32);
  22. if (!strcmp(foo(v),"foo:void *"))
  23. error("foo(void *)")
  24. endif
  25. s = Spam();
  26. if (!strcmp(s.foo(3),"foo:int"))
  27. error("Spam::foo(int)")
  28. endif
  29. if (!strcmp(s.foo(3.1),"foo:double"))
  30. error("Spam::foo(double)")
  31. endif
  32. if (!strcmp(s.foo("hello"),"foo:char *"))
  33. error("Spam::foo(char *)")
  34. endif
  35. if (!strcmp(s.foo(f),"foo:Foo *"))
  36. error("Spam::foo(Foo *)")
  37. endif
  38. if (!strcmp(s.foo(b),"foo:Bar *"))
  39. error("Spam::foo(Bar *)")
  40. endif
  41. if (!strcmp(s.foo(v),"foo:void *"))
  42. error("Spam::foo(void *)")
  43. endif
  44. if (!strcmp(Spam_bar(3),"bar:int"))
  45. error("Spam::bar(int)")
  46. endif
  47. if (!strcmp(Spam_bar(3.1),"bar:double"))
  48. error("Spam::bar(double)")
  49. endif
  50. if (!strcmp(Spam_bar("hello"),"bar:char *"))
  51. error("Spam::bar(char *)")
  52. endif
  53. if (!strcmp(Spam_bar(f),"bar:Foo *"))
  54. error("Spam::bar(Foo *)")
  55. endif
  56. if (!strcmp(Spam_bar(b),"bar:Bar *"))
  57. error("Spam::bar(Bar *)")
  58. endif
  59. if (!strcmp(Spam_bar(v),"bar:void *"))
  60. error("Spam::bar(void *)")
  61. endif
  62. # Test constructors
  63. s = Spam();
  64. if (!strcmp(s.type,"none"))
  65. error("Spam()")
  66. endif
  67. s = Spam(3);
  68. if (!strcmp(s.type,"int"))
  69. error("Spam(int)")
  70. endif
  71. s = Spam(3.4);
  72. if (!strcmp(s.type,"double"))
  73. error("Spam(double)")
  74. endif
  75. s = Spam("hello");
  76. if (!strcmp(s.type,"char *"))
  77. error("Spam(char *)")
  78. endif
  79. s = Spam(f);
  80. if (!strcmp(s.type,"Foo *"))
  81. error("Spam(Foo *)")
  82. endif
  83. s = Spam(b);
  84. if (!strcmp(s.type,"Bar *"))
  85. error("Spam(Bar *)")
  86. endif
  87. s = Spam(v);
  88. if (!strcmp(s.type,"void *"))
  89. error("Spam(void *)")
  90. endif
  91. free_void(v);
  92. a = ClassA();
  93. b = a.method1(1);