temptyseqs.nim 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. discard """
  2. output: '''1
  3. foo
  4. bar
  5. baz
  6. foo
  7. bar
  8. baz
  9. yes
  10. no'''
  11. """
  12. # bug #1708
  13. let foo = {
  14. "1" : (bar: @["1"]),
  15. "2" : (bar: @[])
  16. }
  17. # bug #871
  18. when true:
  19. import os
  20. type
  21. In_out = tuple[src, dest: string, options: ref int]
  22. let
  23. nil_var: In_out = ("hey"/"there", "something", nil)
  24. #nil_var2 = ("hey"/"there", "something", nil)
  25. # bug #1721
  26. const foo2: seq[string] = @[]
  27. echo foo[0][0][0]
  28. proc takeEmpty(x: openArray[string] = []) = discard
  29. takeEmpty()
  30. takeEmpty([])
  31. proc takeEmpty2(x: openArray[string] = @[]) = discard
  32. takeEmpty2()
  33. takeEmpty2([])
  34. takeEmpty2(@[])
  35. #takeEmpty2([nil])
  36. #rawMessage(errExecutionOfProgramFailed, [])
  37. # bug #2470
  38. const
  39. stuff: seq[string] = @[]
  40. for str in stuff:
  41. echo "str=", str
  42. # bug #1354
  43. proc foo4[T](more: seq[T] = @[]) =
  44. var more2 = more
  45. foo4[int]()
  46. proc maino: int =
  47. var wd: cstring = nil
  48. inc result
  49. discard maino()
  50. proc varargso(a: varargs[string]) =
  51. for x in a:
  52. echo x
  53. varargso(["foo", "bar", "baz"])
  54. varargso("foo", "bar", "baz")
  55. type
  56. Flago = enum
  57. tfRequiresInit, tfNotNil
  58. var s: set[Flago] = {tfRequiresInit}
  59. if {tfRequiresInit, tfNotNil} * s != {}:
  60. echo "yes"
  61. else:
  62. echo "no"
  63. if {tfRequiresInit, tfNotNil} * s <= {tfNotNil}:
  64. echo "yes"
  65. else:
  66. echo "no"