*** Running test-ascii-control ===== CASE: -c echo $'\x02' | json read ===== echo $'\x02' | json read ^~~~ [ -c flag ]:1: json read: Invalid token while parsing JSON: Id.Unknown_Tok (line 1, offset 0-1: '\x02\n') ===== CASE: -c echo $'"foo \x01 "' | json read pp test_ (_reply) ===== echo $'"foo \x01 "' | json read ^~~~ [ -c flag ]:1: json read: JSON strings can't have unescaped ASCII control chars (line 1, offset 0-6: '"foo \x01 "\n') echo $'"foo \x01 "' | json read ^~~~ [ -c flag ]:1: errexit PID 8914: command.Simple failed with status 1 echo $'"foo \x01 "' | json read ^~~~ [ -c flag ]:1: errexit PID 8914: command.Pipeline failed with status 1 ===== CASE: -c var invalid = b'\y01' echo $["u'foo" ++ invalid ++ "'"] | json8 read pp test_ (_reply) ===== echo $["u'foo" ++ invalid ++ "'"] | json8 read ^~~~ [ -c flag ]:2: json8 read: J8 strings can't have unescaped ASCII control chars (line 1, offset 0-6: "u'foo\x01'\n") echo $["u'foo" ++ invalid ++ "'"] | json8 read ^~~~~ [ -c flag ]:2: errexit PID 8919: command.Simple failed with status 1 echo $["u'foo" ++ invalid ++ "'"] | json8 read ^~~~~ [ -c flag ]:2: errexit PID 8919: command.Pipeline failed with status 1 OK test-ascii-control *** Running test-cpython Traceback (most recent call last): File "", line 1, in File "/usr/lib/python3.7/json/__init__.py", line 348, in loads return _default_decoder.decode(s) File "/usr/lib/python3.7/json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/lib/python3.7/json/decoder.py", line 353, in raw_decode obj, end = self.scan_once(s, idx) json.decoder.JSONDecodeError: Invalid control character at: line 1 column 6 (char 5) Traceback (most recent call last): File "", line 1, in File "/usr/lib/python3.7/json/__init__.py", line 348, in loads return _default_decoder.decode(s) File "/usr/lib/python3.7/json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/lib/python3.7/json/decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 2 (char 1) OK test-cpython *** Running test-encode ===== CASE: -c var d = {}; setvar d.k = d; json write (d) ===== [ -c flag ]:1: json write: Can't encode Dict 0x7fa39452c758 in object cycle ===== CASE: -c var L = []; call L->append(L); json write (L) ===== [ -c flag ]:1: json write: Can't encode List 0x7fa0c711b758 in object cycle ===== CASE: -c var L = []; call L->append(/d+/); j8 write (L) ===== var L = []; call L->append(/d+/); j8 write (L) ^ [ -c flag ]:1: fatal: 'j8' appears to be external. External commands don't accept typed args (OILS-ERR-200) OK test-encode *** Running test-j8-lines ===== CASE: -c write @(echo ' "json\tstring" '; echo; echo " b'j8' "; echo ' unquoted ';) ===== json string j8 unquoted ===== CASE: -c var lines = @( echo '"unbalanced' ) pp test_ (lines) ===== var lines = @( ^~ [ -c flag ]:1: fatal: Unexpected EOF while lexing J8 string (line 1, offset 0-11: '"unbalanced') ===== CASE: -c write @(echo '"unbalanced') ===== write @(echo '"unbalanced') ^~ [ -c flag ]:1: fatal: Unexpected EOF while lexing J8 string (line 1, offset 0-11: '"unbalanced') ===== CASE: -c write @(echo '"json" "nope"') ===== write @(echo '"json" "nope"') ^~ [ -c flag ]:1: fatal: Unexpected text after J8 Line (Id.J8_String) (line 1, offset 7-13: 'on" "nope"') ===== CASE: -c write @(echo '"json" unquoted') ===== write @(echo '"json" unquoted') ^~ [ -c flag ]:1: fatal: Unexpected text after J8 Line (Id.Lit_Chars) (line 1, offset 7-15: 'on" unquoted') ===== CASE: -c write @(echo '"hello \z"') ===== write @(echo '"hello \z"') ^~ [ -c flag ]:1: fatal: Bad backslash escape in J8 string (line 1, offset 0-8: '"hello \\z"') ===== CASE: -c write @(echo $'foo \xff-bar spam') ===== write @(echo $'foo \xff-bar spam') ^~ [ -c flag ]:1: fatal: Invalid UTF-8 in J8 string literal (line 1, offset 4-9: 'foo \xff-bar spa') ===== CASE: -c write @(echo $'foo \x01-bar spam') ===== write @(echo $'foo \x01-bar spam') ^~ [ -c flag ]:1: fatal: J8 Lines can't have unescaped ASCII control chars (line 1, offset 4-5: 'foo \x01-bar') OK test-j8-lines *** Running test-line-numbers ===== CASE: -c echo ' { "a": 99, "foo\z": 42 } ' | json read ===== ' | json read ^~~~ [ -c flag ]:6: json read: Bad backslash escape in JSON string (line 4, offset 16-21: ',\n "foo\\z": ') ===== CASE: -c echo ' { "foo": 42 oops } ' | json read ===== ' | json read ^~~~ [ -c flag ]:5: json read: Expected Id.J8_RBrace, got Id.J8_Identifier (line 3, offset 15-19: ' 42 oops\n}\n\n') ===== CASE: -c proc p { echo unquoted echo echo echo ' "hi" oops' # line 4 error } write -- @(p) ===== write -- @(p) ^~ [ -c flag ]:8: fatal: Unexpected text after J8 Line (Id.Lit_Chars) (line 4, offset 17-21: 'hi" oops') OK test-line-numbers *** Running test-parse-errors ===== CASE: -c echo "" | json read ===== echo "" | json read ^~~~ [ -c flag ]:1: json read: Unexpected EOF while parsing JSON (line 2, offset 1-1: '\n') ===== CASE: -c echo { | json read ===== echo { | json read ^~~~ [ -c flag ]:1: json read: Expected Id.J8_String, got Id.Eol_Tok (line 2, offset 2-2: '{\n') ===== CASE: -c echo + | json read ===== echo + | json read ^~~~ [ -c flag ]:1: json read: Invalid token while parsing JSON: Id.J8_Operator (line 1, offset 0-1: '+\n') ===== CASE: -c echo "(" | json read ===== echo "(" | json read ^~~~ [ -c flag ]:1: json read: Invalid token while parsing JSON: Id.J8_LParen (line 1, offset 0-1: '(\n') ===== CASE: -c echo '{}[ ' | json read ===== echo '{}[ ' | json read ^~~~ [ -c flag ]:1: json read: Got 3 bytes of unexpected trailing input (line 1, offset 2-3: '{}[ \n') echo '{}[ ' | json read ^~~~ [ -c flag ]:1: errexit PID 9023: command.Simple failed with status 1 echo '{}[ ' | json read ^~~~ [ -c flag ]:1: errexit PID 9023: command.Pipeline failed with status 1 OK test-parse-errors *** Running test-str-bad-escape ===== CASE: -c echo '"hi \z bye"' | json read ===== echo '"hi \z bye"' | json read ^~~~ [ -c flag ]:1: json read: Bad backslash escape in JSON string (line 1, offset 0-5: '"hi \\z by') echo '"hi \z bye"' | json read ^~~~ [ -c flag ]:1: errexit PID 9031: command.Simple failed with status 1 echo '"hi \z bye"' | json read ^~~~ [ -c flag ]:1: errexit PID 9031: command.Pipeline failed with status 1 ===== CASE: -c var invalid = r'\z' echo $["u'hi" ++ invalid ++ "bye'"] | json8 read ===== echo $["u'hi" ++ invalid ++ "bye'"] | json8 read ^~~~ [ -c flag ]:2: json8 read: Bad backslash escape in J8 string (line 1, offset 0-5: "u'hi\\zbye") echo $["u'hi" ++ invalid ++ "bye'"] | json8 read ^~~~~ [ -c flag ]:2: errexit PID 9036: command.Simple failed with status 1 echo $["u'hi" ++ invalid ++ "bye'"] | json8 read ^~~~~ [ -c flag ]:2: errexit PID 9036: command.Pipeline failed with status 1 OK test-str-bad-escape *** Running test-str-invalid-utf8 ===== CASE: -c # part of mu = \u03bc echo $' "\xce" ' | json read ===== echo $' "\xce" ' | json read ^~~~ [ -c flag ]:2: json read: Invalid UTF-8 in JSON string literal (line 1, offset 1-3: ' "\xce" \n') echo $' "\xce" ' | json read ^~~~ [ -c flag ]:2: errexit PID 9044: command.Simple failed with status 1 echo $' "\xce" ' | json read ^~~~ [ -c flag ]:2: errexit PID 9044: command.Pipeline failed with status 1 ===== CASE: -c var invalid = b'\yce' echo $["u'" ++ invalid ++ "'"] | json8 read ===== echo $["u'" ++ invalid ++ "'"] | json8 read ^~~~ [ -c flag ]:2: json8 read: Invalid UTF-8 in J8 string literal (line 1, offset 0-3: "u'\xce'\n") echo $["u'" ++ invalid ++ "'"] | json8 read ^~~~~ [ -c flag ]:2: errexit PID 9049: command.Simple failed with status 1 echo $["u'" ++ invalid ++ "'"] | json8 read ^~~~~ [ -c flag ]:2: errexit PID 9049: command.Pipeline failed with status 1 OK test-str-invalid-utf8 *** Running test-str-unclosed-quote ===== CASE: -c echo -n '["' | json read ===== echo -n '["' | json read ^~~~ [ -c flag ]:1: json read: Unexpected EOF while lexing JSON string (line 1, offset 1-2: '["') ===== CASE: -c echo -n "[b'" | json8 read ===== echo -n "[b'" | json8 read ^~~~ [ -c flag ]:1: json8 read: Unexpected EOF while lexing J8 string (line 1, offset 1-3: "[b'") OK test-str-unclosed-quote data_lang/j8-errors.sh: 9 tests passed.