Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Changes In Branch bug-9c258a841a-tests Excluding Merge-Ins
This is equivalent to a diff from 7083ff878b to 596ea2447c
|
2024-06-19
| ||
| 09:25 | Merge trunk Closed-Leaf check-in: 19ff51752b user: jan.nijtmans tags: tip-697 | |
|
2024-06-07
| ||
| 11:08 | Copy Jan's Tk ICU interface check-in: 866acc143b user: apnadkarni tags: apn-experiment-chardet | |
|
2024-06-03
| ||
| 10:05 | Reduce test set in 3 ways: 1) 'll' means no trunction, which is not C99-compatible. 2) 'p' is platfo... Closed-Leaf check-in: 596ea2447c user: jan.nijtmans tags: bug-9c258a841a-tests | |
|
2024-05-31
| ||
| 16:50 | Rebase to TIP #697 branch, let's see how far we got check-in: 29add71ca8 user: jan.nijtmans tags: bug-9c258a841a-tests | |
| 14:39 | Rebase to 9.0 check-in: 7083ff878b user: jan.nijtmans tags: tip-697 | |
| 14:32 | Since int() doesn't truncate any more (TIP #514), adapt the documentation accordingly check-in: 219bbcbe5e user: jan.nijtmans tags: trunk, main | |
| 13:21 | Make last test-cases pass check-in: 387194d896 user: jan.nijtmans tags: tip-697 | |
Changes to generic/tclTest.c.
| ︙ | |||
336 337 338 339 340 341 342 343 344 345 346 347 348 349 | 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 | + |
static Tcl_ObjCmdProc TestNREUnwind;
static Tcl_ObjCmdProc TestNRELevels;
static Tcl_ObjCmdProc TestInterpResolverCmd;
#if defined(HAVE_CPUID) && !defined(MAC_OSX_TCL)
static Tcl_ObjCmdProc TestcpuidCmd;
#endif
static Tcl_ObjCmdProc TestApplyLambdaObjCmd;
static Tcl_ObjCmdProc C99Format;
static const Tcl_Filesystem testReportingFilesystem = {
"reporting",
sizeof(Tcl_Filesystem),
TCL_FILESYSTEM_VERSION_1,
TestReportInFilesystem, /* path in */
TestReportDupInternalRep,
|
| ︙ | |||
710 711 712 713 714 715 716 717 718 719 720 721 722 723 | 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 | + + |
Tcl_CreateObjCommand(interp, "testnreunwind", TestNREUnwind,
NULL, NULL);
Tcl_CreateObjCommand(interp, "testnrelevels", TestNRELevels,
NULL, NULL);
Tcl_CreateObjCommand(interp, "testinterpresolver", TestInterpResolverCmd,
NULL, NULL);
Tcl_CreateObjCommand(interp, "testapplylambda", TestApplyLambdaObjCmd,
NULL, NULL);
Tcl_CreateObjCommand(interp, "c99format", C99Format,
NULL, NULL);
Tcl_CreateObjCommand(interp, "testlutil", TestLutilCmd,
NULL, NULL);
if (TclObjTest_Init(interp) != TCL_OK) {
return TCL_ERROR;
}
|
| ︙ | |||
8757 8758 8759 8760 8761 8762 8763 8764 8765 8766 8767 8768 8769 8770 8771 8772 | 8760 8761 8762 8763 8764 8765 8766 8767 8768 8769 8770 8771 8772 8773 8774 8775 8776 8777 8778 8779 8780 8781 8782 8783 8784 8785 8786 8787 8788 8789 8790 8791 8792 8793 8794 8795 8796 8797 8798 8799 8800 8801 8802 8803 8804 8805 8806 8807 8808 8809 8810 8811 8812 8813 8814 8815 8816 8817 8818 8819 8820 8821 8822 8823 8824 8825 8826 8827 8828 8829 8830 8831 8832 8833 8834 8835 8836 8837 8838 8839 8840 8841 8842 8843 8844 8845 8846 8847 8848 8849 8850 8851 8852 8853 8854 8855 8856 8857 8858 8859 8860 8861 8862 8863 8864 8865 8866 8867 8868 8869 8870 8871 8872 8873 8874 8875 8876 8877 8878 8879 8880 8881 8882 8883 8884 8885 8886 8887 8888 8889 8890 8891 8892 8893 8894 8895 8896 8897 8898 8899 8900 8901 8902 8903 8904 8905 8906 8907 8908 8909 8910 8911 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + |
}
if (l2Obj) {
Tcl_DecrRefCount(l2Obj);
}
return ret;
}
/*
*------------------------------------------------------------------------
*
* C99Format --
*
* Returns a C99 formatted printf string as interpreter result.
* Does not actually *test* anything.
*
* Does not handle XPG3 or presence of "*" in width/precision.
*
* Results:
* TCL_OK
* TCL_ERROR
*
*------------------------------------------------------------------------
*/
static int
C99Format(
TCL_UNUSED(void *),
Tcl_Interp *interp,
int objc,
Tcl_Obj *const objv[])
{
double dbl;
Tcl_WideInt wide;
char fmt[100];
char buf[256];
Tcl_Size len;
const char *otherSpec;
const char *sizeSpec;
const char *typeSpec;
Tcl_Obj *valueObj;
if (objc < 3 || objc > 5) {
/*
* Order of components is same as in format specifier but some optional
*/
Tcl_WrongNumArgs(interp, 1, objv, "? ?otherspec? size? type value");
return TCL_ERROR;
}
valueObj = objv[objc - 1];
typeSpec = Tcl_GetStringFromObj(objv[objc - 2], &len);
if (len != 1) {
Tcl_AppendResult(
interp, "Invalid type specifier: ", typeSpec, (char *)NULL);
return TCL_ERROR;
}
sizeSpec = otherSpec = "";
if (objc > 3) {
sizeSpec = Tcl_GetString(objv[objc-3]);
if (objc > 4) {
otherSpec = Tcl_GetString(objv[objc - 4]);
}
}
snprintf(fmt, sizeof(fmt), "%%%s%s%s", otherSpec, sizeSpec, typeSpec);
#define PRINTIF(spec_, type_, val_) \
do { \
if (!strcmp(spec_, sizeSpec)) { \
snprintf(buf, sizeof(buf), fmt, (type_)(val_)); \
goto done; \
} \
} while (0)
buf[0] = 0;
switch (*typeSpec) {
/* Doubles */
case 'f':
case 'a':
case 'A':
case 'e':
case 'E':
case 'g':
case 'G':
if (Tcl_GetDoubleFromObj(interp, valueObj, &dbl) != TCL_OK) {
return TCL_ERROR;
}
snprintf(buf, sizeof(buf), fmt, dbl);
break;
/* Integers */
case 'd':
case 'u':
case 'i':
case 'o':
case 'x':
case 'X':
case 'p':
/*
* C does not distinguish between signed vs unsigned passed to printf.
* Below assumes Tcl_WideInt enough for all C integer types of interest.
*/
if (Tcl_GetWideIntFromObj(NULL, valueObj, &wide) != TCL_OK) {
Tcl_WideUInt uwide;
if (Tcl_GetWideUIntFromObj(interp, valueObj, &uwide) !=
TCL_OK) {
return TCL_ERROR;
}
wide = (Tcl_WideInt)uwide;
}
/*
* Code below relies on printf passing signed/unsigned the same way
* else we would have to distinguish between "d" and "u" etc.
*/
PRINTIF("", int, wide);
PRINTIF("hh", int, wide);
PRINTIF("h", int, wide);
PRINTIF("l", long, wide);
PRINTIF("ll", long long, wide);
PRINTIF("t", ptrdiff_t, wide);
PRINTIF("z", size_t, wide);
PRINTIF("j", intmax_t, wide);
#ifdef _WIN32
PRINTIF("I32", int32_t, wide);
PRINTIF("I64", int64_t, wide);
#endif
Tcl_AppendResult(
interp, "Invalid size specifier: ", sizeSpec, (char *)NULL);
return TCL_ERROR;
default:
Tcl_AppendResult(
interp, "Invalid type specifier: ", typeSpec, (char *)NULL);
return TCL_ERROR;
}
done:
Tcl_SetObjResult(interp, Tcl_NewStringObj(buf, -1));
return TCL_OK;
}
/*
* Local Variables:
* mode: c
* c-basic-offset: 4
* fill-column: 78
* tab-width: 8
* indent-tabs-mode: nil
* End:
*/
|
Changes to tests/format.test.
| ︙ | |||
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | + + |
if {"::tcltest" ni [namespace children]} {
package require tcltest 2.5
namespace import -force ::tcltest::*
}
# %z/%t/%p output depends on pointerSize, so some tests are not portable.
testConstraint pointerIs64bit [expr {$tcl_platform(pointerSize) >= 8}]
testConstraint longIs64bit [expr {$tcl_platform(wordSize) >= 8}]
# MSVC uses a broken libc that gets sprintf("%g") wrong. This is a pain
# particularly in Continuous Integration, and there isn't anything much we can
# do about it.
testConstraint knownMsvcBug [expr {![string match msvc-* [tcl::build-info compiler]]}]
testConstraint c99format [expr {[llength [info commands ::c99format]] != 0}]
test format-1.1 {integer formatting} {
format "%*d %d %d %d" 6 34 16923 -12 -1
} { 34 16923 -12 -1}
test format-1.2 {integer formatting} {
format "%4d %4d %4d %4d %d %#x %#X" 6 34 16923 -12 -1 14 12
} { 6 34 16923 -12 -1 0xe 0xC}
|
| ︙ | |||
604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 | 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + |
format %s $x
# After this, obj in $x should be a dict
# We are testing to make sure it has not been shimmered to a
# different internalrep when that is not necessary.
# Whether or not there is a string rep - we should not care!
tcl::unsupported::representation $x
} -match glob -result {value is a dict *}
#
# Match up formatting against C99
foreach type {f a A e E g G} {
set testNum 0
foreach dbl {0} {
test format-c99-$type-[incr testNum] \
"Compare c99format %$type $dbl" \
-constraints c99format -body {
format %$type $dbl
} -result [c99format $type $dbl]
}
}
set sizeSpecs [list {} h l t z j]
if {$::tcl_platform(platform) eq "windows"} {
lappend sizeSpecs I32 I64
}
foreach type {d u i o x X} {
set testNum 0
foreach size $sizeSpecs {
foreach ival {
0 0x1 0x7fff 0xffff
0x10001 0x7fffffff 0x80000000 0xffffffff
0x100000001 0x7fffffffffffffff 0x8000000000000000 0xffffffffffffffff
} {
test format-c99-$type-$size-[incr testNum] \
"Compare c99format %$size$type $ival" \
-constraints {c99format longIs64bit} -body {
format %$size$type $ival
} -result [c99format $size $type $ival]
}
}
}
# cleanup
catch {unset a}
catch {unset b}
catch {unset c}
catch {unset d}
::tcltest::cleanupTests
return
# Local Variables:
# mode: tcl
# End:
|