ttempgen.nim 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. discard """
  2. output: '''
  3. foo
  4. '''
  5. """
  6. block: # #12672
  7. var a = @[1]
  8. let i = 1
  9. inc a[i-1]
  10. var b: seq[int]
  11. doAssertRaises(IndexDefect): inc b[0]
  12. doAssertRaises(IndexDefect): inc b[i-1]
  13. var x: seq[seq[int]]
  14. doAssertRaises(IndexDefect): # not TypeError
  15. inc x[0][i-1]
  16. block: # #14087
  17. type Obj = object
  18. str: string
  19. var s = @[Obj(str: "abc"), Obj(str: "def")]
  20. s[1].str.add("ghi")
  21. s[s.len - 1].str.add("jkl")
  22. s[^1].str.add("mno")
  23. s[s.high].str.add("pqr")
  24. let slen = s.len
  25. s[slen - 1].str.add("stu")
  26. let shigh = s.high
  27. s[shigh].str.add("vwx")
  28. proc foo(): int =
  29. echo "foo"
  30. shigh
  31. s[foo()].str.add("yz")
  32. doAssert s[1].str == "defghijklmnopqrstuvwxyz"
  33. block: # #14117
  34. type
  35. A = object
  36. case kind: bool
  37. of true:
  38. sons: seq[int]
  39. else: discard
  40. var a = A(kind: true)
  41. doAssert a.sons.len == 0
  42. a.sons.add(1)
  43. doAssert a.sons.len == 1
  44. import tables
  45. block: # #13966
  46. var t: Table[int8, array[int8, seq[tuple[]]]]
  47. t[0] = default(array[int8, seq[tuple[]]])
  48. t[0][0].add ()
  49. block: # #11783
  50. proc fun(): string =
  51. discard
  52. var ret: string
  53. ret.add fun()
  54. doAssert ret == ""
  55. block: # #12256
  56. var x: bool
  57. doAssert x == false
  58. reset x
  59. doAssert x == false
  60. doAssert x != true