1
0

jose-fmt 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. #!/bin/sh -ex
  2. jose fmt -j '{}' -O
  3. ! jose fmt -j '{}' -A
  4. ! jose fmt -j '{}' -S
  5. ! jose fmt -j '{}' -I
  6. ! jose fmt -j '{}' -R
  7. ! jose fmt -j '{}' -N
  8. ! jose fmt -j '{}' -T
  9. ! jose fmt -j '{}' -F
  10. ! jose fmt -j '{}' -B
  11. ! jose fmt -j '{}' -0
  12. ! jose fmt -j '{}' -XO
  13. jose fmt -j '{}' -XA
  14. jose fmt -j '{}' -XS
  15. jose fmt -j '{}' -XI
  16. jose fmt -j '{}' -XR
  17. jose fmt -j '{}' -XN
  18. jose fmt -j '{}' -XT
  19. jose fmt -j '{}' -XF
  20. jose fmt -j '{}' -XB
  21. jose fmt -j '{}' -X0
  22. jose fmt -j '[]' -A
  23. ! jose fmt -j '[]' -XA
  24. jose fmt -j '""' -S
  25. ! jose fmt -j '""' -XS
  26. jose fmt -j '8' -I
  27. ! jose fmt -j '8' -XI
  28. jose fmt -j '2.5' -R
  29. ! jose fmt -j '2.5' -XR
  30. jose fmt -j '8' -N
  31. ! jose fmt -j '8' -XN
  32. jose fmt -j 'true' -T
  33. ! jose fmt -j 'true' -XT
  34. jose fmt -j 'false' -F
  35. ! jose fmt -j 'false' -XF
  36. jose fmt -j 'true' -B
  37. ! jose fmt -j 'true' -XB
  38. jose fmt -j 'null' -0
  39. ! jose fmt -j 'null' -X0
  40. jose fmt -j 7 -j 7 -E
  41. ! jose fmt -j 7 -j 7 -XE
  42. ! jose fmt -j 7 -j 8 -E
  43. ! jose fmt -j 7 -j 8 -XE
  44. jose fmt -j '"foo"' -j '"foo"' -E
  45. ! jose fmt -j '"foo"' -j '"foo"' -XE
  46. ! jose fmt -j '"foo"' -j '"bar"' -E
  47. ! jose fmt -j '"foo"' -j '"bar"' -XE
  48. jose fmt -q foo -S -j '"foo"' -SE
  49. ! jose fmt -o-
  50. test `jose fmt -j '{}' -o-` = "{}"
  51. test `jose fmt -j '[1,2,3]' -f- | wc -l` = "3"
  52. test `jose fmt -j '[1,2,3]' -f- | head -n 1` = "1"
  53. test `jose fmt -j '[1,2,3]' -f- | tail -n 1` = "3"
  54. test `jose fmt -j '{"a":1,"b":2}' -f- | wc -l` = "2"
  55. test `jose fmt -j '{"a":1,"b":2}' -f- | head -n 1` = "a=1"
  56. test `jose fmt -j '{"a":1,"b":2}' -f- | tail -n 1` = "b=2"
  57. test "`jose fmt -j '"foo"' -u-`" = "foo"
  58. ! jose fmt -j 7 -u-
  59. ! jose fmt -c
  60. test "`jose fmt -j '{}' -j '{"a":1}' -s x -j 7 -s a -UUo-`" = '{"x":{"a":7}}'
  61. test "`jose fmt -j '{}' -j '{"a":1}' -s x -cj 7 -s a -UUUo-`" = '{"x":{"a":1}}'
  62. test "`jose fmt -Qo-`" = "[]"
  63. test "`jose fmt -j 7 -j 8 -j 9 -Qo-`" = "[9,8,7]"
  64. ! jose fmt -M 1
  65. test "`jose fmt -j 1 -j 2 -j 3 -M 1 -o-`" = "2"
  66. test "`jose fmt -j 1 -j 2 -j 3 -M 1 -Uo-`" = "3"
  67. test "`jose fmt -j 1 -j 2 -j 3 -M 2 -o-`" = "2"
  68. test "`jose fmt -j 1 -j 2 -j 3 -M 2 -Uo-`" = "1"
  69. test "`jose fmt -j 1 -j 2 -j 3 -M 2 -UUo-`" = "3"
  70. ! jose fmt -t 0
  71. ! jose fmt -j 7 -t 0
  72. ! jose fmt -j '{}' -t 0
  73. test "`jose fmt -j '[1,2,3]' -t 0 -lo-`" = "0"
  74. test "`jose fmt -j '[1,2,3]' -t 1 -lo-`" = "1"
  75. test "`jose fmt -j '[1,2,3]' -t 2 -lo-`" = "2"
  76. test "`jose fmt -j '[1,2,3]' -t 3 -lo-`" = "3"
  77. test "`jose fmt -j '[1,2,3]' -t 4 -lo-`" = "3"
  78. ! jose fmt -i 0
  79. ! jose fmt -j '[]' -i 0
  80. ! jose fmt -j 7 -j 8 -i 0
  81. test "`jose fmt -j '[1,2]' -j 3 -i 0 -Uo-`" = "[3,1,2]"
  82. test "`jose fmt -j '[1,2]' -j 3 -i 1 -Uo-`" = "[1,3,2]"
  83. test "`jose fmt -j '[1,2]' -j 3 -i 2 -Uo-`" = "[1,2,3]"
  84. ! jose fmt -a
  85. ! jose fmt -j '[]' -a
  86. ! jose fmt -j 7 -j 8 -a
  87. test "`jose fmt -j '[1,2]' -j 3 -aUo-`" = "[1,2,3]"
  88. test "`jose fmt -j '{"foo":1}' -j '{"foo":2,"bar":2}' -aUo-`" = '{"bar":2,"foo":1}'
  89. ! jose fmt -x
  90. ! jose fmt -j '[]' -x
  91. ! jose fmt -j 7 -j 8 -x
  92. test "`jose fmt -j '[1,2]' -j '[3,4]' -xUo-`" = "[1,2,3,4]"
  93. test "`jose fmt -j '{"foo":1}' -j '{"foo":2,"bar":2}' -xUo-`" = '{"bar":2,"foo":2}'
  94. ! jose fmt -d 0
  95. ! jose fmt -j 7 -d 0
  96. ! jose fmt -j '[]' -d 0
  97. test "`jose fmt -j '[1,2]' -d 0 -o-`" = "[2]"
  98. test "`jose fmt -j '[1,2]' -d 1 -o-`" = "[1]"
  99. ! jose fmt -l
  100. ! jose fmt -j 7 -l
  101. test "`jose fmt -j '{}' -lo-`" = "0"
  102. test "`jose fmt -j '{"foo":1}' -lo-`" = "1"
  103. test "`jose fmt -j '{"foo":1,"bar":2}' -lo-`" = "2"
  104. ! jose fmt -e
  105. ! jose fmt -j 7 -e
  106. test "`jose fmt -j '[1,2,3,4]' -eo-`" = "[]"
  107. test "`jose fmt -j '{"foo":1}' -eo-`" = "{}"
  108. ! jose fmt -g bar
  109. ! jose fmt -g 0
  110. ! jose fmt -j 7 -g bar
  111. ! jose fmt -j 7 -g 0
  112. ! jose fmt -j '{"foo":1}' -g bar
  113. ! jose fmt -j '[]' -g 0
  114. test "`jose fmt -j '{"foo":1}' -g foo -o-`" = "1"
  115. test "`jose fmt -j '[1]' -g 0 -o-`" = "1"
  116. ! jose fmt -s foo
  117. ! jose fmt -s 0
  118. ! jose fmt -j '{}' -s foo
  119. ! jose fmt -j '[]' -s 0
  120. ! jose fmt -j 7 -j 8 -s foo
  121. ! jose fmt -j 7 -j 8 -s 0
  122. ! jose fmt -j '[]' -j 8 -s 0
  123. test "`jose fmt -j '{}' -j 7 -s "foo" -Uo-`" = '{"foo":7}'
  124. test "`jose fmt -j '[1,2]' -j 7 -s 0 -Uo-`" = '[7,2]'
  125. test "`jose fmt -j '[1,2]' -j 7 -s 1 -Uo-`" = '[1,7]'
  126. ! jose fmt -y
  127. ! jose fmt -Y
  128. test "`jose fmt -j '{}' -YSu-`" = "e30"
  129. test "`jose fmt -j '"e30"' -yOo-`" = "{}"