Tcl Source Code

Check-in [53f9e431af]
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

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

Overview
Comment:more test cases (covering vice versa situations: hashed as string in dict/var and search for integer)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | tip-534-sebres-fast-number-hash
Files: files | file ages | folders
SHA3-256: 53f9e431afed7f121574ec07706b6b35228c9580385e2da7d6512baddc909072
User & Date: sebres 2019-05-17 21:56:31
Context
2019-05-17
21:56
more test cases (covering vice versa situations: hashed as string in dict/var and search for integer... Leaf check-in: 53f9e431af user: sebres tags: tip-534-sebres-fast-number-hash
21:54
code review check-in: 7f19c9f6b1 user: sebres tags: tip-534-sebres-fast-number-hash
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to tests/dict.test.

829
830
831
832
833
834
835

836
837
838

839
840
841
842

843
844

845
846
847
848
849
850
851
	0x55555555 0xaaaaaaaa 0x7fffffff 0xffffffff
	0x5555555555555555 0xaaaaaaaaaaaaaaaa 0x7fffffffffffffff 0xffffffffffffffff
	0x7fffffffffffffffffffffffffffffff 0xffffffffffffffffffffffffffffffff
    } {
	# not canonical int's (positive / negative):
	expr {$i}; # make int
	dict set d $i 1; dict get $d [string trim "$i "]; dict unset d $i

	set j -$i
	expr {$j}; # make int
	dict set d $j 1; dict get $d [string trim "$j "]; dict unset d $j

	# canonical int form (positive / negative):
	set i [expr {$i - 5}]
	time { 
	    dict set d [incr i] 1; dict get $d [string trim "$i "]; dict unset d $i

	    set j [expr {-$i}]
	    dict set d [incr j] 1; dict get $d [string trim "$j "]; dict unset d $j

	} 10
    }
    dict size $d
} -cleanup {
    unset -nocomplain d
} -result 0







>



>




>


>







829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
	0x55555555 0xaaaaaaaa 0x7fffffff 0xffffffff
	0x5555555555555555 0xaaaaaaaaaaaaaaaa 0x7fffffffffffffff 0xffffffffffffffff
	0x7fffffffffffffffffffffffffffffff 0xffffffffffffffffffffffffffffffff
    } {
	# not canonical int's (positive / negative):
	expr {$i}; # make int
	dict set d $i 1; dict get $d [string trim "$i "]; dict unset d $i
	dict set d [string trim "$i "] 2; dict unset d $i
	set j -$i
	expr {$j}; # make int
	dict set d $j 1; dict get $d [string trim "$j "]; dict unset d $j
	dict set d [string trim "$j "] 2; dict unset d $j
	# canonical int form (positive / negative):
	set i [expr {$i - 5}]
	time { 
	    dict set d [incr i] 1; dict get $d [string trim "$i "]; dict unset d $i
	    dict set d [string trim "$i "] 2; incr i; incr i -1; dict unset d $i
	    set j [expr {-$i}]
	    dict set d [incr j] 1; dict get $d [string trim "$j "]; dict unset d $j
	    dict set d [string trim "$j "] 2; incr j; incr j -1; dict unset d $j
	} 10
    }
    dict size $d
} -cleanup {
    unset -nocomplain d
} -result 0

Changes to tests/var.test.

1490
1491
1492
1493
1494
1495
1496

1497
1498
1499

1500
1501
1502
1503

1504
1505

1506
1507
1508
1509
1510
1511
1512
	0x55555555 0xaaaaaaaa 0x7fffffff 0xffffffff
	0x5555555555555555 0xaaaaaaaaaaaaaaaa 0x7fffffffffffffff 0xffffffffffffffff
	0x7fffffffffffffffffffffffffffffff 0xffffffffffffffffffffffffffffffff
    } {
	# not canonical int's (positive / negative):
	expr {$i}; # make int
	set v($i) 1; set v([string trim "$i "]); unset v($i)

	set j -$i
	expr {$j}; # make int
	set v($j) 1; set v([string trim "$j "]); unset v($j)

	# canonical int form (positive / negative):
	set i [expr {$i - 5}]
	time { 
	    set v([incr i]) 1; set v([string trim "$i "]); unset v($i)

	    set j [expr {-$i}]
	    set v([incr j]) 1; set v([string trim "$j "]); unset v($j)

	} 10
    }
    array size v
} -cleanup {
    unset -nocomplain v
} -result 0
 






>



>




>


>







1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
	0x55555555 0xaaaaaaaa 0x7fffffff 0xffffffff
	0x5555555555555555 0xaaaaaaaaaaaaaaaa 0x7fffffffffffffff 0xffffffffffffffff
	0x7fffffffffffffffffffffffffffffff 0xffffffffffffffffffffffffffffffff
    } {
	# not canonical int's (positive / negative):
	expr {$i}; # make int
	set v($i) 1; set v([string trim "$i "]); unset v($i)
	set v([string trim "$i "]) 2; unset v($i)
	set j -$i
	expr {$j}; # make int
	set v($j) 1; set v([string trim "$j "]); unset v($j)
	set v([string trim "$j "]) 2; unset v($j)
	# canonical int form (positive / negative):
	set i [expr {$i - 5}]
	time { 
	    set v([incr i]) 1; set v([string trim "$i "]); unset v($i)
	    set v([string trim "$i "]) 2; incr i; incr i -1; unset v($i)
	    set j [expr {-$i}]
	    set v([incr j]) 1; set v([string trim "$j "]); unset v($j)
	    set v([string trim "$j "]) 2; incr j; incr j -1; unset v($j)
	} 10
    }
    array size v
} -cleanup {
    unset -nocomplain v
} -result 0