summaryrefslogtreecommitdiffstats
path: root/tests/link.test
diff options
context:
space:
mode:
Diffstat (limited to 'tests/link.test')
-rw-r--r--tests/link.test188
1 files changed, 68 insertions, 120 deletions
diff --git a/tests/link.test b/tests/link.test
index 71f3767..9ff44db 100644
--- a/tests/link.test
+++ b/tests/link.test
@@ -1,48 +1,41 @@
# Commands covered: none
#
-# This file contains a collection of tests for Tcl_LinkVar and related library
-# procedures. Sourcing this file into Tcl runs the tests and generates output
-# for errors. No output means no errors were found.
+# This file contains a collection of tests for Tcl_LinkVar and related
+# library procedures. Sourcing this file into Tcl runs the tests and
+# generates output for errors. No output means no errors were found.
#
# Copyright (c) 1993 The Regents of the University of California.
# Copyright (c) 1994 Sun Microsystems, Inc.
# Copyright (c) 1998-1999 by Scriptics Corporation.
#
-# See the file "license.terms" for information on usage and redistribution of
-# this file, and for a DISCLAIMER OF ALL WARRANTIES.
+# See the file "license.terms" for information on usage and redistribution
+# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-if {"::tcltest" ni [namespace children]} {
+if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest 2
namespace import -force ::tcltest::*
}
-::tcltest::loadTestedCommands
-catch [list package require -exact Tcltest [info patchlevel]]
-
testConstraint testlink [llength [info commands testlink]]
foreach i {int real bool string} {
- unset -nocomplain $i
+ catch {unset $i}
}
-
-test link-1.1 {reading C variables from Tcl} -constraints {testlink} -setup {
+test link-1.1 {reading C variables from Tcl} {testlink} {
testlink delete
-} -body {
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
-} -result {43 1.23 1 NULL 12341234}
-test link-1.2 {reading C variables from Tcl} -constraints {testlink} -setup {
+} {43 1.23 1 NULL 12341234}
+test link-1.2 {reading C variables from Tcl} {testlink} {
testlink delete
-} -body {
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
-} -result {-3 2.0 0 {A long string with spaces} 43214321 -3 2.0 0 {A long string with spaces} 43214321}
+} {-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} -constraints {testlink} -setup {
+test link-2.1 {writing C variables from Tcl} {testlink} {
testlink delete
-} -body {
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"
@@ -60,35 +53,31 @@ test link-2.1 {writing C variables from Tcl} -constraints {testlink} -setup {
set float 1.0987654321
set uwide 357357357357
concat [testlink get] | $int $real $bool $string $wide $char $uchar $short $ushort $uint $long $ulong $float $uwide
-} -result {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} -setup {
+} {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
-} -constraints {testlink} -body {
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
-} -result {1 {can't set "int": variable must have integer or boolean value} 43}
-test link-2.3 {writing bad values into variables} -setup {
+} {1 {can't set "int": variable must have integer value} 43}
+test link-2.3 {writing bad values into variables} {testlink} {
testlink delete
-} -constraints {testlink} -body {
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
-} -result {1 {can't set "real": variable must have real or boolean value} 1.23}
-test link-2.4 {writing bad values into variables} -setup {
+} {1 {can't set "real": variable must have real value} 1.23}
+test link-2.4 {writing bad values into variables} {testlink} {
testlink delete
-} -constraints {testlink} -body {
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
-} -result {1 {can't set "bool": variable must have boolean value} 1}
-test link-2.5 {writing bad values into variables} -setup {
+} {1 {can't set "bool": variable must have boolean value} 1}
+test link-2.5 {writing bad values into variables} {testlink} {
testlink delete
-} -constraints {testlink} -body {
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
-} -result {1 {can't set "wide": variable must have integer or boolean value} 1}
+} {1 {can't set "wide": variable must have integer value} 1}
test link-2.6 {writing C variables from Tcl} -constraints {testlink} -setup {
testlink delete
} -body {
@@ -96,7 +85,7 @@ test link-2.6 {writing C variables from Tcl} -constraints {testlink} -setup {
testlink create 1 1 1 1 1 1 1 1 1 1 1 1 1 1
set int "+"
set real "+"
- set bool "+"
+ set bool 1
set string "+"
set wide "+"
set char "+"
@@ -109,7 +98,7 @@ test link-2.6 {writing C variables from Tcl} -constraints {testlink} -setup {
set float "+"
set uwide "+"
concat [testlink get] | $int $real $bool $string $wide $char $uchar $short $ushort $uint $long $ulong $float $uwide
-} -result {1 1.0 1 + 1 1 1 1 1 1 1 1 1.0 1 | + + + + + + + + + + + + + +}
+} -result {1 1.0 1 + 1 1 1 1 1 1 1 1 1.0 1 | + + 1 + + + + + + + + + + +}
test link-2.7 {writing C variables from Tcl} -constraints {testlink} -setup {
testlink delete
} -body {
@@ -117,7 +106,7 @@ test link-2.7 {writing C variables from Tcl} -constraints {testlink} -setup {
testlink create 1 1 1 1 1 1 1 1 1 1 1 1 1 1
set int "-"
set real "-"
- set bool "-"
+ set bool 0
set string "-"
set wide "-"
set char "-"
@@ -130,28 +119,7 @@ test link-2.7 {writing C variables from Tcl} -constraints {testlink} -setup {
set float "-"
set uwide "-"
concat [testlink get] | $int $real $bool $string $wide $char $uchar $short $ushort $uint $long $ulong $float $uwide
-} -result {0 0.0 0 - 0 0 0 0 0 0 0 0 0.0 0 | - - - - - - - - - - - - - -}
-test link-2.7 {writing C variables from Tcl} -constraints {testlink} -setup {
- testlink delete
-} -body {
- 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 "o"
- set real "."
- set bool "o"
- set string "o"
- set wide "o"
- set char "o"
- set uchar "o"
- set short "o"
- set ushort "o"
- set uint "o"
- set long "o"
- set ulong "o"
- set float "."
- set uwide "o"
- concat [testlink get] | $int $real $bool $string $wide $char $uchar $short $ushort $uint $long $ulong $float $uwide
-} -result {0 0.0 0 o 0 0 0 0 0 0 0 0 0.0 0 | o . o o o o o o o o o o . o}
+} -result {0 0.0 0 - 0 0 0 0 0 0 0 0 0.0 0 | - - 0 - - - - - - - - - - -}
test link-2.8 {writing C variables from Tcl} -constraints {testlink} -setup {
testlink delete
} -body {
@@ -159,7 +127,7 @@ test link-2.8 {writing C variables from Tcl} -constraints {testlink} -setup {
testlink create 1 1 1 1 1 1 1 1 1 1 1 1 1 1
set int "0x"
set real "0b"
- set bool "0"
+ set bool 0
set string "0"
set wide "0O"
set char "0X"
@@ -174,9 +142,8 @@ test link-2.8 {writing C variables from Tcl} -constraints {testlink} -setup {
concat [testlink get] | $int $real $bool $string $wide $char $uchar $short $ushort $uint $long $ulong $float $uwide
} -result {0 0.0 0 0 0 0 0 0 0 0 0 0 0.0 0 | 0x 0b 0 0 0O 0X 0B 0O 0x 0b 0o 0X 0B 0O}
-test link-3.1 {read-only variables} -constraints {testlink} -setup {
+test link-3.1 {read-only variables} {testlink} {
testlink delete
-} -body {
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 \
@@ -184,10 +151,9 @@ test link-3.1 {read-only variables} -constraints {testlink} -setup {
[catch {set bool no} msg] $msg $bool \
[catch {set string "new value"} msg] $msg $string \
[catch {set wide 12341234} msg] $msg $wide
-} -result {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} -constraints {testlink} -setup {
+} {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
-} -body {
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 \
@@ -195,21 +161,19 @@ test link-3.2 {read-only variables} -constraints {testlink} -setup {
[catch {set bool no} msg] $msg $bool \
[catch {set string "new value"} msg] $msg $string\
[catch {set wide 12341234} msg] $msg $wide
-} -result {0 4 4 1 {can't set "real": linked variable is read-only} 1.23 1 {can't set "bool": linked variable is read-only} 1 0 {new value} {new value} 0 12341234 12341234}
+} {0 4 4 1 {can't set "real": linked variable is read-only} 1.23 1 {can't set "bool": linked variable is read-only} 1 0 {new value} {new value} 0 12341234 12341234}
-test link-4.1 {unsetting linked variables} -constraints {testlink} -setup {
+test link-4.1 {unsetting linked variables} {testlink} {
testlink delete
-} -body {
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 \
[catch {set wide} msg] $msg
-} -result {0 -6 0 -2.5 0 0 0 stringValue 0 13579}
-test link-4.2 {unsetting linked variables} -constraints {testlink} -setup {
+} {0 -6 0 -2.5 0 0 0 stringValue 0 13579}
+test link-4.2 {unsetting linked variables} {testlink} {
testlink delete
-} -body {
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
@@ -219,11 +183,10 @@ test link-4.2 {unsetting linked variables} -constraints {testlink} -setup {
set string newValue
set wide 333555
lrange [testlink get] 0 4
-} -result {102 16.0 1 newValue 333555}
+} {102 16.0 1 newValue 333555}
-test link-5.1 {unlinking variables} -constraints {testlink} -setup {
+test link-5.1 {unlinking variables} {testlink} {
testlink delete
-} -body {
testlink set -6 -2.25 0 stringValue 13579 64 250 30000 60000 0xbeefbabe 12321 32123 3.25 1231231234
testlink delete
set int xx1
@@ -241,108 +204,98 @@ test link-5.1 {unlinking variables} -constraints {testlink} -setup {
set float dskjfbjfd
set uwide isdfsngs
testlink get
-} -result {-6 -2.25 0 stringValue 13579 64 250 30000 60000 -1091585346 12321 32123 3.25 1231231234}
-test link-5.2 {unlinking variables} -constraints {testlink} -setup {
+} {-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
-} -body {
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 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
-} -result {-6 -2.25 0 stringValue 97531 64 250 30000 60000 3203381950 12321 32123 3.25 1231231234}
+} {-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} -setup {
+test link-6.1 {errors in setting up link} {testlink} {
testlink delete
- unset -nocomplain int
-} -constraints {testlink} -body {
+ catch {unset int}
set int(44) 1
- testlink create 1 1 1 1 1 1 1 1 1 1 1 1 1 1
-} -cleanup {
- unset -nocomplain int
-} -returnCodes error -result {can't set "int": variable is array}
+ 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}
-test link-7.1 {access to linked variables via upvar} -setup {
- testlink delete
-} -constraints {testlink} -body {
+test link-7.1 {access to linked variables via upvar} {testlink} {
proc x {} {
upvar int y
unset y
}
+ testlink delete
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
-} -result {0 14}
-test link-7.2 {access to linked variables via upvar} -setup {
- testlink delete
-} -constraints {testlink} -body {
+} {0 14}
+test link-7.2 {access to linked variables via upvar} {testlink} {
proc x {} {
upvar int y
return [set y]
}
+ testlink delete
testlink create 1 0 0 0 0 0 0 0 0 0 0 0 0 0
testlink set 0 {} {} {} {} {} {} {} {} {} {} {} {} {}
set int
testlink set 23 {} {} {} {} {} {} {} {} {} {} {} {} {}
x
list [x] $int
-} -result {23 23}
-test link-7.3 {access to linked variables via upvar} -setup {
- testlink delete
-} -constraints {testlink} -body {
+} {23 23}
+test link-7.3 {access to linked variables via upvar} {testlink} {
proc x {} {
upvar int y
set y 44
}
+ testlink delete
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
-} -result {1 {can't set "y": linked variable is read-only} 11}
-test link-7.4 {access to linked variables via upvar} -setup {
- testlink delete
-} -constraints {testlink} -body {
+} {1 {can't set "y": linked variable is read-only} 11}
+test link-7.4 {access to linked variables via upvar} {testlink} {
proc x {} {
upvar int y
set y abc
}
+ testlink delete
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
-} -result {1 {can't set "y": variable must have integer or boolean value} -4}
-test link-7.5 {access to linked variables via upvar} -setup {
- testlink delete
-} -constraints {testlink} -body {
+} {1 {can't set "y": variable must have integer value} -4}
+test link-7.5 {access to linked variables via upvar} {testlink} {
proc x {} {
upvar real y
set y abc
}
+ testlink delete
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
-} -result {1 {can't set "y": variable must have real or boolean value} 16.75}
-test link-7.6 {access to linked variables via upvar} -setup {
- testlink delete
-} -constraints {testlink} -body {
+} {1 {can't set "y": variable must have real value} 16.75}
+test link-7.6 {access to linked variables via upvar} {testlink} {
proc x {} {
upvar bool y
set y abc
}
+ testlink delete
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
-} -result {1 {can't set "y": variable must have boolean value} 1}
-test link-7.7 {access to linked variables via upvar} -setup {
- testlink delete
-} -constraints {testlink} -body {
+} {1 {can't set "y": variable must have boolean value} 1}
+test link-7.7 {access to linked variables via upvar} {testlink} {
proc x {} {
upvar wide y
set y abc
}
+ testlink delete
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
-} -result {1 {can't set "y": variable must have integer or boolean value} 778899}
+} {1 {can't set "y": variable must have integer value} 778899}
test link-8.1 {Tcl_UpdateLinkedVar procedure} {testlink} {
proc x args {
@@ -355,7 +308,7 @@ test link-8.1 {Tcl_UpdateLinkedVar procedure} {testlink} {
trace var int w x
testlink update 32 4.0 3 abcd 113355 65 251 30001 60001 0xbabebeef 12322 32124 3.125 12312312340
trace vdelete int w x
- return $x
+ set x
} {{int {} w} 32 -2.0 0 xyzzy 995511}
test link-8.2 {Tcl_UpdateLinkedVar procedure} {testlink} {
proc x args {
@@ -369,7 +322,7 @@ test link-8.2 {Tcl_UpdateLinkedVar procedure} {testlink} {
trace var int w x
testlink update 32 4.0 6 abcd 113355 65 251 30001 60001 0xbabebeef 12322 32124 3.125 12312312340
trace vdelete int w x
- return $x
+ set x
} {}
test link-8.3 {Tcl_UpdateLinkedVar procedure, read-only variable} {testlink} {
testlink create 0 0 0 0 0 0 0 0 0 0 0 0 0 0
@@ -377,18 +330,13 @@ test link-8.3 {Tcl_UpdateLinkedVar procedure, read-only variable} {testlink} {
testlink update 47 {} {} {} {} {} {} {} {} {} {} {} {} {}
} msg] $msg $int
} {0 {} 47}
-
+
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} {
- unset -nocomplain $i
+ catch {unset $i}
}
# cleanup
::tcltest::cleanupTests
return
-
-# Local Variables:
-# mode: tcl
-# fill-column: 78
-# End: