titaniummangle.nim 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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. """
  33. #When debugging this notice that if one check fails, it can be due to any of the above.
  34. type
  35. Comparable = concept x, y
  36. (x < y) is bool
  37. Foo = object
  38. a: int32
  39. b: int32
  40. FooTuple = tuple
  41. a: int
  42. b: int
  43. Container[T] = object
  44. data: T
  45. Container2[T, T2] = object
  46. data: T
  47. data2: T2
  48. Boo = distinct Foo
  49. Coo = Foo
  50. Doo = Boo | Foo
  51. TestProc = proc(a:string): string
  52. type EnumSample = enum
  53. a, b, c
  54. type EnumAnotherSample = enum
  55. a, b, c
  56. proc testFunc(a: set[EnumSample]) =
  57. echo $a
  58. proc testFunc(a: typedesc) =
  59. echo $a
  60. proc testFunc(a: ptr Foo) =
  61. echo repr a
  62. proc testFunc(s: string, a: Coo) =
  63. echo repr a
  64. proc testFunc(s: int, a: Comparable) =
  65. echo repr a
  66. proc testFunc(a: TestProc) =
  67. let b = ""
  68. echo repr a("")
  69. proc testFunc(a: ref Foo) =
  70. echo repr a
  71. proc testFunc(b: Boo) =
  72. echo repr b
  73. proc testFunc(a: ptr UncheckedArray[int]) =
  74. echo repr a
  75. proc testFunc(a: ptr int) =
  76. echo repr a
  77. proc testFunc(a: ptr ptr int) =
  78. echo repr a
  79. proc testFunc(e: FooTuple, str: cstring) =
  80. echo e
  81. proc testFunc(e: (float, float)) =
  82. echo e
  83. proc testFunc(e: EnumSample) =
  84. echo e
  85. proc testFunc(e: var int) =
  86. echo e
  87. proc testFunc(e: var Foo, a, b: int32, refFoo: ref Foo) =
  88. echo e
  89. proc testFunc(xs: Container[int]) =
  90. let a = 2
  91. echo xs
  92. proc testFunc(xs: Container2[int32, int32]) =
  93. let a = 2
  94. echo xs
  95. proc testFunc(xs: Container[Container2[int32, int32]]) =
  96. let a = 2
  97. echo xs
  98. proc testFunc(xs: seq[int]) =
  99. let a = 2
  100. echo xs
  101. proc testFunc(xs: openArray[string]) =
  102. let a = 2
  103. echo xs
  104. proc testFunc(xs: array[2, int]) =
  105. let a = 2
  106. echo xs
  107. proc testFunc(e: EnumAnotherSample) =
  108. echo e
  109. proc testFunc(a, b: int) =
  110. echo "hola"
  111. discard
  112. proc testFunc(a: int, xs: varargs[string]) =
  113. let a = 10
  114. for x in xs:
  115. echo x
  116. proc testFunc() =
  117. var a = 2
  118. var aPtr = a.addr
  119. var foo = Foo()
  120. let refFoo : ref Foo = new(Foo)
  121. let b = Foo().Boo()
  122. let d: Doo = Foo()
  123. testFunc("", Coo())
  124. testFunc(1, )
  125. testFunc(b)
  126. testFunc(EnumAnotherSample)
  127. var t = [1, 2]
  128. let uArr = cast[ptr UncheckedArray[int]](t.addr)
  129. testFunc(uArr)
  130. testFunc({})
  131. testFunc(proc(s:string): string = "test")
  132. testFunc(20, a.int32)
  133. testFunc(20, 2)
  134. testFunc(EnumSample.c)
  135. testFunc(EnumAnotherSample.c)
  136. testFunc((2, 1), "adios")
  137. testFunc((22.1, 1.2))
  138. testFunc(a.addr)
  139. testFunc(foo.addr)
  140. testFunc(aPtr.addr)
  141. testFunc(refFoo)
  142. testFunc(foo, 2, 1, refFoo)
  143. testFunc(a)
  144. testFunc(@[2, 1, 2])
  145. testFunc(@["hola"])
  146. testFunc(2, "hola", "adios")
  147. let arr: array[2, int] = [2, 1]
  148. testFunc(arr)
  149. testFunc(Container[int](data: 10))
  150. let c2 = Container2[int32, int32](data: 10, data2: 20)
  151. testFunc(c2)
  152. testFunc(Container[Container2[int32, int32]](data: c2))
  153. testFunc()