OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [itcl/] [itk/] [tests/] [public.test] - Blame information for rev 1780

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
#
2
# Public variables as configuration options
3
# ----------------------------------------------------------------------
4
#   AUTHOR:  Michael J. McLennan
5
#            Bell Labs Innovations for Lucent Technologies
6
#            mmclennan@lucent.com
7
#            http://www.tcltk.com/itcl
8
#
9
#      RCS:  $Id: public.test,v 1.1.1.1 2002-01-16 10:24:48 markom Exp $
10
# ----------------------------------------------------------------------
11
#            Copyright (c) 1993-1998  Lucent Technologies, Inc.
12
# ======================================================================
13
# See the file "license.terms" for information on usage and
14
# redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
15
 
16
if {[string compare test [info procs test]] == 1} then {source defs}
17
 
18
# ----------------------------------------------------------------------
19
#  Define a base class with public variables and a simple mega-widget
20
# ----------------------------------------------------------------------
21
test public-1.1 {define base class and simple mega-widget class} {
22
    itcl::class test_public_base {
23
        public variable null
24
        public variable background "not used"
25
        public variable message
26
    }
27
    itcl::configbody test_public_base::message {
28
        global ::test_public_status
29
        lappend test_public_status "message: $message"
30
    }
31
    itcl::configbody test_public_base::background {
32
        global ::test_public_status
33
        lappend test_public_status "background: $background"
34
    }
35
    option add *TestPublic.background red
36
    option add *TestPublic.foreground white
37
    option add *TestPublic.cursor trek
38
    option add *TestPublic.message "Hello, World!"
39
 
40
    itcl::class TestPublic {
41
        inherit itk::Widget test_public_base
42
        constructor {args} {
43
            itk_component add mesg {
44
                label $itk_interior.mesg
45
            } {
46
                keep -background -foreground -cursor
47
                rename -text -message message Message
48
            }
49
            pack $itk_component(mesg) -side left -padx 2
50
 
51
            eval itk_initialize $args
52
        }
53
    }
54
    set testobj [TestPublic .#auto]
55
    pack $testobj
56
} {}
57
 
58
test public-1.2 {check the list of configuration options} {
59
    $testobj configure
60
} {{-background background Background red red} {-clientdata clientData ClientData {} {}} {-cursor cursor Cursor trek trek} {-foreground foreground Foreground white white} {-message message Message {Hello, World!} {Hello, World!}} {-null {} {} {} {}}}
61
 
62
test public-1.3 {uninitialized public variables are set to ""} {
63
    $testobj info variable null
64
} {public variable ::test_public_base::null  {} {}}
65
 
66
test public-1.4 {config code gets fired off} {
67
    set test_public_status ""
68
    $testobj configure -background blue -message "All Clear"
69
    set test_public_status
70
} {{background: blue} {message: All Clear}}
71
 
72
# ----------------------------------------------------------------------
73
#  Clean up
74
# ----------------------------------------------------------------------
75
itcl::delete class TestPublic test_public_base

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.