Tcl Source Code

Check-in [9af4defa79]
Login

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

Overview
Comment:Add non-bytecoded [string replace] tests to exercise new TclStringReplace() function
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | amg-string-insert
Files: files | file ages | folders
SHA1: 9af4defa79034b510df8bc24fb98989815a90e17
User & Date: andy 2017-08-20 18:13:33
Context
2017-08-20
19:55
Tweak string index boundary conditionals for tiny performance improvement and to make existing tests... check-in: 025ea6e5be user: andy tags: amg-string-insert
18:13
Add non-bytecoded [string replace] tests to exercise new TclStringReplace() function check-in: 9af4defa79 user: andy tags: amg-string-insert
03:45
Add string-14.18 to test that [string replace] with last<first does not insert a string, even though... check-in: de104ef5ab user: andy tags: amg-string-insert
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to tests/string.test.

1320
1321
1322
1323
1324
1325
1326



1327
1328
1329



1330
1331
1332



1333
1334
1335
1336
1337



1338
1339
1340



1341
1342
1343



1344
1345



1346
1347
1348
1349



1350
1351



1352
1353
1354
1355



1356
1357
1358



1359
1360
1361



1362
1363
1364



1365
1366
1367



1368
1369
1370



1371
1372
1373



1374
1375
1376



1377
1378
1379
1380
1381
1382
1383
    # The string range will ensure us that string repeat gets a unicode string
    string repeat [string range ab\u7266cd 2 3] 3
} \u7266c\u7266c\u7266c

