File: entryExtras.test

package info (click to toggle)
tklib 0.9-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 23,156 kB
  • sloc: tcl: 105,088; sh: 2,573; ansic: 792; pascal: 359; makefile: 69; sed: 53; exp: 21
file content (127 lines) | stat: -rw-r--r-- 3,181 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# -*- tcl -*-
# This file is a Tcl script to test entry widgets in Tk.  It is
# organized in the standard fashion for Tcl tests.
#
# Copyright (c) 1994 The Regents of the University of California.
# Copyright (c) 1994-1997 Sun Microsystems, Inc.
# Copyright (c) 1998-1999 by Scriptics Corporation.
# All rights reserved.

::tcltest::testConstraint tk 1

package require widgetPlus
namespace import ::widgetPlus::entryPlus

# ------------------------------------------------------------
# Tests for entryPlus, in addition to those in file
# entryPlus.test which is copied with mods from Tk entry.test.
# ------------------------------------------------------------

package require Tk
package require tcltest 2.2
namespace import -force tcltest::*
catch { tcltest::configure {*}$::argv }
loadTestedCommands

# ------------------------------------------------------------
# First test the entry widget when changing its -textvariable.
# Cf. entry.test 5.* and 22.*
# ------------------------------------------------------------

test entry-25.1 {entry set textvar} -setup {
    entry .e
} -body {
    .e insert end {Some Text}
    .e configure -textvariable ::foo
    set ::foo
} -cleanup {
    destroy .e
    unset ::foo
} -result {Some Text}

test entry-25.2 {entry unset textvar} -setup {
    set ::foo {Some Text}
    entry .e -textvariable ::foo
} -body {
    unset ::foo
    .e get
} -cleanup {
    destroy .e
} -result {Some Text}

test entry-25.3 {entry replace textvar set} -setup {
    set ::foo {Some Text}
    entry .e -textvariable ::foo
} -body {
    set ::bar {Replacement}
    .e configure -textvariable ::bar
    set ::bar
} -cleanup {
    destroy .e
    unset ::foo ::bar
} -result {Replacement}

test entry-25.4 {entry replace textvar unset} -setup {
    set ::foo {Some Text}
    entry .e -textvariable ::foo
} -body {
    unset -nocomplain ::bar
    .e configure -textvariable ::bar
    set ::bar
} -cleanup {
    destroy .e
    unset ::foo ::bar
} -result {Some Text}


# ------------------------------------------------------------
# Now test that entryPlus does the same as entry.
# ------------------------------------------------------------

test entry-35.1 {entryPlus set textvar} -setup {
    entryPlus .e
} -body {
    .e insert end {Some Text}
    .e configure -textvariable ::foo
    set ::foo
} -cleanup {
    destroy .e
    unset ::foo
} -result {Some Text}

test entry-35.2 {entryPlus unset textvar} -setup {
    set ::foo {Some Text}
    entryPlus .e -textvariable ::foo
} -body {
    unset ::foo
    .e get
} -cleanup {
    destroy .e
} -result {Some Text}

test entry-35.3 {entryPlus replace textvar set} -setup {
    set ::foo {Some Text}
    entryPlus .e -textvariable ::foo
} -body {
    set ::bar {Replacement}
    .e configure -textvariable ::bar
    set ::bar
} -cleanup {
    destroy .e
    unset ::foo ::bar
} -result {Replacement}

test entry-35.4 {entryPlus replace textvar unset} -setup {
    set ::foo {Some Text}
    entryPlus .e -textvariable ::foo
} -body {
    unset -nocomplain ::bar
    .e configure -textvariable ::bar
    set ::bar
} -cleanup {
    destroy .e
    unset ::foo ::bar
} -result {Some Text}

cleanupTests
return