aboutsummaryrefslogtreecommitdiff
path: root/tests/dict.test
diff options
context:
space:
mode:
authorSteve Bennett <steveb@workware.net.au>2010-01-24 10:48:25 +1000
committerSteve Bennett <steveb@workware.net.au>2010-10-15 11:02:39 +1000
commitd495fb19428bfc640aa4d0e9245bc8f23c31f380 (patch)
treeb80832b727b297f43584d274485742976e6d7529 /tests/dict.test
parente68eadfbfe66d350b9656e3a4a91f7520e2bfba4 (diff)
downloadjimtcl-d495fb19428bfc640aa4d0e9245bc8f23c31f380.zip
jimtcl-d495fb19428bfc640aa4d0e9245bc8f23c31f380.tar.gz
jimtcl-d495fb19428bfc640aa4d0e9245bc8f23c31f380.tar.bz2
Bugs, features, tests
The result of boolean ops on doubles is an int *: e.g. 0.5 < 0.1 should be 0, not 0.1 Implement jimsh -e <cmd> Allow jim to be built in a different location *: e.g. mkdir build; cd build; ../configure ...; make jimsh Add dict.test
Diffstat (limited to 'tests/dict.test')
-rw-r--r--tests/dict.test45
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/dict.test b/tests/dict.test
new file mode 100644
index 0000000..abccdb3
--- /dev/null
+++ b/tests/dict.test
@@ -0,0 +1,45 @@
+package require testing
+
+section "basic dict"
+
+test dict-1.1 "Basic dict" {
+ set d [dict create]
+ dict set d fruit apple
+ dict set d car holden
+ #puts "d=$d"
+ #puts "d(fruit)=$d(fruit)"
+ dict get $d car
+} {holden}
+
+catch {unset d}
+
+test dict-2.1 "Dict via reference" {
+ set d [dict create]
+ dict set d fruit apple
+ dict set d car holden
+
+ # now create a dictionary reference
+ set dref [ref $d dict]
+ dict get [getref $dref] car
+} {holden}
+
+test dict-2.2 "Modify dict via reference" {
+ # Get the value out of the refernence
+ set d [getref $dref]
+ # Modify it
+ dict set d car toyota
+ # And put the new value back
+ setref $dref $d
+ # Finally check it
+ dict get [getref $dref] car
+} {toyota}
+
+test dict-2.3 "Modify dict via reference - one line" {
+ # Get the value out of the refernence
+ set d [getref $dref]
+ setref $dref [dict set d car toyota]
+ # Finally check it
+ dict get [getref $dref] car
+} {toyota}
+
+testreport