#!/bin/bash

# Copyright (C) 2016, 2017  Stefan Vargyas
# 
# This file is part of Json-Type.
# 
# Json-Type is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# 
# Json-Type is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with Json-Type.  If not, see <http://www.gnu.org/licenses/>.

#
# File generated by a command like:
# $ json-gentest -C type-checker:closed-array6
#

[[ "$1" =~ ^-u[0-9]+$ ]] &&
u="${1:2}" ||
u=""

diff -u$u -L closed-array6.old <(echo \
'$ export JSON_TYPE_CHECK_ERROR_COMPLETE_TYPES=yes
$ json() { LD_LIBRARY_PATH=../lib ../src/json --terse --verbose --literal-value "$@"; }
$ json -d '\''{"type":"array","args":["type","type"]}'\'' <<< '\''[[{}]]'\''
json: error: <stdin>:1:6: type check error: too few arguments
json: error: <stdin>:1:6: [[{}]]
json: error: <stdin>:1:6:      ^
[[{}]
command failed: json -d '\''{"type":"array","args":["type","type"]}'\'' <<< '\''[[{}]]'\''
$ json -d '\''{"type":"array","args":["type","null"]}'\'' <<< '\''[null]'\''
json: error: <stdin>:1:6: type check error: too few arguments
json: error: <stdin>:1:6: [null]
json: error: <stdin>:1:6:      ^
[null
command failed: json -d '\''{"type":"array","args":["type","null"]}'\'' <<< '\''[null]'\''
$ json -d '\''{"type":"array","args":["type","boolean"]}'\'' <<< '\''[false]'\''
json: error: <stdin>:1:7: type check error: too few arguments
json: error: <stdin>:1:7: [false]
json: error: <stdin>:1:7:       ^
[false
command failed: json -d '\''{"type":"array","args":["type","boolean"]}'\'' <<< '\''[false]'\''
$ json -d '\''{"type":"array","args":["type","number"]}'\'' <<< '\''[456]'\''
json: error: <stdin>:1:5: type check error: too few arguments
json: error: <stdin>:1:5: [456]
json: error: <stdin>:1:5:     ^
[456
command failed: json -d '\''{"type":"array","args":["type","number"]}'\'' <<< '\''[456]'\''
$ json -d '\''{"type":"array","args":["type","string"]}'\'' <<< '\''["bar"]'\''
json: error: <stdin>:1:7: type check error: too few arguments
json: error: <stdin>:1:7: ["bar"]
json: error: <stdin>:1:7:       ^
["bar"
command failed: json -d '\''{"type":"array","args":["type","string"]}'\'' <<< '\''["bar"]'\''
$ json -d '\''{"type":"array","args":["type","object"]}'\'' <<< '\''[{}]'\''
json: error: <stdin>:1:4: type check error: too few arguments
json: error: <stdin>:1:4: [{}]
json: error: <stdin>:1:4:    ^
[{}
command failed: json -d '\''{"type":"array","args":["type","object"]}'\'' <<< '\''[{}]'\''
$ json -d '\''{"type":"array","args":["type","array"]}'\'' <<< '\''[[]]'\''
json: error: <stdin>:1:4: type check error: too few arguments
json: error: <stdin>:1:4: [[]]
json: error: <stdin>:1:4:    ^
[[]
command failed: json -d '\''{"type":"array","args":["type","array"]}'\'' <<< '\''[[]]'\'''
) -L closed-array6.new <(
echo '$ export JSON_TYPE_CHECK_ERROR_COMPLETE_TYPES=yes'
export JSON_TYPE_CHECK_ERROR_COMPLETE_TYPES=yes 2>&1 ||
echo 'command failed: export JSON_TYPE_CHECK_ERROR_COMPLETE_TYPES=yes'

echo '$ json() { LD_LIBRARY_PATH=../lib ../src/json --terse --verbose --literal-value "$@"; }'
json() { LD_LIBRARY_PATH=../lib ../src/json --terse --verbose --literal-value "$@"; } 2>&1 ||
echo 'command failed: json() { LD_LIBRARY_PATH=../lib ../src/json --terse --verbose --literal-value "$@"; }'

echo '$ json -d '\''{"type":"array","args":["type","type"]}'\'' <<< '\''[[{}]]'\'''
json -d '{"type":"array","args":["type","type"]}' <<< '[[{}]]' 2>&1 ||
echo 'command failed: json -d '\''{"type":"array","args":["type","type"]}'\'' <<< '\''[[{}]]'\'''

echo '$ json -d '\''{"type":"array","args":["type","null"]}'\'' <<< '\''[null]'\'''
json -d '{"type":"array","args":["type","null"]}' <<< '[null]' 2>&1 ||
echo 'command failed: json -d '\''{"type":"array","args":["type","null"]}'\'' <<< '\''[null]'\'''

echo '$ json -d '\''{"type":"array","args":["type","boolean"]}'\'' <<< '\''[false]'\'''
json -d '{"type":"array","args":["type","boolean"]}' <<< '[false]' 2>&1 ||
echo 'command failed: json -d '\''{"type":"array","args":["type","boolean"]}'\'' <<< '\''[false]'\'''

echo '$ json -d '\''{"type":"array","args":["type","number"]}'\'' <<< '\''[456]'\'''
json -d '{"type":"array","args":["type","number"]}' <<< '[456]' 2>&1 ||
echo 'command failed: json -d '\''{"type":"array","args":["type","number"]}'\'' <<< '\''[456]'\'''

echo '$ json -d '\''{"type":"array","args":["type","string"]}'\'' <<< '\''["bar"]'\'''
json -d '{"type":"array","args":["type","string"]}' <<< '["bar"]' 2>&1 ||
echo 'command failed: json -d '\''{"type":"array","args":["type","string"]}'\'' <<< '\''["bar"]'\'''

echo '$ json -d '\''{"type":"array","args":["type","object"]}'\'' <<< '\''[{}]'\'''
json -d '{"type":"array","args":["type","object"]}' <<< '[{}]' 2>&1 ||
echo 'command failed: json -d '\''{"type":"array","args":["type","object"]}'\'' <<< '\''[{}]'\'''

echo '$ json -d '\''{"type":"array","args":["type","array"]}'\'' <<< '\''[[]]'\'''
json -d '{"type":"array","args":["type","array"]}' <<< '[[]]' 2>&1 ||
echo 'command failed: json -d '\''{"type":"array","args":["type","array"]}'\'' <<< '\''[[]]'\'''
)

