tissues_types.nim 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. discard """
  2. output: '''true
  3. true
  4. true
  5. true
  6. ptr Foo
  7. (member: "hello world")
  8. (member: 123.456)
  9. (member: "hello world", x: ...)
  10. (member: 123.456, x: ...)
  11. '''
  12. joinable: false
  13. """
  14. # not joinable because it causes out of memory with --gc:boehm
  15. import typetraits
  16. block t1252:
  17. echo float32 isnot float64
  18. echo float32 isnot float
  19. echo int32 isnot int64
  20. echo int32 isnot int
  21. block t5640:
  22. type
  23. vecBase[I: static[int]] = distinct array[I, float32]
  24. vec2 = vecBase[2]
  25. var v = vec2([0.0'f32, 0.0'f32])
  26. block t5648:
  27. type Foo = object
  28. bar: int
  29. proc main() =
  30. var f = create(Foo)
  31. f.bar = 3
  32. echo f.type.name
  33. discard realloc(f, 0)
  34. var g = Foo()
  35. g.bar = 3
  36. main()
  37. block t7581:
  38. discard int -1
  39. block t7905:
  40. template foobar(arg: typed): untyped =
  41. type
  42. MyType = object
  43. member: type(arg)
  44. var myVar: MyType
  45. myVar.member = arg
  46. echo myVar
  47. foobar("hello world")
  48. foobar(123.456'f64)
  49. template foobarRec(arg: typed): untyped =
  50. type
  51. MyType = object
  52. member: type(arg)
  53. x: ref MyType
  54. var myVar: MyType
  55. myVar.member = arg
  56. echo myVar
  57. foobarRec("hello world")
  58. foobarRec(123.456'f64)