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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [itcl/] [itcl/] [tests/] [local.test] - Blame information for rev 1773

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

Line No. Rev Author Line
1 578 markom
#
2
# Tests for "local" command for creating objects local to a proc
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: local.test,v 1.1.1.1 2002-01-16 10:24:47 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
#  Test "local" to create objects that only exist within a proc
20
# ----------------------------------------------------------------------
21
test local-1.1 {define a class to use for testing} {
22
    class test_local {
23
        common status ""
24
        constructor {} {
25
            lappend status "created $this"
26
        }
27
        destructor {
28
            lappend status "deleted $this"
29
        }
30
        proc clear {} {
31
            set status ""
32
        }
33
        proc check {} {
34
            return $status
35
        }
36
        proc test {} {
37
            local test_local #auto
38
            lappend status "processing"
39
        }
40
        proc test2 {} {
41
            local test_local #auto
42
            lappend status "call test..."
43
            test
44
            lappend status "...back"
45
        }
46
    }
47
    test_local #auto
48
} {test_local0}
49
 
50
test local-1.2 {} {
51
    test_local::clear
52
    test_local::test
53
    test_local::check
54
} {{created ::test_local::test_local1} processing {deleted ::test_local::test_local1}}
55
 
56
test local-1.3 {} {
57
    test_local::clear
58
    test_local::test2
59
    test_local::check
60
} {{created ::test_local::test_local2} {call test...} {created ::test_local::test_local3} processing {deleted ::test_local::test_local3} ...back {deleted ::test_local::test_local2}}
61
 
62
test local-1.4 {} {
63
    find objects -isa test_local
64
} {test_local0}
65
 
66
delete class test_local

powered by: WebSVN 2.1.0

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