#!/bin/sh
# standard method for making Tcl script executable ... \
exec wish "$0" -name classBrowser -- "${1+$@}"

# -----------------------------------------------------------------------------
# classIntrospectionTest --
#
#       Test script for the classIntrospection package.  On execution, it
#       should produce the line "classIntrospectionTest PASSED".
# -----------------------------------------------------------------------------
# Copyright 2000 Paul Welton
#       Permission to use, copy, modify, and distribute this software and its
#       documentation for any purpose and without fee is hereby granted,
#       provided that this copyright notice appears in all copies.  No
#       representations are made about the suitability of this software for any
#       purpose.  It is provided "as is" without express or implied warranty.
# -----------------------------------------------------------------------------
#  Revision:   1.1   : Initial Release
# -----------------------------------------------------------------------------

lappend auto_path .
package require classIntrospection

class cg {}

foreach Space {:: ::n1 ::n1::n2} {
	namespace eval $Space {
        class c0 {}
        class c1 { inherit cg c0
                   public { variable v;         method m;       \
                            proc     p;         common c } }
        class c2 { inherit cg c0
                   public   variable v;  public method m;       \
                   public   proc     p;  public common c }
        class c3 { inherit cg c0
                   public   variable v;         method m;       \
                            proc     p;  public common c;       \
                            variable vp;        common cp }
    }
}

foreach Class {c1         c2         c3         ::c1         ::c2         ::c3
               n1::c1     n1::c2     n1::c3     ::n1::c1     ::n1::c2     ::n1::c3
               n1::n2::c1 n1::n2::c2 n1::n2::c3 ::n1::n2::c1 ::n1::n2::c2 ::n1::n2::c3} {
    foreach item        {heritage variable method proc common}  \
            expectation {{cg c0} v m p c} {
    	set result [class $Class info $item]
        if {![string equal $result $expectation]} {
        	error [format "%s \[class %s info %s\] returned \"%s\" not \"%s\"" \
                          "Test failed:" $Class $item $result $expectation]
        }
    }
}

puts "classIntrospectionTest PASSED"
exit 0
