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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [itcl/] [itcl/] [tests/] [old/] [toaster.test] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
#
2
# Tests for "toaster" example
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: toaster.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
# ----------------------------------------------------------------------
17
#  Get toaster classes from "demos" directory.
18
# ----------------------------------------------------------------------
19
lappend auto_path toasters
20
 
21
# ----------------------------------------------------------------------
22
#  Outlets send bills to an e-mail address.  Determine this address.
23
# ----------------------------------------------------------------------
24
if {[info exists env(USER)]} {
25
        set Owner $env(USER)
26
} elseif {[info exists env(LOGNAME)]} {
27
        set Owner $env(LOGNAME)
28
} else {
29
        set Owner [exec logname]
30
}
31
 
32
# ----------------------------------------------------------------------
33
#  TOASTERS
34
# ----------------------------------------------------------------------
35
test {Create a toaster and plug it in} {
36
        global Owner
37
        Toaster original -heat 1 -outlet [Outlet #auto -owner $Owner]
38
} {
39
        $result == "original"
40
}
41
 
42
test {Turn up the heat setting on the toaster} {
43
        original config -heat 5
44
} {
45
        $result == ""
46
}
47
 
48
test {Toast a few slices of bread} {
49
        original toast 2
50
} {
51
        $result == "crumb tray: 25% full"
52
}
53
 
54
test {Clean the toaster} {
55
        original clean
56
} {
57
        $result == "crumb tray: 0% full"
58
}
59
 
60
test {Toast a few slices of bread a few different times} {
61
        original clean
62
        original toast 2
63
        original toast 1
64
} {
65
        $result == "crumb tray: 38% full"
66
}
67
 
68
test {Toast too many slices of bread and cause a fire} {
69
        puts stdout ">>> should say \"== FIRE! FIRE! ==\""
70
        original clean
71
        original toast 2
72
        original toast 2
73
        original toast 2
74
        original toast 2
75
} {
76
        $result == "crumb tray: 100% full"
77
}
78
 
79
test {Destroy the toaster} {
80
        original clean
81
        original toast 2
82
        original toast 1
83
        puts stdout ">>> should say \"15 crumbs ... what a mess!\""
84
        original delete
85
} {
86
        $result == ""
87
}
88
 
89
# ----------------------------------------------------------------------
90
#  SMART TOASTERS
91
# ----------------------------------------------------------------------
92
test {Create a toaster and plug it in} {
93
        global Owner
94
        SmartToaster deluxe -heat 4 -outlet [Outlet #auto -owner $Owner]
95
} {
96
        $result == "deluxe"
97
}
98
 
99
test {Toast a few slices of bread} {
100
        deluxe toast 2
101
} {
102
        $result == "crumb tray: 20% full"
103
}
104
 
105
test {Toast a few slices of bread and look for auto-clean} {
106
        deluxe clean
107
        deluxe toast 2
108
        deluxe toast 2
109
        deluxe toast 2
110
        deluxe toast 2
111
        deluxe toast 2
112
} {
113
        $result == "crumb tray: 20% full"
114
}
115
 
116
# ----------------------------------------------------------------------
117
#  PRODUCT STATISTICS
118
# ----------------------------------------------------------------------
119
test {Check statistics gathered by Hazard base class} {
120
        set tmp [Toaster #auto]
121
        set stats [Hazard :: report ::Toaster]
122
        $tmp delete
123
        set stats
124
} {
125
        $result == "::Toaster: 2 produced, 1 active, 1 accidents"
126
}
127
 
128
test {Check statistics gathered by Hazard base class} {
129
        Hazard :: report ::SmartToaster
130
} {
131
        $result == "::SmartToaster: 1 produced, 1 active, 0 accidents"
132
}
133
 
134
test {Destroy all Toasters} {
135
        foreach toaster [itcl_info objects -isa Toaster] {
136
                $toaster clean
137
                $toaster delete
138
        }
139
} {
140
        $result == ""
141
}
142
 
143
test {SmartToasters should have been destroyed along with Toasters} {
144
        itcl_info objects -class SmartToaster
145
} {
146
        $result == ""
147
}
148
 
149
# ----------------------------------------------------------------------
150
#  OUTLETS
151
# ----------------------------------------------------------------------
152
test {Bill all customers for outlet charges} {
153
        Outlet :: bill
154
        puts stdout ">>> should send two bills for outlets via e-mail"
155
} {
156
        $result == ""
157
}
158
 
159
test {Destroy all outlets} {
160
        foreach outlet [itcl_info objects -class Outlet] {
161
                $outlet delete
162
        }
163
} {
164
        $result == ""
165
}

powered by: WebSVN 2.1.0

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