tissues.nim 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. """
  13. import typetraits
  14. block t1252:
  15. echo float32 isnot float64
  16. echo float32 isnot float
  17. echo int32 isnot int64
  18. echo int32 isnot int
  19. block t5640:
  20. type
  21. vecBase[I: static[int]] = distinct array[I, float32]
  22. vec2 = vecBase[2]
  23. var v = vec2([0.0'f32, 0.0'f32])
  24. block t5648:
  25. type Foo = object
  26. bar: int
  27. proc main() =
  28. var f = create(Foo)
  29. f.bar = 3
  30. echo f.type.name
  31. discard realloc(f, 0)
  32. var g = Foo()
  33. g.bar = 3
  34. main()
  35. block t7581:
  36. discard int -1
  37. block t7905:
  38. template foobar(arg: typed): untyped =
  39. type
  40. MyType = object
  41. member: type(arg)
  42. var myVar: MyType
  43. myVar.member = arg
  44. echo myVar
  45. foobar("hello world")
  46. foobar(123.456'f64)
  47. template foobarRec(arg: typed): untyped =
  48. type
  49. MyType = object
  50. member: type(arg)
  51. x: ref MyType
  52. var myVar: MyType
  53. myVar.member = arg
  54. echo myVar
  55. foobarRec("hello world")
  56. foobarRec(123.456'f64)