Skip to content

Commit 4ed4671

Browse files
author
SReject
committed
Updated tests
1 parent 3a54afb commit 4ed4671

1 file changed

Lines changed: 22 additions & 27 deletions

File tree

test/JSON for mIRC - Tests.mrc

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ alias JSONTest {
1515
alias -l jfm_test {
1616
;; variables that will be needed within testing
1717
var %jsondata = {"null":null,"true":true,"false":false,"int":1,"dec":1.1,"negint":-1,"negdec":-1.1,"string":"string","array":["item0","item1","item2"],"object":{"key0":"item0","key1":"item1","key2":"item2"}}
18-
var %debugdata = {"state":"done","input":"{\"null\":null,\"true\":true,\"false\":false,\"int\":1,\"dec\":1.1,\"negint\":-1,\"negdec\":-1.1,\"string\":\"string\",\"array\":[\"item0\",\"item1\",\"item2\"],\"object\":{\"key0\":\"item0\",\"key1\":\"item1\",\"key2\":\"item2\"}}","type":"text","error":false,"parse":true,"http":{"url":"","method":"GET","headers":[]},"isChild":false,"json":{"path":[],"value":{"null":null,"true":true,"false":false,"int":1,"dec":1.1,"negint":-1,"negdec":-1.1,"string":"string","array":["item0","item1","item2"],"object":{"key0":"item0","key1":"item1","key2":"item2"}}}}
18+
var %debugdata = {"state":"done","input":"{\"null\":null,\"true\":true,\"false\":false,\"int\":1,\"dec\":1.1,\"negint\":-1,\"negdec\":-1.1,\"string\":\"string\",\"array\":[\"item0\",\"item1\",\"item2\"],\"object\":{\"key0\":\"item0\",\"key1\":\"item1\",\"key2\":\"item2\"}}","type":"text","error":false,"parse":true,"http":{"url":"","method":"GET","headers":[],"insecure":false},"isChild":false,"json":{"path":[],"value":{"null":null,"true":true,"false":false,"int":1,"dec":1.1,"negint":-1,"negdec":-1.1,"string":"string","array":["item0","item1","item2"],"object":{"key0":"item0","key1":"item1","key2":"item2"}}}}
1919

2020
;; state variables
2121
var %testnum = 0
@@ -25,18 +25,13 @@ alias -l jfm_test {
2525
var %cert_re
2626
var %echo = echo 03 -sgi6 $!+([#,$base(%testNum,10,10,3),])
2727

28-
jsonshutdown
29-
jsondebug on
30-
window -n @SReject/JSONForMirc/Log
31-
3228
;;============================;;
3329
;; ;;
3430
;; $JSONVersion tests ;;
3531
;; ;;
3632
;;============================;;
3733

3834

39-
4035
;; Check $JSONVersion
4136
:1
4237
inc %testnum
@@ -85,7 +80,7 @@ alias -l jfm_test {
8580
if (%err == $null) {
8681
return %testnum /JSONOpen -q : Failed to report error (SWITCH_INVALID)
8782
}
88-
if (SWITCH_INVALID !iswm %err) {
83+
if (SWITCH_INVALID:? !iswm %err) {
8984
return %testnum /JSONOpen -q : Reported incorrect error: $v2
9085
}
9186
$(%echo,2) /JSONOpen -q : Passed Check: SWITCH_INVALID
@@ -209,20 +204,20 @@ alias -l jfm_test {
209204
$(%echo,2) /JSONOpen -b : Passed Check: PARAMETER_MISSING
210205

211206

212-
;; test to make sure /JSONOpen raises "PARAMETER_INVALID:NOT_BVAR" if -b is specified without a valid bvar
207+
;; test to make sure /JSONOpen raises "PARAMETER_INVALID:BVAR" if -b is specified without a valid bvar
213208
inc %testnum
214209
JSONOpen -b jfm_test nope
215210
%err = $JSONError
216211
if (%err == $null) {
217212
return %testnum /JSONOpen -b : Failed to report error (PARAMETER_INVALID:NOT_BVAR)
218213
}
219-
if (PARAMETER_INVALID:NOT_BVAR !== %err) {
214+
if (PARAMETER_INVALID:BVAR !== %err) {
220215
return %testnum /JSONOpen -b : Reported incorrect error: $v2
221216
}
222-
$(%echo,2) /JSONOpen -b : Passed Check: PARAMETER_INVALID:NOT_BVAR
217+
$(%echo,2) /JSONOpen -b : Passed Check: PARAMETER_INVALID:BVAR
223218

224219

225-
;; test to make sure /JSONOpen raises "PARAMETER_INVALID:NOT_BVAR" if -b is specified without a valid bvar
220+
;; test to make sure /JSONOpen raises "PARAMETER_INVALID:BVAR" if -b is specified without a valid bvar
226221
inc %testnum
227222
JSONOpen -b jfm_test &jfm_test nope
228223
%err = $JSONError
@@ -235,17 +230,17 @@ alias -l jfm_test {
235230
$(%echo,2) /JSONOpen -b : Passed Check: PARAMETER_INVALID:BVAR
236231

237232

238-
;; test to make sure /JSONOpen raises "PARAMETER_INVALID:BVAR_EMPTY" if -b is specified and the bvar is empty or doesn't exist
233+
;; test to make sure /JSONOpen raises "PARAMETER_INVALID:BVAR" if -b is specified and the bvar is empty or doesn't exist
239234
inc %testnum
240235
JSONOpen -b jfm_test &jfm_test
241236
%err = $JSONError
242237
if (%err == $null) {
243-
return %testnum /JSONOpen -b : Failed to report error (PARAMETER_INVALID:BVAR_EMPTY)
238+
return %testnum /JSONOpen -b : Failed to report error (PARAMETER_INVALID:BVAR)
244239
}
245-
if (PARAMETER_INVALID:BVAR_EMPTY !== %err) {
240+
if (PARAMETER_INVALID:BVAR !== %err) {
246241
return %testnum /JSONOpen -b : Reported incorrect error: $v2
247242
}
248-
$(%echo,2) /JSONOpen -b : Passed Check: PARAMETER_INVALID:BVAR_EMPTY
243+
$(%echo,2) /JSONOpen -b : Passed Check: PARAMETER_INVALID:BVAR
249244

250245

251246
;; test to make sure /JSONOpen raises "PARAMETER_MISSING" if -f is specified
@@ -261,17 +256,17 @@ alias -l jfm_test {
261256
$(%echo,2) /JSONOpen -f : Passed Check: PARAMETER_MISSING
262257

263258

264-
;; test to make sure /JSONOpen raises "PARAMETER_INVALID:FILE_DOESNOT_EXIST" if -f is specified but the file does not exist
259+
;; test to make sure /JSONOpen raises "PARAMETER_INVALID:FILE" if -f is specified but the file does not exist
265260
inc %testnum
266261
JSONOpen -f jfm_test jfm_test
267262
%err = $JSONError
268263
if (%err == $null) {
269-
return %testnum /JSONOpen -f : Failed to report error (PARAMETER_INVALID:FILE_DOESNOT_EXIST)
264+
return %testnum /JSONOpen -f : Failed to report error (PARAMETER_INVALID:FILE)
270265
}
271-
if (PARAMETER_INVALID:FILE_DOESNOT_EXIST !== %err) {
266+
if (PARAMETER_INVALID:FILE !== %err) {
272267
return %testnum /JSONOpen -f : Reported incorrect error: $v2
273268
}
274-
$(%echo,2) /JSONOpen -f : Passed Check: PARAMETER_INVALID:FILE_DOESNOT_EXIST
269+
$(%echo,2) /JSONOpen -f : Passed Check: PARAMETER_INVALID:FILE
275270

276271

277272
;; test to make sure /JSONOpen raises "PARAMETER_MISSING" if -u is specified but no url parameter is specified
@@ -287,17 +282,17 @@ alias -l jfm_test {
287282
$(%echo,2) /JSONOpen -u : Passed Check: PARAMETER_MISSING
288283

289284

290-
;; test to make sure /JSONOpen raises "PARAMETER_INVALID:URL_SPACES" if -u is specified but the url parameter contains spaces
285+
;; test to make sure /JSONOpen raises "PARAMETER_INVALID:URL" if -u is specified but the url parameter contains spaces
291286
inc %testnum
292287
JSONOpen -u jfm_test jfm test
293288
%err = $JSONError
294289
if (%err == $null) {
295-
return %testnum /JSONOpen -u : Failed to report error (PARAMETER_INVALID:URL_SPACES)
290+
return %testnum /JSONOpen -u : Failed to report error (PARAMETER_INVALID:URL)
296291
}
297-
if (PARAMETER_INVALID:URL_SPACES !== %err) {
292+
if (PARAMETER_INVALID:URL !== %err) {
298293
return %testnum /JSONOpen -u : Reported incorrect error: $v2
299294
}
300-
$(%echo,2) /JSONOpen -u : Passed Check: PARAMETER_INVALID:URL_SPACES
295+
$(%echo,2) /JSONOpen -u : Passed Check: PARAMETER_INVALID:URL
301296

302297

303298
;; test to make sure /JSONOpen raises "PARAMETER_MISSING" if -u is specified but no url parameter is specified
@@ -313,17 +308,17 @@ alias -l jfm_test {
313308
$(%echo,2) /JSONOpen -U : Passed Check: PARAMETER_MISSING
314309

315310

316-
;; test to make sure /JSONOpen raises "PARAMETER_INVALID:URL_SPACES" if -U is specified but the url parameter contains spaces
311+
;; test to make sure /JSONOpen raises "PARAMETER_INVALID:URL" if -U is specified but the url parameter contains spaces
317312
inc %testnum
318313
JSONOpen -U jfm_test jfm test
319314
%err = $JSONError
320315
if (%err == $null) {
321-
return %testnum /JSONOpen -U : Failed to report error (PARAMETER_INVALID:URL_SPACES)
316+
return %testnum /JSONOpen -U : Failed to report error (PARAMETER_INVALID:URL)
322317
}
323-
if (PARAMETER_INVALID:URL_SPACES !== %err) {
318+
if (PARAMETER_INVALID:URL !== %err) {
324319
return %testnum /JSONOpen -U : Reported incorrect error: $v2
325320
}
326-
$(%echo,2) /JSONOpen -U : Passed Check: PARAMETER_INVALID:URL_SPACES
321+
$(%echo,2) /JSONOpen -U : Passed Check: PARAMETER_INVALID:URL
327322

328323

329324
;; test to make sure /JSONOpen raises "INVALID_JSON" when applicable

0 commit comments

Comments
 (0)