Tcl Library Source Code

Check-in [9b736e1cfc]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Sort tests by name in the data arrays
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | ak-bug-6efa4f571af052-jsonc
Files: files | file ages | folders
SHA1: 9b736e1cfc7da0cc48e73c6cdc952de0afbe3b52
User & Date: andreask 2013-12-11 23:18:44.224
Context
2013-12-11
23:20
Fixed bug in json::dict2json. Nobody seems to have used this before. check-in: 05d128bcc8 user: andreask tags: ak-bug-6efa4f571af052-jsonc
23:18
Sort tests by name in the data arrays check-in: 9b736e1cfc user: andreask tags: ak-bug-6efa4f571af052-jsonc
22:26
Small test simplification check-in: 942a650535 user: andreask tags: ak-bug-6efa4f571af052-jsonc
Changes
Unified Diff Ignore Whitespace Patch
Changes to modules/json/json.testsuite.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# -*- tcl -*-
# -------------------------------------------------------------------------
# Tests
# -------------------------------------------------------------------------

set i 0
foreach name [array names JSON] {
    test json-${impl}-1.[incr i] "test JSON $name" -body {
	transform [json::json2dict $JSON($name)] $name
    } -result [resultfor $name]
}

set i 0
foreach name [array names JSON] {
    test json-${impl}-7.[incr i] "validate JSON $name" -body {
        json::validate $JSON($name)
    } -result 1
}

set i 0
foreach name [array names FAIL] {
    test json-${impl}-8.[incr i] "test FAIL $name" -body {
	json::json2dict $FAIL($name)
    } -returnCodes error -result $ERR(${name}-${impl})
}

set i 0
foreach name [array names FAIL] {
    test json-${impl}-9.[incr i] "validate FAIL $name" -body {
        json::validate $FAIL($name)
    } -result 0
}

# -------------------------------------------------------------------------
# More Tests - list2json, string2json






|






|






|






|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# -*- tcl -*-
# -------------------------------------------------------------------------
# Tests
# -------------------------------------------------------------------------

set i 0
foreach name [lsort -dict [array names JSON]] {
    test json-${impl}-1.[incr i] "test JSON $name" -body {
	transform [json::json2dict $JSON($name)] $name
    } -result [resultfor $name]
}

set i 0
foreach name [lsort -dict [array names JSON]] {
    test json-${impl}-7.[incr i] "validate JSON $name" -body {
        json::validate $JSON($name)
    } -result 1
}

set i 0
foreach name [lsort -dict [array names FAIL]] {
    test json-${impl}-8.[incr i] "test FAIL $name" -body {
	json::json2dict $FAIL($name)
    } -returnCodes error -result $ERR(${name}-${impl})
}

set i 0
foreach name [lsort -dict [array names FAIL]] {
    test json-${impl}-9.[incr i] "validate FAIL $name" -body {
        json::validate $FAIL($name)
    } -result 0
}

# -------------------------------------------------------------------------
# More Tests - list2json, string2json
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
} -returnCodes error -result {wrong # args: should be "json::many-json2dict jsonText ?max?"}

test json-${impl}-3.2 {many-json2dict, bad limit, zero} -body {
    json::many-json2dict {[]} 0
} -returnCodes error -result {Bad limit 0 of json entities to extract.}

set i 0
foreach first [array names JSON] {
    foreach second [array names JSON] {
        set    input $JSON($first)
        append input " " $JSON($second)

        set     output {}
        lappend output [resultfor $first]
        lappend output [resultfor $second]

        test json-${impl}-4.[incr i] "many-json2dict: $first/$second, all" -body {
            transform* [json::many-json2dict $input] $first $second
        } -result $output
    }
}

set i 0
foreach first [array names JSON] {
    foreach second [array names JSON] {
        set    input $JSON($first)
        append input " " $JSON($second)

        set     output {}
        lappend output [resultfor $first]

        test json-${impl}-5.[incr i] "many-json2dict: $first/$second, first only" -body {
            transform* [json::many-json2dict $input 1] $first
        } -result $output
    }
}

set i 0
foreach first [array names JSON] {
    set input $JSON($first)
    test json-${impl}-6.[incr i] "many-json2dict, bad limit, 3 over 1" -body {
        json::many-json2dict $input 3
    } -returnCodes error -result {Bad limit 3 of json entities to extract, found only 1.}
}

# -------------------------------------------------------------------------







|
|














|
|













|







57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
} -returnCodes error -result {wrong # args: should be "json::many-json2dict jsonText ?max?"}

test json-${impl}-3.2 {many-json2dict, bad limit, zero} -body {
    json::many-json2dict {[]} 0
} -returnCodes error -result {Bad limit 0 of json entities to extract.}

set i 0
foreach first [lsort -dict [array names JSON]] {
    foreach second [lsort -dict [array names JSON]] {
        set    input $JSON($first)
        append input " " $JSON($second)

        set     output {}
        lappend output [resultfor $first]
        lappend output [resultfor $second]

        test json-${impl}-4.[incr i] "many-json2dict: $first/$second, all" -body {
            transform* [json::many-json2dict $input] $first $second
        } -result $output
    }
}

set i 0
foreach first [lsort -dict [array names JSON]] {
    foreach second [lsort -dict [array names JSON]] {
        set    input $JSON($first)
        append input " " $JSON($second)

        set     output {}
        lappend output [resultfor $first]

        test json-${impl}-5.[incr i] "many-json2dict: $first/$second, first only" -body {
            transform* [json::many-json2dict $input 1] $first
        } -result $output
    }
}

set i 0
foreach first [lsort -dict [array names JSON]] {
    set input $JSON($first)
    test json-${impl}-6.[incr i] "many-json2dict, bad limit, 3 over 1" -body {
        json::many-json2dict $input 3
    } -returnCodes error -result {Bad limit 3 of json entities to extract, found only 1.}
}

# -------------------------------------------------------------------------