# This file tests the functions in javaUtil.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: javaUtil.test,v 1.1.1.1 1998/10/14 21:09:24 cvsadmin 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

set interp [java::new tcl.lang.Interp]

test javaUtil-1.1 {Java_tcl_lang_Util_getBoolean} {
    list [catch {
	java::call tcl.lang.Util getBoolean java0x0 java0x0
    } msg] $msg
} {1 tcl.lang.TclException}
test javaUtil-1.2 {Java_tcl_lang_Util_getBoolean} {
    $interp resetResult
    list [catch {
	java::call tcl.lang.Util getBoolean $interp java0x0
    } msg] $msg
} {1 {tcl.lang.TclException: expected boolean value but got ""}}
test javaUtil-1.3 {Java_tcl_lang_Util_getBoolean} {
    java::call tcl.lang.Util getBoolean java0x0 false
} 0
test javaUtil-1.4 {Java_tcl_lang_Util_getBoolean} {
    java::call tcl.lang.Util getBoolean java0x0 on
} 1
test javaUtil-1.5 {Java_tcl_lang_Util_getBoolean} {
    $interp resetResult
    list [catch {
	java::call tcl.lang.Util getBoolean $interp foo
    } msg] $msg
} {1 {tcl.lang.TclException: expected boolean value but got "foo"}}

test javaUtil-2.1 {Java_tcl_lang_Util_getDouble} {
    list [catch {
	java::call tcl.lang.Util getDouble java0x0 java0x0
    } msg] $msg
} {1 tcl.lang.TclException}
test javaUtil-2.2 {Java_tcl_lang_Util_getDouble} {
    $interp resetResult
    list [catch {
	java::call tcl.lang.Util getDouble $interp java0x0
    } msg] $msg
} {1 {tcl.lang.TclException: expected floating-point number but got ""}}
test javaUtil-2.3 {Java_tcl_lang_Util_getDouble} {
    java::call tcl.lang.Util getDouble java0x0 3.4
} 3.4
test javaUtil-2.4 {Java_tcl_lang_Util_getDouble} {
    $interp resetResult
    list [catch {
	java::call tcl.lang.Util getDouble $interp foo
    } msg] $msg
} {1 {tcl.lang.TclException: expected floating-point number but got "foo"}}

test javaUtil-3.1 {Java_tcl_lang_Util_getInt} {
    list [catch {
	java::call tcl.lang.Util getInt java0x0 java0x0
    } msg] $msg
} {1 tcl.lang.TclException}
test javaUtil-3.2 {Java_tcl_lang_Util_getInt} {
    $interp resetResult
    list [catch {
	java::call tcl.lang.Util getInt $interp java0x0
    } msg] $msg
} {1 {tcl.lang.TclException: expected integer but got ""}}
test javaUtil-3.3 {Java_tcl_lang_Util_getInt} {
    java::call tcl.lang.Util getInt java0x0 42
} 42
test javaUtil-3.4 {Java_tcl_lang_Util_getInt} {
    $interp resetResult
    list [catch {
	java::call tcl.lang.Util getInt $interp foo
    } msg] $msg
} {1 {tcl.lang.TclException: expected integer but got "foo"}}

$interp dispose

