Tcl Source Code

Check-in [d046004a15]
Login

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

Overview
Comment:Add more failure cases to test suite, gonna have to do non-error cases one of these days
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | amg-array-enum-c-api
Files: files | file ages | folders
SHA1: d046004a15ed323474c6c4ba8759ae926dba9fc7
User & Date: andy 2016-12-03 00:42:19
Context
2016-12-10
19:35
Add [array set] tests check-in: a8289808bb user: andy tags: amg-array-enum-c-api
2016-12-03
00:42
Add more failure cases to test suite, gonna have to do non-error cases one of these days check-in: d046004a15 user: andy tags: amg-array-enum-c-api
2016-12-02
22:10
Rename [oxor] to [or] and [oxand] to [and], also [oxjoin] to [oxfordJoin] check-in: c903f22fde user: andy tags: amg-array-enum-c-api
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to tests/array.test.

76
77
78
79
80
81
82

83
84
85
86
87
88
89
90

91
92
93
94
95
96
97
    }
}
interp alias {} and {} oxfordJoin and
interp alias {} or {} oxfordJoin or

# samples --
# Produces a list of sample arguments, given a list of parameters.

proc samples {params} {
    lmap param $params {dict get {
        arrayName   a
        searchId    s-1-a
        ?mode?      -exact
        ?pattern?   hello
        list        {hello world}
    } $param}

}

# test --
# Wrapper around [::tcltest::test] with additional features:
#
# - Single-argument block design gives a cleaner visual presentation.
# - All script execution is performed in a new stack frame.







>
|
|





|
>







76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
    }
}
interp alias {} and {} oxfordJoin and
interp alias {} or {} oxfordJoin or

# samples --
# Produces a list of sample arguments, given a list of parameters.
# Customizations can be applied via $args.
proc samples {params args} {
    set map [dict merge {
        arrayName   a
        searchId    s-1-a
        ?mode?      -exact
        ?pattern?   hello
        list        {hello world}
    } $args]
    lmap param $params {dict get $map $param}
}

# test --
# Wrapper around [::tcltest::test] with additional features:
#
# - Single-argument block design gives a cleaner visual presentation.
# - All script execution is performed in a new stack frame.
325
326
327
328
329
330
331






















































































332
333
334
335
336
337
338
        desc {nonexistent array: \[array $cmd\]}
        {scalar cmd} $cmd
        {scalar args} {[samples [dict get $params $cmd]]}
        body {array $cmd {*}$args}
        returnCodes error
        result {"a" isn't an array}
    }






















































































}

# Cleanup.
foreach namespace [namespace children] {
    if {$namespace ni $namespaces} {
        namespace delete $namespace
    }







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
        desc {nonexistent array: \[array $cmd\]}
        {scalar cmd} $cmd
        {scalar args} {[samples [dict get $params $cmd]]}
        body {array $cmd {*}$args}
        returnCodes error
        result {"a" isn't an array}
    }
    test {
        name array-2.7.$cmd
        desc {element of proc-slot-only array: \[array $cmd\]}
        {scalar cmd} $cmd
        {scalar args} {[samples [dict get $params $cmd]]}
        body {array $cmd {*}$args; set a(hello) 123}
        returnCodes error
        result {"a" isn't an array}
    }
}
foreach cmd {anymore donesearch nextelement set startsearch statistics} {
    test {
        name array-2.8.$cmd
        desc {scalar variable: \[array $cmd\]}
        {scalar cmd} $cmd
        {scalar args} {[samples [dict get $params $cmd]]}
        {scalar a} {}
        body {array $cmd {*}$args}
        returnCodes error
        result {[expr {$cmd ne "set" ? "\"a\" isn't an array"
                     : "can't set \"a(hello)\": variable isn't array"}]}
    }
    test {
        name array-2.9.$cmd
        desc {element of empty array: \[array $cmd\]}
        {scalar cmd} $cmd
        {scalar args} {[samples [dict get $params $cmd] arrayName a(x)]}
        {array a} {}
        body {array $cmd {*}$args}
        returnCodes error
        result {[expr {$cmd ne "set" ? "\"a(x)\" isn't an array"
                     : "can't set \"a(x)\": variable isn't array"}]}
    }
    test {
        name array-2.10.$cmd
        desc {element of nonexistent array: \[array $cmd\]}
        {scalar cmd} $cmd
        {scalar args} {[samples [dict get $params $cmd] arrayName a(x)]}
        body {array $cmd {*}$args}
        returnCodes error
        result {[expr {$cmd ne "set" ? "\"a(x)\" isn't an array"
                     : "can't set \"a(x)\": variable isn't array"}]}
    }
    test {
        name array-2.11.$cmd
        desc {element of scalar variable: \[array $cmd\]}
        {scalar cmd} $cmd
        {scalar args} {[samples [dict get $params $cmd] arrayName a(x)]}
        {scalar a} {}
        body {array $cmd {*}$args}
        returnCodes error
        result {[expr {$cmd ne "set" ? "\"a(x)\" isn't an array"
                     : "can't set \"a(x)\": variable isn't array"}]}
    }
    test {
        name array-2.12.$cmd
        desc {existing element of array: \[array $cmd\]}
        {scalar cmd} $cmd
        {scalar args} {[samples [dict get $params $cmd] arrayName a(x)]}
        {scalar a} {x 123}
        body {array $cmd {*}$args}
        returnCodes error
        result {[expr {$cmd ne "set" ? "\"a(x)\" isn't an array"
                     : "can't set \"a(x)\": variable isn't array"}]}
    }
    test {
        name array-2.13.$cmd
        desc {nonexistent element of array: \[array $cmd\]}
        {scalar cmd} $cmd
        {scalar args} {[samples [dict get $params $cmd] arrayName a(x)]}
        {array a} {}
        body {array $cmd {*}$args}
        returnCodes error
        result {[expr {$cmd ne "set" ? "\"a(x)\" isn't an array"
                     : "can't set \"a(x)\": variable isn't array"}]}
    }
    test {
        name array-2.14.$cmd
        desc {bad namespace: \[array $cmd\]}
        {scalar cmd} $cmd
        {scalar args} {[samples [dict get $params $cmd] arrayName ::X::a]}
        body {array $cmd {*}$args}
        returnCodes error
        result {[expr {$cmd ne "set" ? "\"::X::a\" isn't an array"
                     : "can't set \"::X::a\": parent namespace doesn't exist"}]}
    }
}

# Cleanup.
foreach namespace [namespace children] {
    if {$namespace ni $namespaces} {
        namespace delete $namespace
    }