Skip to content

Commit f91c1b6

Browse files
author
SReject
committed
Updating tests
1 parent 2ebaa83 commit f91c1b6

1 file changed

Lines changed: 46 additions & 30 deletions

File tree

test/JSON for mIRC - Tests.mrc

Lines changed: 46 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
;; /JSONTest
22
alias JSONTest {
33
_cleanup
4-
tokenize 32 $jfm_test
4+
tokenize 32 $jfm_test($1)
55
if ($0) {
66
echo 04 -sgei6 [# $+ $base($1,10,10,2) $+ ] $2-
77
}
@@ -23,14 +23,20 @@ alias -l jfm_test {
2323
var %res
2424
var %echo = echo 03 -sgi6 $!+([#,$base(%testNum,10,10,3),])
2525

26+
jsonshutdown
27+
jsondebug on
28+
window -n @SReject/JSONForMirc/Log
2629

2730
;;============================;;
2831
;; ;;
2932
;; $JSONVersion tests ;;
3033
;; ;;
3134
;;============================;;
3235

36+
37+
3338
;; Check $JSONVersion
39+
:1
3440
inc %testnum
3541
%res = $JSONVersion
3642
if (!$regex(%res, /^(?:SReject\/JSONForMirc v\d{1,4}\.\d{1,4}\.\d{1,4})$/)) {
@@ -40,6 +46,7 @@ alias -l jfm_test {
4046

4147

4248
;; Check $JSONVersion(short)
49+
:2
4350
inc %testnum
4451
%res = $JSONVersion(short)
4552
if (!$regex(%res, /^(?:\d{1,4}\.\d{1,4}\.\d{1,4})$/)) {
@@ -55,6 +62,7 @@ alias -l jfm_test {
5562
;;=========================;;
5663

5764
;; Tests to make sure "/JSONOpen" raises "PARAMETER_MISSING" error
65+
:3
5866
inc %testnum
5967
JSONOpen
6068
%err = $JSONError
@@ -68,6 +76,7 @@ alias -l jfm_test {
6876

6977

7078
;; tests to make sure /JSONOpen raises "SWITCH_INVALID" when an unknown switch is specified
79+
:4
7180
inc %testnum
7281
JSONOpen -q jfm_test "a"
7382
%err = $JSONError
@@ -81,6 +90,7 @@ alias -l jfm_test {
8190

8291

8392
;; tests to make sure /JSONOpen raises "SWITCH_CONFLICT" when conflicting switches -bf are specified
93+
:5
8494
inc %testnum
8595
JSONOpen -bf jfm_test "a"
8696
%err = $JSONError
@@ -323,6 +333,12 @@ alias -l jfm_test {
323333
$(%echo,2) /JSONClose : Passed Check: Close
324334

325335

336+
;;=======================;;
337+
;; ;;
338+
;; Parsing tests ;;
339+
;; ;;
340+
;;=======================;;
341+
326342
;; test to make sure null is properly parsed
327343
inc %testnum
328344
JSONOpen jfm_test null
@@ -1045,8 +1061,8 @@ alias -l jfm_test {
10451061
return %testnum $!JSON(jfm_test, ~ 1).FuzzyValue : Returned incorrect value: $v2
10461062
}
10471063
$(%echo,2) $!JSON(jfm_test, ~ 1).FuzzyValue : Passed Check
1048-
1049-
1064+
1065+
10501066
;;=========================;;
10511067
;; ;;
10521068
;; $JSONPath tests ;;
@@ -1077,14 +1093,14 @@ alias -l jfm_test {
10771093
return %testnum $!JSONPath(..., 1) : Returned incorrect value: $v2
10781094
}
10791095
$(%echo,2) $!JSONPath(..., 1) : Passed Check
1080-
1081-
1096+
1097+
10821098
;;============================;;
10831099
;; ;;
10841100
;; $JSONForEach Tests ;;
10851101
;; ;;
10861102
;;============================;;
1087-
1103+
10881104
;; Test $JSONForEach() on arrays
10891105
inc %testnum
10901106
unset %_jfm_foreach
@@ -1101,7 +1117,7 @@ alias -l jfm_test {
11011117
}
11021118
$(%echo,2) $!JSONForEach(<array>, ...) : Passed Check
11031119

1104-
1120+
11051121
;; Test $JSONForEach() on objects
11061122
inc %testnum
11071123
unset %_jfm_foreach
@@ -1118,17 +1134,17 @@ alias -l jfm_test {
11181134
}
11191135
$(%echo,2) $!JSONForEach(<object>, ...) : Passed Check
11201136

1121-
1137+
11221138
;; Close the JSON handle
11231139
JSONClose jfm_test
1124-
1125-
1140+
1141+
11261142
;;==============================;;
11271143
;; ;;
11281144
;; /JSONOpen HTTP tests ;;
11291145
;; ;;
11301146
;;==============================;;
1131-
1147+
11321148
;; Attempt to retrieve data from a remote source
11331149
inc %testnum
11341150
JSONOpen -u jfm_test http://echo.jsontest.com/key/value
@@ -1137,7 +1153,7 @@ alias -l jfm_test {
11371153
}
11381154
$(%echo,2) /JSONOpen -u : Request succeeded
11391155

1140-
1156+
11411157
;; Check to make sure the parsed json can be accessed
11421158
inc %testnum
11431159
%res = $JSON(jfm_test, key).value
@@ -1149,8 +1165,8 @@ alias -l jfm_test {
11491165
return %testnum $!JSON(jfm_test, key).value after request returned incorrect value: $v2
11501166
}
11511167
$(%echo,2) $!JSON(jfm_test, key).value after request: Passed Check
1152-
1153-
1168+
1169+
11541170
;; Check $JSON().HttpStatus
11551171
inc %testnum
11561172
%res = $JSON(jfm_test).HttpStatus
@@ -1165,8 +1181,8 @@ alias -l jfm_test {
11651181
return %testnum $!JSON(jfm_test).HttpStatus : Returned incorrect value: %res
11661182
}
11671183
$(%echo,2) $!JSON(jfm_test).HttpStatus : Passed Check
1168-
1169-
1184+
1185+
11701186
;; Check $JSON().HttpStatusText
11711187
inc %testnum
11721188
%res = $JSON(jfm_test).HttpStatusText
@@ -1178,8 +1194,8 @@ alias -l jfm_test {
11781194
return %testnum $!JSON(jfm_test).HttpStatusText : Returned incorrect value: $!null
11791195
}
11801196
$(%echo,2) $!JSON(jfm_test).HttpStatusText : Passed Check
1181-
1182-
1197+
1198+
11831199
;; Check $JSON().HttpHeader
11841200
inc %testnum
11851201
%res = $JSON(jfm_test, Content-Length).HttpHeader
@@ -1191,8 +1207,8 @@ alias -l jfm_test {
11911207
return %testnum $!JSON(jfm_test, Content-Length).HttpHeader : Returned incorrect value: $!null
11921208
}
11931209
$(%echo,2) $!JSON(jfm_test, Content-Length).HttpHeader : Passed Check
1194-
1195-
1210+
1211+
11961212
;; Check $JSON().HttpHeaders
11971213
inc %testnum
11981214
%res = $JSON(jfm_test).HttpHeaders
@@ -1204,8 +1220,8 @@ alias -l jfm_test {
12041220
return %testnum $!JSON(jfm_test).HttpHeaders : Returned incorrect value: $!null
12051221
}
12061222
$(%echo,2) $!JSON(jfm_test).HttpHeaders : Passed Check
1207-
1208-
1223+
1224+
12091225
;; Check $JSON().HttpHead
12101226
inc %testnum
12111227
%res = $JSON(jfm_test).HttpHead
@@ -1217,8 +1233,8 @@ alias -l jfm_test {
12171233
return %testnum $!JSON(jfm_test).HttpHead : Returned incorrect value: $!null
12181234
}
12191235
$(%echo,2) $!JSON(jfm_test).HttpHead : Passed Check
1220-
1221-
1236+
1237+
12221238
;; Check $JSON().HttpBody
12231239
inc %testnum
12241240
%res = $JSON(jfm_test).HttpBody
@@ -1230,8 +1246,8 @@ alias -l jfm_test {
12301246
return %testnum $!JSON(jfm_test).HttpBody : Returned incorrect value: $!null
12311247
}
12321248
$(%echo,2) $!JSON(jfm_test).HttpBody : Passed Check
1233-
1234-
1249+
1250+
12351251
;; Check $JSON().HttpResponse
12361252
inc %testnum
12371253
%res = $JSON(jfm_test).HttpResponse
@@ -1243,8 +1259,8 @@ alias -l jfm_test {
12431259
return %testnum $!JSON(jfm_test).HttpResponse : Returned incorrect value: $!null
12441260
}
12451261
$(%echo,2) $!JSON(jfm_test).HttpResponse : Passed Check
1246-
1247-
1262+
1263+
12481264
;; Check $JSON().HttpParse
12491265
inc %testnum
12501266
%res = $JSON(jfm_test).HttpParse
@@ -1256,9 +1272,9 @@ alias -l jfm_test {
12561272
return %testnum $!JSON(jfm_test).HttpParse : Returned incorrect value: $!null
12571273
}
12581274
$(%echo,2) $!JSON(jfm_test).HttpParse : Passed Check
1259-
1275+
12601276
JSONClose jfm_test
1261-
1277+
12621278
}
12631279

12641280

0 commit comments

Comments
 (0)