-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Design a unit-test suite for jsqry executable #7
- Loading branch information
Showing
3 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,5 +3,6 @@ | |
.idea/ | ||
target/ | ||
build/ | ||
temp/ | ||
node_modules/ | ||
*.iml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Uses https://github.com/adolfopa/tush | ||
|
||
mydir=$(cd "$(dirname $0)" ; pwd) | ||
|
||
export PATH=$mydir/build:$PATH:~/proj_src/tush/bin/ | ||
|
||
#which jsqry | ||
#jsqry -v | ||
|
||
tush-check tests.tush |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
|
||
$ echo '[{"a":1},{"a":2}]' | jsqry 'a' | ||
| [ | ||
| 1, | ||
| 2 | ||
| ] | ||
|
||
$ echo '[{"a":1},{"a":2}]' | jsqry # pretty-print | ||
| [ | ||
| { | ||
| "a": 1 | ||
| }, | ||
| { | ||
| "a": 2 | ||
| } | ||
| ] | ||
|
||
$ echo '[{"a":1},{"a":2}]' | jsqry -1 'a' # first | ||
| 1 | ||
|
||
$ echo '["a", "b", "c", "d", "e"]' | jsqry '[i%2==0]' | ||
| [ | ||
| "a", | ||
| "c", | ||
| "e" | ||
| ] | ||
|
||
$ echo '[{ "k": [{ "a": 1 }, { "a": 2 }] }, { "k": [{ "a": 3 }] }]' | jsqry 'k.*.a' | ||
| [ | ||
| 1, | ||
| 2, | ||
| 3 | ||
| ] | ||
|
||
$ echo '[{ "k": [{ "a": 1 }, { "a": 2 }] }, { "k": [{ "a": 3 }] }]' | jsqry 'k.*.a[::-1]' | ||
| [ | ||
| 3, | ||
| 2, | ||
| 1 | ||
| ] | ||
|
||
$ echo '[{ "k": [{ "a": 1 }, { "a": 2 }] }, { "k": [{ "a": 3 }] }]' | jsqry -1 'k.*.a[::-1][_<3][1]{_+100}' | ||
| 101 | ||
|
||
$ echo 'hello' | jsqry 'a' | ||
@ error: Wrong JSON | ||
? 1 | ||
|
||
$ echo '{}' | jsqry '[' | ||
@ error: Not closed [ | ||
? 1 | ||
|
||
$ echo '{}' | jsqry '}' | ||
@ error: } without { | ||
? 1 | ||
|
||
$ jsqry -v | ||
| 0.0.2 | ||
|
||
$ jsqry -h | ||
| jsqry ver. 0.0.2 | ||
| Usage: echo $JSON | jsqry 'query' | ||
| -1,--first return first result element | ||
| -h,--help print help and exit | ||
| -v,--version print version and exit |