diff options
Diffstat (limited to 'itcl/itcl/tests/old/toaster.test')
-rw-r--r-- | itcl/itcl/tests/old/toaster.test | 165 |
1 files changed, 165 insertions, 0 deletions
diff --git a/itcl/itcl/tests/old/toaster.test b/itcl/itcl/tests/old/toaster.test new file mode 100644 index 00000000000..593676a648c --- /dev/null +++ b/itcl/itcl/tests/old/toaster.test @@ -0,0 +1,165 @@ +# +# Tests for "toaster" example +# ---------------------------------------------------------------------- +# AUTHOR: Michael J. McLennan +# Bell Labs Innovations for Lucent Technologies +# mmclennan@lucent.com +# http://www.tcltk.com/itcl +# +# RCS: $Id$ +# ---------------------------------------------------------------------- +# Copyright (c) 1993-1998 Lucent Technologies, Inc. +# ====================================================================== +# See the file "license.terms" for information on usage and +# redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. + +# ---------------------------------------------------------------------- +# Get toaster classes from "demos" directory. +# ---------------------------------------------------------------------- +lappend auto_path toasters + +# ---------------------------------------------------------------------- +# Outlets send bills to an e-mail address. Determine this address. +# ---------------------------------------------------------------------- +if {[info exists env(USER)]} { + set Owner $env(USER) +} elseif {[info exists env(LOGNAME)]} { + set Owner $env(LOGNAME) +} else { + set Owner [exec logname] +} + +# ---------------------------------------------------------------------- +# TOASTERS +# ---------------------------------------------------------------------- +test {Create a toaster and plug it in} { + global Owner + Toaster original -heat 1 -outlet [Outlet #auto -owner $Owner] +} { + $result == "original" +} + +test {Turn up the heat setting on the toaster} { + original config -heat 5 +} { + $result == "" +} + +test {Toast a few slices of bread} { + original toast 2 +} { + $result == "crumb tray: 25% full" +} + +test {Clean the toaster} { + original clean +} { + $result == "crumb tray: 0% full" +} + +test {Toast a few slices of bread a few different times} { + original clean + original toast 2 + original toast 1 +} { + $result == "crumb tray: 38% full" +} + +test {Toast too many slices of bread and cause a fire} { + puts stdout ">>> should say \"== FIRE! FIRE! ==\"" + original clean + original toast 2 + original toast 2 + original toast 2 + original toast 2 +} { + $result == "crumb tray: 100% full" +} + +test {Destroy the toaster} { + original clean + original toast 2 + original toast 1 + puts stdout ">>> should say \"15 crumbs ... what a mess!\"" + original delete +} { + $result == "" +} + +# ---------------------------------------------------------------------- +# SMART TOASTERS +# ---------------------------------------------------------------------- +test {Create a toaster and plug it in} { + global Owner + SmartToaster deluxe -heat 4 -outlet [Outlet #auto -owner $Owner] +} { + $result == "deluxe" +} + +test {Toast a few slices of bread} { + deluxe toast 2 +} { + $result == "crumb tray: 20% full" +} + +test {Toast a few slices of bread and look for auto-clean} { + deluxe clean + deluxe toast 2 + deluxe toast 2 + deluxe toast 2 + deluxe toast 2 + deluxe toast 2 +} { + $result == "crumb tray: 20% full" +} + +# ---------------------------------------------------------------------- +# PRODUCT STATISTICS +# ---------------------------------------------------------------------- +test {Check statistics gathered by Hazard base class} { + set tmp [Toaster #auto] + set stats [Hazard :: report ::Toaster] + $tmp delete + set stats +} { + $result == "::Toaster: 2 produced, 1 active, 1 accidents" +} + +test {Check statistics gathered by Hazard base class} { + Hazard :: report ::SmartToaster +} { + $result == "::SmartToaster: 1 produced, 1 active, 0 accidents" +} + +test {Destroy all Toasters} { + foreach toaster [itcl_info objects -isa Toaster] { + $toaster clean + $toaster delete + } +} { + $result == "" +} + +test {SmartToasters should have been destroyed along with Toasters} { + itcl_info objects -class SmartToaster +} { + $result == "" +} + +# ---------------------------------------------------------------------- +# OUTLETS +# ---------------------------------------------------------------------- +test {Bill all customers for outlet charges} { + Outlet :: bill + puts stdout ">>> should send two bills for outlets via e-mail" +} { + $result == "" +} + +test {Destroy all outlets} { + foreach outlet [itcl_info objects -class Outlet] { + $outlet delete + } +} { + $result == "" +} |