tvarious1.nim 859 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. discard """
  2. output: '''
  3. 1
  4. 0
  5. Whopie
  6. 12
  7. 1.7'''
  8. """
  9. echo len([1_000_000]) #OUT 1
  10. type
  11. TArray = array[0..3, int]
  12. TVector = distinct array[0..3, int]
  13. proc `[]`(v: TVector; idx: int): int = TArray(v)[idx]
  14. var v: TVector
  15. echo v[2]
  16. # bug #569
  17. import deques
  18. type
  19. TWidget = object
  20. names: Deque[string]
  21. var w = TWidget(names: initDeque[string]())
  22. addLast(w.names, "Whopie")
  23. for n in w.names: echo(n)
  24. # bug #681
  25. type TSomeRange = object
  26. hour: range[0..23]
  27. var value: string
  28. var val12 = TSomeRange(hour: 12)
  29. value = $(if val12.hour > 12: val12.hour - 12 else: val12.hour)
  30. echo value
  31. # bug #1334
  32. var ys = @[4.1, 5.6, 7.2, 1.7, 9.3, 4.4, 3.2]
  33. #var x = int(ys.high / 2) #echo ys[x] # Works
  34. echo ys[int(ys.high / 2)] # Doesn't work
  35. # bug #19680
  36. var here = ""
  37. when stderr is static:
  38. doAssert false
  39. else:
  40. here = "works"
  41. doAssert here == "works"