tsince.nim 665 B

123456789101112131415161718192021222324252627282930313233
  1. import std/private/since
  2. proc fun1(): int {.since: (1, 3).} = 12
  3. proc fun1Bad(): int {.since: (99, 3).} = 12
  4. proc fun2(): int {.since: (1, 3, 1).} = 12
  5. proc fun2Bad(): int {.since: (99, 3, 1).} = 12
  6. doAssert fun1() == 12
  7. doAssert declared(fun1)
  8. doAssert not declared(fun1Bad)
  9. doAssert fun2() == 12
  10. doAssert declared(fun2)
  11. doAssert not declared(fun2Bad)
  12. var ok = false
  13. since (1, 3):
  14. ok = true
  15. doAssert ok
  16. ok = false
  17. since (1, 3, 1):
  18. ok = true
  19. doAssert ok
  20. since (99, 3):
  21. doAssert false
  22. when false:
  23. # pending https://github.com/timotheecour/Nim/issues/129
  24. # Error: cannot attach a custom pragma to 'fun3'
  25. template fun3(): int {.since: (1, 3).} = 12