exists.ion 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. # Same tests as in src/builtins/exists.rs:test_evaluate_arguments()
  2. # TODO: find a better way than to write "echo $?" between each test cases
  3. exists
  4. echo $?
  5. exists foo bar
  6. echo $?
  7. exists --help
  8. echo $?
  9. exists --help unused params
  10. echo $?
  11. exists ""
  12. echo $?
  13. exists string
  14. echo $?
  15. exists "string with spaces"
  16. echo $?
  17. exists "-startswithdash"
  18. echo $?
  19. exists -a
  20. echo $?
  21. let emptyarray = []
  22. echo @emptyarray
  23. exists -a emptyarray
  24. echo $?
  25. let array = [ "element" ]
  26. echo @array
  27. exists -a array
  28. echo $?
  29. exists -a array
  30. echo $?
  31. exists -b
  32. echo $?
  33. let OLDPATH = $PATH
  34. let PATH = testing/
  35. echo "PATH = $PATH"
  36. ls -1 $PATH
  37. exists -b executable_file
  38. echo $?
  39. exists -b empty_file
  40. echo $?
  41. exists -b file_does_not_exist
  42. echo $?
  43. let PATH = $OLDPATH
  44. echo "Reset PATH to old path"
  45. exists -d
  46. echo $?
  47. exists -d testing/
  48. echo $?
  49. exists -d testing/empty_file
  50. echo $?
  51. exists -d does/not/exist
  52. echo $?
  53. exists -f
  54. echo $?
  55. exists -f testing/
  56. echo $?
  57. exists -f testing/empty_file
  58. echo $?
  59. exists -f does-not-exist
  60. echo $?
  61. fn testFunc a
  62. echo $a
  63. end
  64. exists --fn testFunc
  65. echo $?
  66. exists -s
  67. echo $?
  68. let emptyvar = ""
  69. echo "emptyvar = $emptyvar"
  70. exists -s emptyvar
  71. echo $?
  72. let testvar = "foobar"
  73. echo "testvar = $testvar"
  74. exists -s testvar
  75. echo $?
  76. drop testvar
  77. exists --foo
  78. echo $?
  79. exists -x
  80. echo $?
  81. echo "testvar = $testvar"
  82. echo This line should not be reached. Accessing an undefined variable is a programming error