# This file tests javaCmd.c.
#
# This file contains a collection of tests for one or more of the Tcl
# built-in commands.  Sourcing this file into Tcl runs the tests and
# generates output for errors.  No output means no errors were found.
#
# Copyright (c) 1997 by Sun Microsystems, Inc.
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
# RCS: @(#) $Id: javaCmd.test,v 1.2 1999/05/10 02:59:49 dejong Exp $

# Note: This test file must be sourced from the parent directory
#       or else the defs file may not be properly loaded.

if {[string compare test [info procs test]] == 1} then {source defs}

setupJavaPackage

proc setupInterp {name} {
    catch {interp delete $name}
    interp create $name
    $name eval [list set ::auto_path $::auto_path]
    $name eval {
	package require java
    }
}

test javaCmd-1.1 {Tclblend_Init} {
    setupInterp x
    x eval {
	catch {java::new} msg
	set msg
    }
} {wrong # args: should be "java::new signature ?arg arg ...?"}

test javaCmd-1.2 {Tclblend_Init} {
    set i [java::new tcl.lang.Interp]
    catch {$i {eval String} {java::new}}
    set result [[$i getResult] toString]
    $i dispose
    set result
} {wrong # args: should be "java::new signature ?arg arg ...?"}

# JavaGetEnv, JavaSetEnv, and JavaInitBlend do not have tests

test javaCmd-2.1 {JavaInterpDeleted} {
    set i [java::new tcl.lang.Interp]
    $i {eval String} {set x 1}
    $i dispose
    list [catch {$i {eval String} {set x 1}} msg] $msg
} {1 {java.lang.NullPointerException: Invalid interpreter.}}

# JavaSetupJava, ToString, JavaThrowTclException do not have tests
