tvarious.nim 972 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. # Test various aspects
  2. # bug #572
  3. var a=12345678901'u64
  4. var x = (x: 42, y: (a: 8, z: 10))
  5. echo x.y
  6. import
  7. mvarious
  8. type
  9. PA = ref TA
  10. PB = ref TB
  11. TB = object
  12. a: PA
  13. TA = object
  14. b: TB
  15. x: int
  16. proc getPA(): PA =
  17. var
  18. b: bool
  19. b = not false
  20. return nil
  21. # bug #501
  22. proc f(): int = 54
  23. var
  24. global: int
  25. var
  26. s: string
  27. i: int
  28. r: TA
  29. r.b.a.x = 0
  30. global = global + 1
  31. exportme()
  32. write(stdout, "Hallo wie heißt du? ")
  33. write(stdout, getPA().x)
  34. s = readLine(stdin)
  35. i = 0
  36. while i < s.len:
  37. if s[i] == 'c': write(stdout, "'c' in deinem Namen gefunden\n")
  38. i = i + 1
  39. write(stdout, "Du heißt " & s)
  40. # bug #544
  41. # yay, fails again
  42. type Bar [T; I:range] = array[I, T]
  43. proc foo*[T; I:range](a, b: Bar[T, I]): Bar[T, I] =
  44. when len(a) != 3:
  45. # Error: constant expression expected
  46. {.fatal:"Dimensions have to be 3".}
  47. #...
  48. block:
  49. var a, b: Bar[int, range[0..2]]
  50. discard foo(a, b)
  51. # bug #1788
  52. echo "hello" & char(ord(' ')) & "world"