| 1 | ## oils_failures_allowed: 1
|
| 2 |
|
| 3 | #### pp asdl
|
| 4 |
|
| 5 | shopt -s ysh:upgrade
|
| 6 |
|
| 7 | fopen >out.txt {
|
| 8 | x=42
|
| 9 | setvar y = {foo: x}
|
| 10 |
|
| 11 | pp asdl (x)
|
| 12 | pp asdl (y)
|
| 13 |
|
| 14 | # TODO, this might be nice?
|
| 15 | # pp asdl (x, y)
|
| 16 | }
|
| 17 |
|
| 18 | # Two lines with value.Str
|
| 19 | grep -n -o value.Str out.txt
|
| 20 |
|
| 21 | # Dict should have an address
|
| 22 | #grep -n -o 'Dict 0x' out.txt
|
| 23 |
|
| 24 | #cat out.txt
|
| 25 |
|
| 26 | ## STDOUT:
|
| 27 | 1:value.Str
|
| 28 | 2:value.Str
|
| 29 | ## END
|
| 30 |
|
| 31 | #### pp asdl can handle an object cycle
|
| 32 |
|
| 33 | shopt -s ysh:upgrade
|
| 34 |
|
| 35 | var d = {}
|
| 36 | setvar d.cycle = d
|
| 37 |
|
| 38 | pp line (d) | fgrep -o '{"cycle":'
|
| 39 |
|
| 40 | pp asdl (d) | fgrep -o 'cycle ...'
|
| 41 |
|
| 42 | ## STDOUT:
|
| 43 | {"cycle":
|
| 44 | cycle ...
|
| 45 | ## END
|
| 46 |
|
| 47 | #### pp line supports BashArray, BashAssoc
|
| 48 |
|
| 49 | declare -a array=(a b c)
|
| 50 | pp line (array)
|
| 51 |
|
| 52 | array[5]=z
|
| 53 | pp line (array)
|
| 54 |
|
| 55 | declare -A assoc=([k]=v [k2]=v2)
|
| 56 | pp line (assoc)
|
| 57 |
|
| 58 | # I think assoc arrays can never null / unset
|
| 59 |
|
| 60 | assoc['k3']=
|
| 61 | pp line (assoc)
|
| 62 |
|
| 63 | ## STDOUT:
|
| 64 | (BashArray) ["a","b","c"]
|
| 65 | (BashArray) ["a","b","c",null,null,"z"]
|
| 66 | (BashAssoc) {"k":"v","k2":"v2"}
|
| 67 | (BashAssoc) {"k":"v","k2":"v2","k3":""}
|
| 68 | ## END
|
| 69 |
|
| 70 |
|
| 71 | #### pp gc-stats
|
| 72 |
|
| 73 | pp gc-stats
|
| 74 |
|
| 75 | ## STDOUT:
|
| 76 | ## END
|
| 77 |
|
| 78 |
|
| 79 | #### pp cell
|
| 80 | x=42
|
| 81 |
|
| 82 | pp cell x
|
| 83 | echo status=$?
|
| 84 |
|
| 85 | pp -- cell :x
|
| 86 | echo status=$?
|
| 87 |
|
| 88 | pp cell nonexistent
|
| 89 | echo status=$?
|
| 90 | ## STDOUT:
|
| 91 | x = (Cell exported:F readonly:F nameref:F val:(value.Str s:42))
|
| 92 | status=0
|
| 93 | x = (Cell exported:F readonly:F nameref:F val:(value.Str s:42))
|
| 94 | status=0
|
| 95 | status=1
|
| 96 | ## END
|
| 97 |
|
| 98 | #### pp cell on indexed array with hole
|
| 99 | declare -a array
|
| 100 | array[3]=42
|
| 101 | pp cell array
|
| 102 | ## STDOUT:
|
| 103 | array = (Cell exported:F readonly:F nameref:F val:(value.BashArray strs:[_ _ _ 42]))
|
| 104 | ## END
|
| 105 |
|
| 106 |
|
| 107 | #### pp proc
|
| 108 | shopt --set ysh:upgrade
|
| 109 |
|
| 110 | # This has to be a separate file because sh_spec.py strips comments!
|
| 111 | . $REPO_ROOT/spec/testdata/doc-comments.sh
|
| 112 |
|
| 113 | pp proc
|
| 114 | echo ---
|
| 115 |
|
| 116 | # print one
|
| 117 | pp proc f
|
| 118 |
|
| 119 | ## STDOUT:
|
| 120 | proc_name doc_comment
|
| 121 | f "doc ' comment with \" quotes"
|
| 122 | g ""
|
| 123 | myproc "YSH-style proc"
|
| 124 | "true" "Special quoting rule"
|
| 125 | ---
|
| 126 | proc_name doc_comment
|
| 127 | f "doc ' comment with \" quotes"
|
| 128 | ## END
|
| 129 |
|