test string-14.1 {string replace} {
    list [catch {string replace} msg] $msg
} {1 {wrong # args: should be "string replace string first last ?string?"}}



test string-14.2 {string replace} {
    list [catch {string replace a 1} msg] $msg
} {1 {wrong # args: should be "string replace string first last ?string?"}}



test string-14.3 {string replace} {
    list [catch {string replace a 1 2 3 4} msg] $msg
} {1 {wrong # args: should be "string replace string first last ?string?"}}



test string-14.4 {string replace} {
} {}
test string-14.5 {string replace} {
    string replace abcdefghijklmnop 2 14
} {abp}



test string-14.6 {string replace} {
    string replace abcdefghijklmnop 7 1000
} {abcdefg}



test string-14.7 {string replace} {
    string replace abcdefghijklmnop 10 end
} {abcdefghij}



test string-14.8 {string replace} {
    string replace abcdefghijklmnop 10 9



} {abcdefghijklmnop}
test string-14.9 {string replace} {
    string replace abcdefghijklmnop -3 2
} {defghijklmnop}



test string-14.10 {string replace} {
    string replace abcdefghijklmnop -3 -2



} {abcdefghijklmnop}
test string-14.11 {string replace} {
    string replace abcdefghijklmnop 1000 1010
} {abcdefghijklmnop}



test string-14.12 {string replace} {
    string replace abcdefghijklmnop -100 end
} {}



test string-14.13 {string replace} {
    list [catch {string replace abc abc 1} msg] $msg
} {1 {bad index "abc": must be integer?[+-]integer? or end?[+-]integer?}}



test string-14.14 {string replace} {
    list [catch {string replace abc 1 eof} msg] $msg
} {1 {bad index "eof": must be integer?[+-]integer? or end?[+-]integer?}}



test string-14.15 {string replace} {
    string replace abcdefghijklmnop end-10 end-2 NEW
} {abcdeNEWop}



test string-14.16 {string replace} {
    string replace abcdefghijklmnop 0 end foo
} {foo}



test string-14.17 {string replace} {
    string replace abcdefghijklmnop end end-1
} {abcdefghijklmnop}



test string-14.18 {string replace} {
    string replace abcdefghijklmnop 10 9 XXX
} {abcdefghijklmnop}




test string-15.1 {string tolower too few args} {
    list [catch {string tolower} msg] $msg
} {1 {wrong # args: should be "string tolower string ?first? ?last?"}}
test string-15.2 {string tolower bad args} {
    list [catch {string tolower a b} msg] $msg
} {1 {bad index "b": must be integer?[+-]integer? or end?[+-]integer?}}







>
>
>



>
>
>



>
>
>





>
>
>



>
>
>



>
>
>


>
>
>




>
>
>


>
>
>




>
>
>



>
>
>



>
>
>



>
>
>



>
>
>



>
>
>



>
>
>



>
>
>







1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
    # The string range will ensure us that string repeat gets a unicode string
    string repeat [string range ab\u7266cd 2 3] 3
} \u7266c\u7266c\u7266c

test string-14.1 {string replace} {
    list [catch {string replace} msg] $msg
} {1 {wrong # args: should be "string replace string first last ?string?"}}
test string-14.1.1 {string replace non-bytecode} {
    list [catch {{*}[list string replace]} msg] $msg
} {1 {wrong # args: should be "string replace string first last ?string?"}}
test string-14.2 {string replace} {
    list [catch {string replace a 1} msg] $msg
} {1 {wrong # args: should be "string replace string first last ?string?"}}
test string-14.2.1 {string replace non-bytecode} {
    list [catch {{*}[list string replace] a 1} msg] $msg
} {1 {wrong # args: should be "string replace string first last ?string?"}}
test string-14.3 {string replace} {
    list [catch {string replace a 1 2 3 4} msg] $msg
} {1 {wrong # args: should be "string replace string first last ?string?"}}
test string-14.3.1 {string replace non-bytecode} {
    list [catch {{*}[list string replace] a 1 2 3 4} msg] $msg
} {1 {wrong # args: should be "string replace string first last ?string?"}}
test string-14.4 {string replace} {
} {}
test string-14.5 {string replace} {
    string replace abcdefghijklmnop 2 14
} {abp}
test string-14.5.1 {string replace non-bytecode} {
    {*}[list string replace] abcdefghijklmnop 2 14
} {abp}
test string-14.6 {string replace} {
    string replace abcdefghijklmnop 7 1000
} {abcdefg}
test string-14.6.1 {string replace non-bytecode} {
    {*}[list string replace] abcdefghijklmnop 7 1000
} {abcdefg}
test string-14.7 {string replace} {
    string replace abcdefghijklmnop 10 end
} {abcdefghij}
test string-14.7.1 {string replace non-bytecode} {
    {*}[list string replace] abcdefghijklmnop 10 end
} {abcdefghij}
test string-14.8 {string replace} {
    string replace abcdefghijklmnop 10 9
} {abcdefghijklmnop}
test string-14.8.1 {string replace non-bytecode} {
    {*}[list string replace] abcdefghijklmnop 10 9
} {abcdefghijklmnop}
test string-14.9 {string replace} {
    string replace abcdefghijklmnop -3 2
} {defghijklmnop}
test string-14.9.1 {string replace non-bytecode} {
    {*}[list string replace] abcdefghijklmnop -3 2
} {defghijklmnop}
test string-14.10 {string replace} {
    string replace abcdefghijklmnop -3 -2
} {abcdefghijklmnop}
test string-14.10.1 {string replace non-bytecode} {
    {*}[list string replace] abcdefghijklmnop -3 -2
} {abcdefghijklmnop}
test string-14.11 {string replace} {
    string replace abcdefghijklmnop 1000 1010
} {abcdefghijklmnop}
test string-14.11.1 {string replace non-bytecode} {
    {*}[list string replace] abcdefghijklmnop 1000 1010
} {abcdefghijklmnop}
test string-14.12 {string replace} {
    string replace abcdefghijklmnop -100 end
} {}
test string-14.12.1 {string replace non-bytecode} {
    {*}[list string replace] abcdefghijklmnop -100 end
} {}
test string-14.13 {string replace} {
    list [catch {string replace abc abc 1} msg] $msg
} {1 {bad index "abc": must be integer?[+-]integer? or end?[+-]integer?}}
test string-14.13.1 {string replace non-bytecode} {
    list [catch {{*}[list string replace] abc abc 1} msg] $msg
} {1 {bad index "abc": must be integer?[+-]integer? or end?[+-]integer?}}
test string-14.14 {string replace} {
    list [catch {string replace abc 1 eof} msg] $msg
} {1 {bad index "eof": must be integer?[+-]integer? or end?[+-]integer?}}
test string-14.14.1 {string replace non-bytecode} {
    list [catch {{*}[list string replace] abc 1 eof} msg] $msg
} {1 {bad index "eof": must be integer?[+-]integer? or end?[+-]integer?}}
test string-14.15 {string replace} {
    string replace abcdefghijklmnop end-10 end-2 NEW
} {abcdeNEWop}
test string-14.15.1 {string replace non-bytecode} {
    {*}[list string replace] abcdefghijklmnop end-10 end-2 NEW
} {abcdeNEWop}
test string-14.16 {string replace} {
    string replace abcdefghijklmnop 0 end foo
} {foo}
test string-14.16.1 {string replace non-bytecode} {
    {*}[list string replace] abcdefghijklmnop 0 end foo
} {foo}
test string-14.17 {string replace} {
    string replace abcdefghijklmnop end end-1
} {abcdefghijklmnop}
test string-14.17.1 {string replace non-bytecode} {
    {*}[list string replace] abcdefghijklmnop end end-1
} {abcdefghijklmnop}
test string-14.18 {string replace} {
    string replace abcdefghijklmnop 10 9 XXX
} {abcdefghijklmnop}
test string-14.18.1 {string replace non-bytecode} {
    {*}[list string replace] abcdefghijklmnop 10 9 XXX
} {abcdefghijklmnop}

test string-15.1 {string tolower too few args} {
    list [catch {string tolower} msg] $msg
} {1 {wrong # args: should be "string tolower string ?first? ?last?"}}
test string-15.2 {string tolower bad args} {
    list [catch {string tolower a b} msg] $msg
} {1 {bad index "b": must be integer?[+-]integer? or end?[+-]integer?}}