source: trunk/packages/optimizer/tests/pgapack.test

Last change on this file was 3177, checked in by mmc, 12 years ago

Updated all of the copyright notices to reference the transfer to
the new HUBzero Foundation, LLC.

File size: 2.5 KB
Line 
1# ----------------------------------------------------------------------
2#  TESTS FOR:  pgapack module in Rappture::optimizer
3#
4#  This file contains a collection of tests for Tcl commands driving
5#  the RapptureOptimizer package.  This part covers the "pgapack"
6#  plug-in module.
7#
8# ======================================================================
9#  AUTHOR:  Michael McLennan, Purdue University
10#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
11#
12#  See the file "license.terms" for information on usage and
13#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
14# ======================================================================
15#
16# Load the tcltest package...
17if {[lsearch [namespace children] ::tcltest] < 0} {
18    package require tcltest 2
19    namespace import -force ::tcltest::*
20}
21
22test aaa-0.1 {RapptureOptimizer package can be loaded} {
23    set status [catch {package require RapptureOptimizer} result]
24    if {$status != 0} {
25        # must not be installed yet -- use build version
26        lappend auto_path ../src
27        set status [catch {package require RapptureOptimizer} result]
28    }
29    list $status $result
30} {0 1.0}
31
32# ----------------------------------------------------------------------
33test pgapack-1.1 {default plugin is pgapack} {
34  Rappture::optimizer opt
35  opt using
36} {pgapack}
37
38test pgapack-1.2 {plugin has configuration options} {
39  opt configure
40} {-maxruns 10000 -operation minimize -poprepl best -popsize 200}
41
42test pgapack-1.3 {plugin configuration option values can be queried} {
43  opt configure -popsize
44} {200}
45
46test pgapack-1.4 {plugin configuration options can be modified} {
47  opt configure -popsize 1000 -operation maximize
48  opt configure
49} {-maxruns 10000 -operation maximize -poprepl best -popsize 1000}
50
51test pgapack-1.5 {options/values must be in pairs when changing them} {
52  list [catch {opt configure -operation minimize -poprepl} result] $result
53} {1 {missing value for option "-poprepl"}}
54
55test pgapack-1.6 {only certain options are recognized} {
56  list [catch {opt configure -foo} result] $result
57} {1 {bad option "-foo": should be -maxruns, -operation, -poprepl, -popsize}}
58
59test pgapack-1.7 {custom poprepl option works properly} {
60  list [catch {opt configure -poprepl random-repl} result] $result \
61       [opt configure -poprepl]
62} {0 {} random-repl}
63
64test pgapack-1.8 {custom poprepl option catches errors} {
65  list [catch {opt configure -poprepl foo} result] $result
66} {1 {bad value "foo": should be best, random-norepl, or random-repl}}
67
68# cleanup
69::tcltest::cleanupTests
70return
Note: See TracBrowser for help on using the repository browser.