Index: tests/disposition.test =================================================================== diff -u -rdc94a1f141b1c6a106d0ee142c9df2743ac82e67 -rfca63858221119209f3730ed2e1b997316c1e5e6 --- tests/disposition.test (.../disposition.test) (revision dc94a1f141b1c6a106d0ee142c9df2743ac82e67) +++ tests/disposition.test (.../disposition.test) (revision fca63858221119209f3730ed2e1b997316c1e5e6) @@ -431,16 +431,16 @@ ? {[R new -foo t f] eval {info exists :bar}} "expected true but got \"f\" as return value" R setObjectParams [list -foo:alias,true bar:alias,false \ - [list baz:alias,wideinteger,substdefault {[expr {2 ** 63}]}]] + [list baz:alias,wideinteger,substdefault {[expr {2 ** 63 - 1}]}]] ::nsf::method::property R $methods(bar) returns boolean set methods(baz) [R public method baz {z:wideinteger} -returns int32 { set :baz $z }] ? {[R new -foo t f [expr {2 ** 31}]] eval {info exists :foo}} 1 - ? {[R new -foo t f] eval {info exists :baz}} "expected int32 but got \"[expr {2 ** 63}]\" as return value" - ? {[R new -foo t f] eval {info exists :baz}} "expected int32 but got \"[expr {2 ** 63}]\" as return value" + ? {[R new -foo t f] eval {info exists :baz}} "expected int32 but got \"[expr {2 ** 63 - 1}]\" as return value" + ? {[R new -foo t f] eval {info exists :baz}} "expected int32 but got \"[expr {2 ** 63 - 1}]\" as return value" ::nsf::method::property R $methods(baz) returns wideinteger ? {string is wideinteger [[R new -foo t f] eval {set :baz}]} 1 Index: tests/parameters.test =================================================================== diff -u -r2a955681817e4db4776d7ae904babe8053c5ad74 -rfca63858221119209f3730ed2e1b997316c1e5e6 --- tests/parameters.test (.../parameters.test) (revision 2a955681817e4db4776d7ae904babe8053c5ad74) +++ tests/parameters.test (.../parameters.test) (revision fca63858221119209f3730ed2e1b997316c1e5e6) @@ -2200,75 +2200,157 @@ :public object method baz {x:double} { return $x } } - # - # In Tcl 8.5, "integer" means 32 bit integer - # - ? [list string is integer [expr {2 ** 31}]] 1 - ? [list string is integer [expr {2 ** 32}]] 0 - ? {o foo [expr {2 ** 16}]} "65536" - ? {o foo [expr {2 ** 31}]} "2147483648" - #? {o foo [expr {2 ** 32}]} {expected integer but got "4294967296" for parameter "x"} - ? {o foo [expr {2 ** 32}]} "4294967296" + if {![string is integer [expr {2 ** 32}]]} { + # + # pre TIP 514 (< 8.7a2) + # see https://core.tcl.tk/tips/doc/trunk/tip/514.md + # + # + # In Tcl 8.5, "integer" means 32 bit integer + # + ? [list string is integer [expr {2 ** 31}]] 1 + ? [list string is integer [expr {2 ** 32}]] 0 + ? {o foo [expr {2 ** 16}]} "65536" + ? {o foo [expr {2 ** 31}]} "2147483648" + #? {o foo [expr {2 ** 32}]} {expected integer but got "4294967296" for parameter "x"} + ? {o foo [expr {2 ** 32}]} "4294967296" + + + ? [list string is integer [expr {2 ** 63}]] 0 + ? [list string is integer [expr {2 ** 64}]] 0 + #? {o foo [expr {2 ** 63}]} {expected integer but got "9223372036854775808" for parameter "x"} + #? {o foo [expr {2 ** 64}]} {expected integer but got "18446744073709551616" for parameter "x"} + ? {o foo [expr {2 ** 63}]} "9223372036854775808" + ? {o foo [expr {2 ** 64}]} "18446744073709551616" + ? {o foo [expr {2 ** 128}]} "340282366920938463463374607431768211456" + + ? {o foo [expr {wide(2 ** 63)}]} "-9223372036854775808" + + ? {o foo [expr {2.0}]} {expected integer but got "2.0" for parameter "x"} + ? {o foo [expr {2.0 * 2}]} {expected integer but got "4.0" for parameter "x"} + + # + # Note: In Tcl version less or equal 8.5.9 (to be precise, before + # fossil check-in 769801ace1) there is a rounding issue for + # doubles. It can be worked around by setting the tcl precision + # level sufficiently high (see below). With check-in 769801ace1, or + # with the 8.5.10 release version of Tcl, this work-around becomes + # obsolete. + # + if {[::package vcompare [::info patchlevel] 8.5.9] < 1} { + set ::nsf::savedTclPrecision $::tcl_precision + set ::tcl_precision 17 + } + + ? {o foo [expr {2.0 ** 128}]} {expected integer but got "3.4028236692093846e+38" for parameter "x"} + ? {o foo [expr {(2 ** 128)*1.0}]} {expected integer but got "3.4028236692093846e+38" for parameter "x"} + + if {[info exists ::nsf::savedTclPrecision]} { + set ::tcl_precision $::nsf::savedTclPrecision + unset ::nsf::savedTclPrecision + } + + ? {o foo32 [expr {2 ** 31}]} "2147483648" + ? {o foo32 [expr {2 ** 32}]} {expected int32 but got "4294967296" for parameter "x"} + + # + # In Tcl 8.5, "wideinteger" means 64 bit integer + # + ? [list string is wideinteger [expr {2 ** 63}]] 1 + ? [list string is wideinteger [expr {2 ** 64}]] 0 + ? {o bar [expr {2 ** 63}]} "9223372036854775808" + ? {o bar [expr {2 ** 64}]} {expected wideinteger but got "18446744073709551616" for parameter "x"} + + ? [list string is wideinteger [expr {wide(2 ** 64)}]] 1 + ? {o bar [expr {wide(2 ** 63)}]} "-9223372036854775808" + ? {o bar [expr {wide(2 ** 64)}]} "0" + + # + # In Tcl 8.5, "bignums" have to be checked with "double" + # + ? [list string is double [expr {2 ** 63}]] 1 + ? [list string is double [expr {2 ** 64}]] 1 + ? {o baz [expr {2 ** 63}]} "9223372036854775808" + ? {o baz [expr {2 ** 64}]} "18446744073709551616" + ? {o baz [expr {2 ** 128}]} "340282366920938463463374607431768211456" + + } else { - ? [list string is integer [expr {2 ** 63}]] 0 - ? [list string is integer [expr {2 ** 64}]] 0 - #? {o foo [expr {2 ** 63}]} {expected integer but got "9223372036854775808" for parameter "x"} - #? {o foo [expr {2 ** 64}]} {expected integer but got "18446744073709551616" for parameter "x"} - ? {o foo [expr {2 ** 63}]} "9223372036854775808" - ? {o foo [expr {2 ** 64}]} "18446744073709551616" - ? {o foo [expr {2 ** 128}]} "340282366920938463463374607431768211456" + # + # post TIP 514 (>= 8.7a2) + # see https://core.tcl.tk/tips/doc/trunk/tip/514.md + # + # [string is integer] is now equivalent to [string is entier], and + # does not perform any representational range checks anymore. + # - ? {o foo [expr {wide(2 ** 63)}]} "-9223372036854775808" + # + # [string is integer] means arbitrary-bit integers (equiv. to entier) + # + ? [list string is integer [expr {2 ** 31}]] 1 + ? [list string is integer [expr {2 ** 32}]] 1 + ? [list nsf::is int32 [expr {2 ** 32}]] 0 + ? [list nsf::is int32 [expr {2 ** 32 - 1}]] 1 - ? {o foo [expr {2.0}]} {expected integer but got "2.0" for parameter "x"} - ? {o foo [expr {2.0 * 2}]} {expected integer but got "4.0" for parameter "x"} + ? {o foo [expr {2 ** 16}]} "65536" + ? {o foo [expr {2 ** 31}]} "2147483648" + ? {o foo [expr {2 ** 32}]} "4294967296" + + + ? [list string is integer [expr {2 ** 63 - 1}]] 1 + ? [list string is integer [expr {2 ** 64}]] 1 + ? [list nsf::is int32 [expr {2 ** 63 - 1}]] 0 + ? {o foo [expr {2 ** 63}]} "9223372036854775808" + ? {o foo [expr {2 ** 64}]} "18446744073709551616" + ? {o foo [expr {2 ** 128}]} "340282366920938463463374607431768211456" + + ? {o foo [expr {wide(2 ** 63)}]} "-9223372036854775808" + + ? {o foo [expr {2.0}]} {expected integer but got "2.0" for parameter "x"} + ? {o foo [expr {2.0 * 2}]} {expected integer but got "4.0" for parameter "x"} + + ? {o foo [expr {2.0 ** 128}]} {expected integer but got "3.4028236692093846e+38" for parameter "x"} + ? {o foo [expr {(2 ** 128)*1.0}]} {expected integer but got "3.4028236692093846e+38" for parameter "x"} + + ? {o foo32 [expr {2 ** 31}]} "2147483648" + ? {o foo32 [expr {2 ** 32}]} {expected int32 but got "4294967296" for parameter "x"} - # - # Note: In Tcl version less or equal 8.5.9 (to be precise, before - # fossil check-in 769801ace1) there is a rounding issue for - # doubles. It can be worked around by setting the tcl precision - # level sufficiently high (see below). With check-in 769801ace1, or - # with the 8.5.10 release version of Tcl, this work-around becomes - # obsolete. - # - if {[::package vcompare [::info patchlevel] 8.5.9] < 1} { - set ::nsf::savedTclPrecision $::tcl_precision - set ::tcl_precision 17 - } + # [string is wide] is now more picky about the upper 64-bit int bound: 2^63-1, and not 2^63 + + ? [list string is wideinteger [expr {2 ** 63 - 1}]] 1 + ? [list string is wideinteger [expr {2 ** 63}]] 0 + ? {o bar [expr {2 ** 63 - 1}]} "9223372036854775807" + ? {o bar [expr {2 ** 64}]} {expected wideinteger but got "18446744073709551616" for parameter "x"} + + ? [list string is wideinteger [expr {wide(2 ** 64)}]] 1 + ? {o bar [expr {wide(2 ** 63)}]} "-9223372036854775808" + ? {o bar [expr {wide(2 ** 64)}]} "0" - ? {o foo [expr {2.0 ** 128}]} {expected integer but got "3.4028236692093846e+38" for parameter "x"} - ? {o foo [expr {(2 ** 128)*1.0}]} {expected integer but got "3.4028236692093846e+38" for parameter "x"} + # + # [string is integer] will accept arbitrarily sized numeric + # strings (no range check) + # - if {[info exists ::nsf::savedTclPrecision]} { - set ::tcl_precision $::nsf::savedTclPrecision - unset ::nsf::savedTclPrecision - } + ? [list string is int [expr {2 ** 63}]] 1 + ? [list string is int [expr {2 ** 64}]] 1 + ? {o baz [expr {2 ** 63}]} "9223372036854775808" + ? {o baz [expr {2 ** 64}]} "18446744073709551616" + ? {o baz [expr {2 ** 128}]} "340282366920938463463374607431768211456" - ? {o foo32 [expr {2 ** 31}]} "2147483648" - ? {o foo32 [expr {2 ** 32}]} {expected int32 but got "4294967296" for parameter "x"} + # + # [string is double] will accept arbitrarily sized doubles (no + # range check) + # - # - # In Tcl 8.5, "wideinteger" means 64 bit integer - # - ? [list string is wideinteger [expr {2 ** 63}]] 1 - ? [list string is wideinteger [expr {2 ** 64}]] 0 - ? {o bar [expr {2 ** 63}]} "9223372036854775808" - ? {o bar [expr {2 ** 64}]} {expected wideinteger but got "18446744073709551616" for parameter "x"} - - ? [list string is wideinteger [expr {wide(2 ** 64)}]] 1 - ? {o bar [expr {wide(2 ** 63)}]} "-9223372036854775808" - ? {o bar [expr {wide(2 ** 64)}]} "0" - - # - # In Tcl 8.5, "bignums" have to be checked with "double" - # - ? [list string is double [expr {2 ** 63}]] 1 - ? [list string is double [expr {2 ** 64}]] 1 - ? {o baz [expr {2 ** 63}]} "9223372036854775808" - ? {o baz [expr {2 ** 64}]} "18446744073709551616" - ? {o baz [expr {2 ** 128}]} "340282366920938463463374607431768211456" - + ? [list string is double [expr {2 ** 63 * 0.1}]] 1 + ? [list string is double [expr {2 ** 64 * 0.1}]] 1 + ? {o baz [expr {2 ** 63 * 0.1}]} "9.223372036854776e+17" + ? {o baz [expr {2 ** 64 * 0.1}]} "1.8446744073709553e+18" + ? {o baz [expr {2 ** 128 * 0.1}]} "3.402823669209385e+37" + + + } } nx::test case reconfigure-perobj-default {