titaniummangle.nim 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. discard """
  2. targets: "c"
  3. matrix: "--debugger:native"
  4. ccodecheck: "'_ZN14titaniummangle8testFuncE'"
  5. ccodecheck: "'_ZN14titaniummangle8testFuncE6stringN14titaniummangle3FooE'"
  6. ccodecheck: "'_ZN14titaniummangle8testFuncE3int7varargsI6stringE'"
  7. ccodecheck: "'_ZN14titaniummangle8testFuncEN14titaniummangle3BooE'"
  8. ccodecheck: "'_ZN14titaniummangle8testFuncE8typeDescIN14titaniummangle17EnumAnotherSampleEE'"
  9. ccodecheck: "'_ZN14titaniummangle8testFuncE3ptrI14uncheckedArrayI3intEE'"
  10. ccodecheck: "'_ZN14titaniummangle8testFuncE3setIN14titaniummangle10EnumSampleEE'"
  11. ccodecheck: "'_ZN14titaniummangle8testFuncE4procI6string6stringE'"
  12. ccodecheck: "'_ZN14titaniummangle8testFuncE3intN10Comparable10ComparableE'"
  13. ccodecheck: "'_ZN14titaniummangle8testFuncE3int3int'"
  14. ccodecheck: "'_ZN14titaniummangle8testFuncEN14titaniummangle10EnumSampleE'"
  15. ccodecheck: "'_ZN14titaniummangle8testFuncEN14titaniummangle17EnumAnotherSampleE'"
  16. ccodecheck: "'_ZN14titaniummangle8testFuncE3int3int'"
  17. ccodecheck: "'_ZN14titaniummangle8testFuncEN14titaniummangle10EnumSampleE'"
  18. ccodecheck: "'_ZN14titaniummangle8testFuncEN14titaniummangle17EnumAnotherSampleE'"
  19. ccodecheck: "'_ZN14titaniummangle8testFuncE5tupleI3int3intE7cstring'"
  20. ccodecheck: "'_ZN14titaniummangle8testFuncE5tupleI5float5floatE'"
  21. ccodecheck: "'_ZN14titaniummangle8testFuncE3ptrI3intE'"
  22. ccodecheck: "'_ZN14titaniummangle8testFuncE3ptrIN14titaniummangle3FooEE'"
  23. ccodecheck: "'_ZN14titaniummangle8testFuncE3ptrI3ptrI3intEE'"
  24. ccodecheck: "'_ZN14titaniummangle8testFuncE3refIN14titaniummangle3FooEE'"
  25. ccodecheck: "'_ZN14titaniummangle8testFuncE3varIN14titaniummangle3FooEE5int325int323refIN14titaniummangle3FooEE'"
  26. ccodecheck: "'_ZN14titaniummangle8testFuncE3varI3intE'"
  27. ccodecheck: "'_ZN14titaniummangle8testFuncE9openArrayI6stringE'"
  28. ccodecheck: "'_ZN14titaniummangle8testFuncE5arrayI7range013intE'"
  29. ccodecheck: "'_ZN14titaniummangle8testFuncE9ContainerI3intE'"
  30. ccodecheck: "'_ZN14titaniummangle8testFuncE10Container2I5int325int32E'"
  31. ccodecheck: "'_ZN14titaniummangle8testFuncE9ContainerI10Container2I5int325int32EE'"
  32. ccodecheck: "'_ZN14titaniummangle7xxx_s10E'"
  33. ccodecheck: "'_ZN14titaniummangle7xxx_s20E'"
  34. """
  35. #When debugging this notice that if one check fails, it can be due to any of the above.
  36. type
  37. Comparable = concept x, y
  38. (x < y) is bool
  39. Foo = object
  40. a: int32
  41. b: int32
  42. FooTuple = tuple
  43. a: int
  44. b: int
  45. Container[T] = object
  46. data: T
  47. Container2[T, T2] = object
  48. data: T
  49. data2: T2
  50. Boo = distinct Foo
  51. Coo = Foo
  52. Doo = Boo | Foo
  53. TestProc = proc(a:string): string
  54. type EnumSample = enum
  55. a, b, c
  56. type EnumAnotherSample = enum
  57. a, b, c
  58. proc testFunc(a: set[EnumSample]) =
  59. echo $a
  60. proc testFunc(a: typedesc) =
  61. echo $a
  62. proc testFunc(a: ptr Foo) =
  63. echo repr a
  64. proc testFunc(s: string, a: Coo) =
  65. echo repr a
  66. proc testFunc(s: int, a: Comparable) =
  67. echo repr a
  68. proc testFunc(a: TestProc) =
  69. let b = ""
  70. echo repr a("")
  71. proc testFunc(a: ref Foo) =
  72. echo repr a
  73. proc testFunc(b: Boo) =
  74. echo repr b
  75. proc testFunc(a: ptr UncheckedArray[int]) =
  76. echo repr a
  77. proc testFunc(a: ptr int) =
  78. echo repr a
  79. proc testFunc(a: ptr ptr int) =
  80. echo repr a
  81. proc testFunc(e: FooTuple, str: cstring) =
  82. echo e
  83. proc testFunc(e: (float, float)) =
  84. echo e
  85. proc testFunc(e: EnumSample) =
  86. echo e
  87. proc testFunc(e: var int) =
  88. echo e
  89. proc testFunc(e: var Foo, a, b: int32, refFoo: ref Foo) =
  90. echo e
  91. proc testFunc(xs: Container[int]) =
  92. let a = 2
  93. echo xs
  94. proc testFunc(xs: Container2[int32, int32]) =
  95. let a = 2
  96. echo xs
  97. proc testFunc(xs: Container[Container2[int32, int32]]) =
  98. let a = 2
  99. echo xs
  100. proc testFunc(xs: seq[int]) =
  101. let a = 2
  102. echo xs
  103. proc testFunc(xs: openArray[string]) =
  104. let a = 2
  105. echo xs
  106. proc testFunc(xs: array[2, int]) =
  107. let a = 2
  108. echo xs
  109. proc testFunc(e: EnumAnotherSample) =
  110. echo e
  111. proc testFunc(a, b: int) =
  112. echo "hola"
  113. discard
  114. proc testFunc(a: int, xs: varargs[string]) =
  115. let a = 10
  116. for x in xs:
  117. echo x
  118. proc xxx(v: static int) =
  119. echo v
  120. proc testFunc() =
  121. var a = 2
  122. var aPtr = a.addr
  123. var foo = Foo()
  124. let refFoo : ref Foo = new(Foo)
  125. let b = Foo().Boo()
  126. let d: Doo = Foo()
  127. testFunc("", Coo())
  128. testFunc(1, )
  129. testFunc(b)
  130. testFunc(EnumAnotherSample)
  131. var t = [1, 2]
  132. let uArr = cast[ptr UncheckedArray[int]](t.addr)
  133. testFunc(uArr)
  134. testFunc({})
  135. testFunc(proc(s:string): string = "test")
  136. testFunc(20, a.int32)
  137. testFunc(20, 2)
  138. testFunc(EnumSample.c)
  139. testFunc(EnumAnotherSample.c)
  140. testFunc((2, 1), "adios")
  141. testFunc((22.1, 1.2))
  142. testFunc(a.addr)
  143. testFunc(foo.addr)
  144. testFunc(aPtr.addr)
  145. testFunc(refFoo)
  146. testFunc(foo, 2, 1, refFoo)
  147. testFunc(a)
  148. testFunc(@[2, 1, 2])
  149. testFunc(@["hola"])
  150. testFunc(2, "hola", "adios")
  151. let arr: array[2, int] = [2, 1]
  152. testFunc(arr)
  153. testFunc(Container[int](data: 10))
  154. let c2 = Container2[int32, int32](data: 10, data2: 20)
  155. testFunc(c2)
  156. testFunc(Container[Container2[int32, int32]](data: c2))
  157. xxx(10)
  158. xxx(20)
  159. testFunc()