summaryrefslogtreecommitdiffstats
path: root/tests/link.test
diff options
context:
space:
mode:
Diffstat (limited to 'tests/link.test')
-rw-r--r--tests/link.test139
1 files changed, 79 insertions, 60 deletions
diff --git a/tests/link.test b/tests/link.test
index 672185c..3b423ec 100644
--- a/tests/link.test
+++ b/tests/link.test
@@ -16,65 +16,73 @@ if {[lsearch [namespace children] ::tcltest] == -1} {
namespace import -force ::tcltest::*
}
-::tcltest::testConstraint testlink \
- [expr {[info commands testlink] != {}}]
+testConstraint testlink [llength [info commands testlink]]
foreach i {int real bool string} {
catch {unset $i}
}
test link-1.1 {reading C variables from Tcl} {testlink} {
testlink delete
- testlink set 43 1.23 4 - 12341234
- testlink create 1 1 1 1 1
+ testlink set 43 1.23 4 - 12341234 64 250 30000 60000 0xbeefbabe 12321 32123 3.25 1231231234
+ testlink create 1 1 1 1 1 1 1 1 1 1 1 1 1 1
list $int $real $bool $string $wide
} {43 1.23 1 NULL 12341234}
test link-1.2 {reading C variables from Tcl} {testlink} {
testlink delete
- testlink create 1 1 1 1 1
- testlink set -3 2 0 "A long string with spaces" 43214321
+ testlink create 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ testlink set -3 2 0 "A long string with spaces" 43214321 64 250 30000 60000 0xbeefbabe 12321 32123 3.25 1231231234
list $int $real $bool $string $wide $int $real $bool $string $wide
} {-3 2.0 0 {A long string with spaces} 43214321 -3 2.0 0 {A long string with spaces} 43214321}
test link-2.1 {writing C variables from Tcl} {testlink} {
testlink delete
- testlink set 43 1.21 4 - 56785678
- testlink create 1 1 1 1 1
- set int "00721"
+ testlink set 43 1.21 4 - 56785678 64 250 30000 60000 0xbaadbeef 12321 32123 3.25 1231231234
+ testlink create 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ set int "0o0721"
set real -10.5
set bool true
set string abcdef
set wide 135135
- concat [testlink get] $int $real $bool $string $wide
-} {465 -10.5 1 abcdef 135135 00721 -10.5 true abcdef 135135}
+ set char 79
+ set uchar 161
+ set short 8000
+ set ushort 40000
+ set uint 0xc001babe
+ set long 34543
+ set ulong 567890
+ set float 1.0987654321
+ set uwide 357357357357
+ concat [testlink get] | $int $real $bool $string $wide $char $uchar $short $ushort $uint $long $ulong $float $uwide
+} {465 -10.5 1 abcdef 135135 79 161 8000 40000 -1073628482 34543 567890 1.0987653732299805 357357357357 | 0o0721 -10.5 true abcdef 135135 79 161 8000 40000 0xc001babe 34543 567890 1.0987654321 357357357357}
test link-2.2 {writing bad values into variables} {testlink} {
testlink delete
- testlink set 43 1.23 4 - 56785678
- testlink create 1 1 1 1 1
+ testlink set 43 1.23 4 - 56785678 64 250 30000 60000 0xbeefbabe 12321 32123 3.25 1231231234
+ testlink create 1 1 1 1 1 1 1 1 1 1 1 1 1 1
list [catch {set int 09a} msg] $msg $int
} {1 {can't set "int": variable must have integer value} 43}
test link-2.3 {writing bad values into variables} {testlink} {
testlink delete
- testlink set 43 1.23 4 - 56785678
- testlink create 1 1 1 1 1
+ testlink set 43 1.23 4 - 56785678 64 250 30000 60000 0xbeefbabe 12321 32123 3.25 1231231234
+ testlink create 1 1 1 1 1 1 1 1 1 1 1 1 1 1
list [catch {set real 1.x3} msg] $msg $real
} {1 {can't set "real": variable must have real value} 1.23}
test link-2.4 {writing bad values into variables} {testlink} {
testlink delete
- testlink set 43 1.23 4 - 56785678
- testlink create 1 1 1 1 1
+ testlink set 43 1.23 4 - 56785678 64 250 30000 60000 0xbeefbabe 12321 32123 3.25 1231231234
+ testlink create 1 1 1 1 1 1 1 1 1 1 1 1 1 1
list [catch {set bool gorp} msg] $msg $bool
} {1 {can't set "bool": variable must have boolean value} 1}
test link-2.5 {writing bad values into variables} {testlink} {
testlink delete
- testlink set 43 1.23 4 - 56785678
- testlink create 1 1 1 1 1
+ testlink set 43 1.23 4 - 56785678 64 250 30000 60000 0xbeefbabe 12321 32123 3.25 1231231234
+ testlink create 1 1 1 1 1 1 1 1 1 1 1 1 1 1
list [catch {set wide gorp} msg] $msg $bool
} {1 {can't set "wide": variable must have integer value} 1}
test link-3.1 {read-only variables} {testlink} {
testlink delete
- testlink set 43 1.23 4 - 56785678
- testlink create 0 1 1 0 0
+ testlink set 43 1.23 4 - 56785678 64 250 30000 60000 0xbeefbabe 12321 32123 3.25 1231231234
+ testlink create 0 1 1 0 0 0 0 0 0 0 0 0 0 0
list [catch {set int 4} msg] $msg $int \
[catch {set real 10.6} msg] $msg $real \
[catch {set bool no} msg] $msg $bool \
@@ -83,8 +91,8 @@ test link-3.1 {read-only variables} {testlink} {
} {1 {can't set "int": linked variable is read-only} 43 0 10.6 10.6 0 no no 1 {can't set "string": linked variable is read-only} NULL 1 {can't set "wide": linked variable is read-only} 56785678}
test link-3.2 {read-only variables} {testlink} {
testlink delete
- testlink set 43 1.23 4 - 56785678
- testlink create 1 0 0 1 1
+ testlink set 43 1.23 4 - 56785678 64 250 30000 60000 0xbeefbabe 12321 32123 3.25 1231231234
+ testlink create 1 0 0 1 1 0 0 0 0 0 0 0 0 0
list [catch {set int 4} msg] $msg $int \
[catch {set real 10.6} msg] $msg $real \
[catch {set bool no} msg] $msg $bool \
@@ -94,8 +102,8 @@ test link-3.2 {read-only variables} {testlink} {
test link-4.1 {unsetting linked variables} {testlink} {
testlink delete
- testlink set -6 -2.5 0 stringValue 13579
- testlink create 1 1 1 1 1
+ testlink set -6 -2.5 0 stringValue 13579 64 250 30000 60000 0xbeefbabe 12321 32123 3.25 1231231234
+ testlink create 1 1 1 1 1 1 1 1 1 1 1 1 1 1
unset int real bool string wide
list [catch {set int} msg] $msg [catch {set real} msg] $msg \
[catch {set bool} msg] $msg [catch {set string} msg] $msg \
@@ -103,42 +111,51 @@ test link-4.1 {unsetting linked variables} {testlink} {
} {0 -6 0 -2.5 0 0 0 stringValue 0 13579}
test link-4.2 {unsetting linked variables} {testlink} {
testlink delete
- testlink set -6 -2.1 0 stringValue 97531
- testlink create 1 1 1 1 1
+ testlink set -6 -2.1 0 stringValue 97531 64 250 30000 60000 0xbeefbabe 12321 32123 3.25 1231231234
+ testlink create 1 1 1 1 1 1 1 1 1 1 1 1 1 1
unset int real bool string wide
set int 102
set real 16
set bool true
set string newValue
set wide 333555
- testlink get
+ lrange [testlink get] 0 4
} {102 16.0 1 newValue 333555}
test link-5.1 {unlinking variables} {testlink} {
testlink delete
- testlink set -6 -2.25 0 stringValue 13579
+ testlink set -6 -2.25 0 stringValue 13579 64 250 30000 60000 0xbeefbabe 12321 32123 3.25 1231231234
testlink delete
set int xx1
set real qrst
set bool bogus
set string 12345
set wide 875421
+ set char skjdf
+ set uchar dslfjk
+ set short slkf
+ set ushort skrh
+ set uint sfdkfkh
+ set long srkjh
+ set ulong sjkg
+ set float dskjfbjfd
+ set uwide isdfsngs
testlink get
-} {-6 -2.25 0 stringValue 13579}
+} {-6 -2.25 0 stringValue 13579 64 250 30000 60000 -1091585346 12321 32123 3.25 1231231234}
test link-5.2 {unlinking variables} {testlink} {
testlink delete
- testlink set -6 -2.25 0 stringValue 97531
- testlink create 1 1 1 1 1
+ testlink set -6 -2.25 0 stringValue 97531 64 250 30000 60000 0xbeefbabe 12321 32123 3.25 1231231234
+ testlink create 1 1 1 1 1 1 1 1 1 1 1 1 1 1
testlink delete
- testlink set 25 14.7 7 - 999999
- list $int $real $bool $string $wide
-} {-6 -2.25 0 stringValue 97531}
+ testlink set 25 14.7 7 - 999999 65 251 30001 60001 0xbabebeef 12322 32124 3.125 12312312340
+ list $int $real $bool $string $wide $char $uchar $short $ushort $uint $long $ulong $float $uwide
+} {-6 -2.25 0 stringValue 97531 64 250 30000 60000 3203381950 12321 32123 3.25 1231231234}
test link-6.1 {errors in setting up link} {testlink} {
testlink delete
catch {unset int}
set int(44) 1
- list [catch {testlink create 1 1 1 1 1} msg] $msg
+ list [catch {testlink create 1 1 1 1 1 1 1 1 1 1 1 1 1 1} msg] $msg
} {1 {can't set "int": variable is array}}
catch {unset int}
@@ -148,8 +165,8 @@ test link-7.1 {access to linked variables via upvar} {testlink} {
unset y
}
testlink delete
- testlink create 1 0 0 0 0
- testlink set 14 {} {} {} {}
+ testlink create 1 0 0 0 0 0 0 0 0 0 0 0 0 0
+ testlink set 14 {} {} {} {} {} {} {} {} {} {} {} {} {}
x
list [catch {set int} msg] $msg
} {0 14}
@@ -159,10 +176,10 @@ test link-7.2 {access to linked variables via upvar} {testlink} {
return [set y]
}
testlink delete
- testlink create 1 0 0 0 0
- testlink set 0 {} {} {} {}
+ testlink create 1 0 0 0 0 0 0 0 0 0 0 0 0 0
+ testlink set 0 {} {} {} {} {} {} {} {} {} {} {} {} {}
set int
- testlink set 23 {} {} {} {}
+ testlink set 23 {} {} {} {} {} {} {} {} {} {} {} {} {}
x
list [x] $int
} {23 23}
@@ -172,8 +189,8 @@ test link-7.3 {access to linked variables via upvar} {testlink} {
set y 44
}
testlink delete
- testlink create 0 0 0 0 0
- testlink set 11 {} {} {} {}
+ testlink create 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ testlink set 11 {} {} {} {} {} {} {} {} {} {} {} {} {}
list [catch x msg] $msg $int
} {1 {can't set "y": linked variable is read-only} 11}
test link-7.4 {access to linked variables via upvar} {testlink} {
@@ -182,8 +199,8 @@ test link-7.4 {access to linked variables via upvar} {testlink} {
set y abc
}
testlink delete
- testlink create 1 1 1 1 1
- testlink set -4 {} {} {} {}
+ testlink create 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ testlink set -4 {} {} {} {} {} {} {} {} {} {} {} {} {}
list [catch x msg] $msg $int
} {1 {can't set "y": variable must have integer value} -4}
test link-7.5 {access to linked variables via upvar} {testlink} {
@@ -192,8 +209,8 @@ test link-7.5 {access to linked variables via upvar} {testlink} {
set y abc
}
testlink delete
- testlink create 1 1 1 1 1
- testlink set -4 16.75 {} {} {}
+ testlink create 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ testlink set -4 16.75 {} {} {} {} {} {} {} {} {} {} {} {}
list [catch x msg] $msg $real
} {1 {can't set "y": variable must have real value} 16.75}
test link-7.6 {access to linked variables via upvar} {testlink} {
@@ -202,8 +219,8 @@ test link-7.6 {access to linked variables via upvar} {testlink} {
set y abc
}
testlink delete
- testlink create 1 1 1 1 1
- testlink set -4 16.3 1 {} {}
+ testlink create 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ testlink set -4 16.3 1 {} {} {} {} {} {} {} {} {} {} {}
list [catch x msg] $msg $bool
} {1 {can't set "y": variable must have boolean value} 1}
test link-7.7 {access to linked variables via upvar} {testlink} {
@@ -212,8 +229,8 @@ test link-7.7 {access to linked variables via upvar} {testlink} {
set y abc
}
testlink delete
- testlink create 1 1 1 1 1
- testlink set -4 16.3 1 {} 778899
+ testlink create 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ testlink set -4 16.3 1 {} 778899 {} {} {} {} {} {} {} {} {}
list [catch x msg] $msg $wide
} {1 {can't set "y": variable must have integer value} 778899}
@@ -223,10 +240,10 @@ test link-8.1 {Tcl_UpdateLinkedVar procedure} {testlink} {
lappend x $args $int $real $bool $string $wide
}
set x {}
- testlink create 1 1 1 1 1
- testlink set 14 -2.0 0 xyzzy 995511
+ testlink create 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ testlink set 14 -2.0 0 xyzzy 995511 64 250 30000 60000 0xbeefbabe 12321 32123 3.25 1231231234
trace var int w x
- testlink update 32 4.0 3 abcd 113355
+ testlink update 32 4.0 3 abcd 113355 65 251 30001 60001 0xbabebeef 12322 32124 3.125 12312312340
trace vdelete int w x
set x
} {{int {} w} 32 -2.0 0 xyzzy 995511}
@@ -236,20 +253,22 @@ test link-8.2 {Tcl_UpdateLinkedVar procedure} {testlink} {
lappend x $args $int $real $bool $string $wide
}
set x {}
- testlink create 1 1 1 1 1
- testlink set 14 -2.0 0 xyzzy 995511
+ testlink create 1 1 1 1 1 1 1 1 1 1 1 1 1 1
+ testlink set 14 -2.0 0 xyzzy 995511 64 250 30000 60000 0xbeefbabe 12321 32123 3.25 1231231234
testlink delete
trace var int w x
- testlink update 32 4.0 6 abcd 113355
+ testlink update 32 4.0 6 abcd 113355 65 251 30001 60001 0xbabebeef 12322 32124 3.125 12312312340
trace vdelete int w x
set x
} {}
test link-8.3 {Tcl_UpdateLinkedVar procedure, read-only variable} {testlink} {
- testlink create 0 0 0 0 0
- list [catch {testlink update 47 {} {} {} {}} msg] $msg $int
+ testlink create 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ list [catch {
+ testlink update 47 {} {} {} {} {} {} {} {} {} {} {} {} {}
+ } msg] $msg $int
} {0 {} 47}
-catch {testlink set 0 0 0 - 0}
+catch {testlink set 0 0 0 - 0 0 0 0 0 0 0 0 0 0}
catch {testlink delete}
foreach i {int real bool string wide} {
catch {unset $i}