Initial commit

This commit is contained in:
Bassem Girgis
2018-12-20 17:34:07 -06:00
parent 7a2d899662
commit 81b4b9e273
34743 changed files with 5940233 additions and 0 deletions

View File

@@ -0,0 +1,58 @@
#######################################################################
# Makefile for tcl test-suite
#######################################################################
LANGUAGE = tcl
TCLSH = tclsh
SCRIPTSUFFIX = _runme.tcl
srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
CPP_TEST_CASES += \
primitive_types \
li_cstring \
li_cwstring
C_TEST_CASES += \
li_cstring \
li_cwstring
include $(srcdir)/../common.mk
# Overridden variables here
# none!
# Custom tests - tests with additional commandline options
# none!
# Rules for the different types of tests
%.cpptest:
$(setup)
+$(swig_and_compile_cpp)
$(run_testcase)
%.ctest:
$(setup)
+$(swig_and_compile_c)
$(run_testcase)
%.multicpptest:
$(setup)
+$(swig_and_compile_multi_cpp)
$(run_testcase)
# Runs the testcase. A testcase is only run if
# a file is found which has _runme.tcl appended after the testcase name.
run_testcase = \
if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(TCLSH) $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
fi
# Clean
%.clean:
@exit 0
clean:
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' tcl_clean

View File

@@ -0,0 +1,4 @@
See ../README for common README file.
Any testcases which have _runme.tcl appended after the testcase name will be detected and run.

View File

@@ -0,0 +1,73 @@
if [ catch { load ./bools[info sharedlibextension] bools} err_msg ] {
puts stderr "Could not load shared object:\n$err_msg"
}
# bool constant check
if {$constbool != 0} {
puts stderr "Runtime test 1 failed"
exit 1
}
# bool variables check
if {$bool1 != 1} {
puts stderr "Runtime test 2 failed"
exit 1
}
if {$bool2 != 0} {
puts stderr "Runtime test 3 failed"
exit 1
}
if { [ value $pbool ] != $bool1} {
puts stderr "Runtime test 4 failed"
exit 1
}
if { [ value $rbool ] != $bool2} {
puts stderr "Runtime test 5 failed"
exit 1
}
if { [ value $const_pbool ] != $bool1} {
puts stderr "Runtime test 6 failed"
exit 1
}
if { $const_rbool != $bool2} {
puts stderr "Runtime test 7 failed"
exit 1
}
# bool functions check
if { [ bo 0 ] != 0} {
puts stderr "Runtime test 8 failed"
exit 1
}
if { [ bo 1 ] != 1} {
puts stderr "Runtime test 9 failed"
exit 1
}
if { [ value [ rbo $rbool ] ] != [ value $rbool ]} {
puts stderr "Runtime test 10 failed"
exit 1
}
if { [ value [ pbo $pbool ] ] != [ value $pbool ]} {
puts stderr "Runtime test 11 failed"
exit 1
}
if { [ const_rbo $const_rbool ] != $const_rbool } {
puts stderr "Runtime test 12 failed"
exit 1
}
if { [ value [ const_pbo $const_pbool ] ] != [ value $const_pbool ]} {
puts stderr "Runtime test 13 failed"
exit 1
}

View File

@@ -0,0 +1,88 @@
if [ catch { load ./clientdata_prop_b[info sharedlibextension] clientdata_prop_b} err_msg ] {
puts stderr "Could not load shared object:\n$err_msg"
exit 1
}
if [ catch { load ./clientdata_prop_a[info sharedlibextension] clientdata_prop_a} err_msg ] {
puts stderr "Could not load shared object:\n$err_msg"
exit 1
}
A a
test_A a
test_tA a
test_t2A a
test_t3A a
a fA
B b
test_A b
test_tA b
test_t2A b
test_t3A b
test_B b
b fA
b fB
C c
test_A c
test_tA c
test_t2A c
test_t3A c
test_C c
c fA
c fC
D d
test_A d
test_tA d
test_t2A d
test_t3A d
test_D d
test_tD d
test_t2D d
d fA
d fD
set a2 [new_tA]
test_A $a2
test_tA $a2
test_t2A $a2
test_t3A $a2
$a2 fA
set a3 [new_t2A]
test_A $a3
test_tA $a3
test_t2A $a3
test_t3A $a3
$a3 fA
set a4 [new_t3A]
test_A $a4
test_tA $a4
test_t2A $a4
test_t3A $a4
$a4 fA
set d2 [new_tD]
test_A $d2
test_tA $d2
test_t2A $d2
test_t3A $d2
test_D $d2
test_tD $d2
test_t2D $d2
$d2 fA
$d2 fD
set d3 [new_t2D]
test_A $d3
test_tA $d3
test_t2A $d3
test_t3A $d3
test_D $d3
test_tD $d3
test_t2D $d3
$d3 fA
$d3 fD

View File

@@ -0,0 +1,172 @@
if [ catch { load ./cpp11_strongly_typed_enumerations[info sharedlibextension] cpp11_strongly_typed_enumerations} err_msg ] {
puts stderr "Could not load shared object:\n$err_msg"
}
proc enumCheck {actual expected} {
if {$actual != $expected} {
error "Enum value mismatch. Expected $expected. Actual: $actual"
}
return [expr $expected + 1]
}
#set val 0
#set val [enumCheck $Enum1_Val1 $val]
#set val [enumCheck $Enum1_Val2 $val]
set val 0
set val [enumCheck $Enum1_Val1 $val]
set val [enumCheck $Enum1_Val2 $val]
set val [enumCheck $Enum1_Val3 13]
set val [enumCheck $Enum1_Val4 $val]
set val [enumCheck $Enum1_Val5a 13]
set val [enumCheck $Enum1_Val6a $val]
set val 0
set val [enumCheck $Enum2_Val1 $val]
set val [enumCheck $Enum2_Val2 $val]
set val [enumCheck $Enum2_Val3 23]
set val [enumCheck $Enum2_Val4 $val]
set val [enumCheck $Enum2_Val5b 23]
set val [enumCheck $Enum2_Val6b $val]
set val 0
set val [enumCheck $Val1 $val]
set val [enumCheck $Val2 $val]
set val [enumCheck $Val3 43]
set val [enumCheck $Val4 $val]
set val 0
set val [enumCheck $Enum5_Val1 $val]
set val [enumCheck $Enum5_Val2 $val]
set val [enumCheck $Enum5_Val3 53]
set val [enumCheck $Enum5_Val4 $val]
set val 0
set val [enumCheck $Enum6_Val1 $val]
set val [enumCheck $Enum6_Val2 $val]
set val [enumCheck $Enum6_Val3 63]
set val [enumCheck $Enum6_Val4 $val]
set val 0
set val [enumCheck $Enum7td_Val1 $val]
set val [enumCheck $Enum7td_Val2 $val]
set val [enumCheck $Enum7td_Val3 73]
set val [enumCheck $Enum7td_Val4 $val]
set val 0
set val [enumCheck $Enum8_Val1 $val]
set val [enumCheck $Enum8_Val2 $val]
set val [enumCheck $Enum8_Val3 83]
set val [enumCheck $Enum8_Val4 $val]
set val 0
set val [enumCheck $Enum10_Val1 $val]
set val [enumCheck $Enum10_Val2 $val]
set val [enumCheck $Enum10_Val3 103]
set val [enumCheck $Enum10_Val4 $val]
set val 0
set val [enumCheck $Class1_Enum12_Val1 1121]
set val [enumCheck $Class1_Enum12_Val2 1122]
set val [enumCheck $Class1_Enum12_Val3 $val]
set val [enumCheck $Class1_Enum12_Val4 $val]
set val [enumCheck $Class1_Enum12_Val5c 1121]
set val [enumCheck $Class1_Enum12_Val6c $val]
set val 0
set val [enumCheck $Class1_Val1 1131]
set val [enumCheck $Class1_Val2 1132]
set val [enumCheck $Class1_Val3 $val]
set val [enumCheck $Class1_Val4 $val]
set val [enumCheck $Class1_Val5d 1131]
set val [enumCheck $Class1_Val6d $val]
set val 0
set val [enumCheck $Class1_Enum14_Val1 1141]
set val [enumCheck $Class1_Enum14_Val2 1142]
set val [enumCheck $Class1_Enum14_Val3 $val]
set val [enumCheck $Class1_Enum14_Val4 $val]
set val [enumCheck $Class1_Enum14_Val5e 1141]
set val [enumCheck $Class1_Enum14_Val6e $val]
# Requires nested class support to work
#set val 0
#set val [enumCheck $Class1_Struct1_Enum12_Val1 3121]
#set val [enumCheck $Class1_Struct1_Enum12_Val2 3122]
#set val [enumCheck $Class1_Struct1_Enum12_Val3 $val]
#set val [enumCheck $Class1_Struct1_Enum12_Val4 $val]
#set val [enumCheck $Class1_Struct1_Enum12_Val5f 3121]
#set val [enumCheck $Class1_Struct1_Enum12_Val6f $val]
#
#set val 0
#set val [enumCheck $Class1_Struct1_Val1 3131]
#set val [enumCheck $Class1_Struct1_Val2 3132]
#set val [enumCheck $Class1_Struct1_Val3 $val]
#set val [enumCheck $Class1_Struct1_Val4 $val]
#
#set val 0
#set val [enumCheck $Class1_Struct1_Enum14_Val1 3141]
#set val [enumCheck $Class1_Struct1_Enum14_Val2 3142]
#set val [enumCheck $Class1_Struct1_Enum14_Val3 $val]
#set val [enumCheck $Class1_Struct1_Enum14_Val4 $val]
#set val [enumCheck $Class1_Struct1_Enum14_Val5g 3141]
#set val [enumCheck $Class1_Struct1_Enum14_Val6g $val]
set val 0
set val [enumCheck $Class2_Enum12_Val1 2121]
set val [enumCheck $Class2_Enum12_Val2 2122]
set val [enumCheck $Class2_Enum12_Val3 $val]
set val [enumCheck $Class2_Enum12_Val4 $val]
set val [enumCheck $Class2_Enum12_Val5h 2121]
set val [enumCheck $Class2_Enum12_Val6h $val]
set val 0
set val [enumCheck $Class2_Val1 2131]
set val [enumCheck $Class2_Val2 2132]
set val [enumCheck $Class2_Val3 $val]
set val [enumCheck $Class2_Val4 $val]
set val [enumCheck $Class2_Val5i 2131]
set val [enumCheck $Class2_Val6i $val]
set val 0
set val [enumCheck $Class2_Enum14_Val1 2141]
set val [enumCheck $Class2_Enum14_Val2 2142]
set val [enumCheck $Class2_Enum14_Val3 $val]
set val [enumCheck $Class2_Enum14_Val4 $val]
set val [enumCheck $Class2_Enum14_Val5j 2141]
set val [enumCheck $Class2_Enum14_Val6j $val]
# Requires nested class support to work
#set val 0
#set val [enumCheck $Class2_Struct1_Enum12_Val1 4121]
#set val [enumCheck $Class2_Struct1_Enum12_Val2 4122]
#set val [enumCheck $Class2_Struct1_Enum12_Val3 $val]
#set val [enumCheck $Class2_Struct1_Enum12_Val4 $val]
#set val [enumCheck $Class2_Struct1_Enum12_Val5k 4121]
#set val [enumCheck $Class2_Struct1_Enum12_Val6k $val]
#
#set val 0
#set val [enumCheck $Class2_Struct1_Val1 4131]
#set val [enumCheck $Class2_Struct1_Val2 4132]
#set val [enumCheck $Class2_Struct1_Val3 $val]
#set val [enumCheck $Class2_Struct1_Val4 $val]
#set val [enumCheck $Class2_Struct1_Val5l 4131]
#set val [enumCheck $Class2_Struct1_Val6l $val]
#
#set val 0
#set val [enumCheck $Class2_Struct1_Enum14_Val1 4141]
#set val [enumCheck $Class2_Struct1_Enum14_Val2 4142]
#set val [enumCheck $Class2_Struct1_Enum14_Val3 $val]
#set val [enumCheck $Class2_Struct1_Enum14_Val4 $val]
#set val [enumCheck $Class2_Struct1_Enum14_Val5m 4141]
#set val [enumCheck $Class2_Struct1_Enum14_Val6m $val]
set class1 [Class1]
enumCheck [$class1 class1Test1 $Enum1_Val5a] 13
enumCheck [$class1 class1Test2 $Class1_Enum12_Val5c] 1121
#enumCheck [$class1 class1Test3 $Class1_Struct1_Enum12_Val5f] 3121
enumCheck [globalTest1 $Enum1_Val5a] 13
enumCheck [globalTest2 $Class1_Enum12_Val5c] 1121
#enumCheck [globalTest3 $Class1_Struct1_Enum12_Val5f] 3121

View File

@@ -0,0 +1,16 @@
# This is the union runtime testcase. It ensures that values within a
# union embedded within a struct can be set and read correctly.
if [ catch { load ./disown[info sharedlibextension] disown} err_msg ] {
puts stderr "Could not load shared object:\n$err_msg"
}
set x 0
while {$x<100} {
set a [new_A]
B b
b acquire $a
incr x
}

View File

@@ -0,0 +1,9 @@
if [ catch { load ./enum_thorough[info sharedlibextension] enum_thorough} err_msg ] {
puts stderr "Could not load shared object:\n$err_msg"
}
if { [speedTest0 $SpeedClass_slow] != $SpeedClass_slow } { puts stderr "speedTest0 failed" }
if { [speedTest4 $SpeedClass_slow] != $SpeedClass_slow } { puts stderr "speedTest4 failed" }
if { [speedTest5 $SpeedClass_slow] != $SpeedClass_slow } { puts stderr "speedTest5 failed" }

View File

@@ -0,0 +1,4 @@
if [ catch { load ./import_nomodule[info sharedlibextension] import_nomodule} err_msg ] {
puts stderr "Could not load shared object:\n$err_msg"
}

View File

@@ -0,0 +1,22 @@
# This is the imports runtime testcase.
proc import {} {
if [ catch { load ./imports_b[info sharedlibextension] imports_b} err_msg ] {
puts stderr "Could not load shared object:\n$err_msg"
exit 1
}
if [ catch { load ./imports_a[info sharedlibextension] imports_a} err_msg ] {
puts stderr "Could not load shared object:\n$err_msg"
exit 1
}
}
import
set x [new_B]
A_hello $x
if [ catch { $x nonexistant } ] {
} else {
puts stderr "nonexistant method did not throw exception\n"
exit 1
}

View File

@@ -0,0 +1,21 @@
if [ catch { load ./li_std_string[info sharedlibextension] li_std_string} err_msg ] {
puts stderr "Could not load shared object:\n$err_msg"
}
Structure s
if {"[s cget -MemberString2]" != "member string 2"} { error "bad string map"}
s configure -MemberString2 "hello"
if {"[s cget -MemberString2]" != "hello"} { error "bad string map"}
if {"[s cget -ConstMemberString]" != "const member string"} { error "bad string map"}
if {"$GlobalString2" != "global string 2"} { error "bad string map"}
if {"$Structure_StaticMemberString2" != "static member string 2"} { error "bad string map"}
set GlobalString2 "hello"
if {"$GlobalString2" != "hello"} { error "bad string map"}
set Structure_StaticMemberString2 "hello"
if {"$Structure_StaticMemberString2" != "hello"} { error "bad string map"}

View File

@@ -0,0 +1,46 @@
# Example using pointers to member functions
if [ catch { load ./member_pointer[info sharedlibextension] member_pointer} err_msg ] {
puts stderr "Could not load shared object:\n$err_msg"
}
proc check {what expected actual} {
if {$expected != $actual } {
error "Failed: $what , Expected: $expected , Actual: $actual"
}
}
# Get the pointers
set area_pt [ areapt ]
set perim_pt [ perimeterpt ]
# Create some objects
set s [Square -args 10]
# Do some calculations
check "Square area " 100.0 [do_op $s $area_pt]
check "Square perim" 40.0 [do_op $s $perim_pt]
set memberPtr $areavar
set memberPtr $perimetervar
# Try the variables
check "Square area " 100.0 [do_op $s $areavar]
check "Square perim" 40.0 [do_op $s $perimetervar]
# Modify one of the variables
set areavar $perim_pt
check "Square perimeter" 40.0 [do_op $s $areavar]
# Try the constants
set memberPtr $AREAPT
set memberPtr $PERIMPT
set memberPtr $NULLPT
check "Square area " 100.0 [do_op $s $AREAPT]
check "Square perim" 40.0 [do_op $s $PERIMPT]

View File

@@ -0,0 +1,28 @@
if [ catch { load ./newobject1[info sharedlibextension] newobject1} err_msg ] {
puts stderr "Could not load shared object:\n$err_msg"
}
set foo1 [Foo_makeFoo]
if {[Foo_fooCount] != 1} {
puts stderr "newobject1 test 1 failed"
exit 1
}
set foo2 [$foo1 makeMore]
if {[Foo_fooCount] != 2} {
puts stderr "newobject1 test 2 failed"
exit 1
}
# Disable test while we solve the problem of premature object deletion
#$foo1 -delete
#if {[Foo_fooCount] != 1} {
# puts stderr "newobject1 test 3 failed"
# exit 1
#}
#
#$foo2 -delete
#if {[Foo_fooCount] != 0} {
# puts stderr "newobject1 test 4 failed"
# exit 1
#}

View File

@@ -0,0 +1,27 @@
if [ catch { load ./newobject2[info sharedlibextension] newobject2} err_msg ] {
puts stderr "Could not load shared object:\n$err_msg"
}
set foo1 [makeFoo]
if {[fooCount] != 1} {
puts stderr "newobject2 test 1 failed"
exit 1
}
set foo2 [makeFoo]
if {[fooCount] != 2} {
puts stderr "newobject2 test 2 failed"
exit 1
}
#$foo1 -delete
#if {[fooCount] != 1} {
# puts stderr "newobject2 test 3 failed"
# exit 1
#}
#$foo2 -delete
#if {[fooCount] != 0} {
# puts stderr "newobject2 test 4 failed"
# exit 1
#}

View File

@@ -0,0 +1,21 @@
if [ catch { load ./null_pointer[info sharedlibextension] null_pointer} err_msg ] {
puts stderr "Could not load shared object:\n$err_msg"
}
set a [A]
if {[func $a] != 0} {
puts stderr "null_pointer test 1 failed"
exit 1
}
set null [getnull]
if {$null != "NULL"} {
puts stderr "null_pointer test 2 failed"
exit 1
}
if {[llength [info commands "NULL"]] != 0} {
puts stderr "null_pointer test 3 failed"
exit 1
}

View File

@@ -0,0 +1,12 @@
if [ catch { load ./overload_copy[info sharedlibextension] overload_copy} err_msg ] {
puts stderr "Could not load shared object:\n$err_msg"
}
Foo f
Foo g [f cget -this]

View File

@@ -0,0 +1,166 @@
if [ catch { load ./overload_simple[info sharedlibextension] overload_simple} err_msg ] {
puts stderr "Could not load shared object:\n$err_msg"
}
set f [new_Foo]
set b [new_Bar]
set v [malloc_void 32]
set x [foo 3]
if {$x != "foo:int"} {
puts stderr "foo(int) test failed $x"
exit 1
}
set x [foo 3.4]
if {$x != "foo:double"} {
puts stderr "foo(double) test failed"
exit 1
}
set x [foo hello]
if {$x != "foo:char *"} {
puts stderr "foo(char *) test failed"
exit 1
}
set x [foo $f]
if {$x != "foo:Foo *"} {
puts stderr "foo(Foo *) test failed"
exit 1
}
set x [foo $b]
if {$x != "foo:Bar *"} {
puts stderr "foo(Bar *) test failed"
exit 1
}
set x [foo $v]
if {$x != "foo:void *"} {
puts stderr "foo(void *) test failed"
exit 1
}
Spam s
set x [s foo 3]
if {$x != "foo:int"} {
puts stderr "Spam::foo(int) test failed"
exit 1
}
set x [s foo 3.4]
if {$x != "foo:double"} {
puts stderr "Spam::foo(double) test failed"
exit 1
}
set x [s foo hello]
if {$x != "foo:char *"} {
puts stderr "Spam::foo(char *) test failed"
exit 1
}
set x [s foo $f]
if {$x != "foo:Foo *"} {
puts stderr "Spam::foo(Foo *) test failed"
exit 1
}
set x [s foo $b]
if {$x != "foo:Bar *"} {
puts stderr "Spam::foo(Bar *) test failed"
exit 1
}
set x [s foo $v]
if {$x != "foo:void *"} {
puts stderr "Spam::foo(void *) test failed"
exit 1
}
set x [Spam_bar 3]
if {$x != "bar:int"} {
puts stderr "Spam::bar(int) test failed"
exit 1
}
set x [Spam_bar 3.4]
if {$x != "bar:double"} {
puts stderr "Spam::bar(double) test failed"
exit 1
}
set x [Spam_bar hello]
if {$x != "bar:char *"} {
puts stderr "Spam::bar(char *) test failed"
exit 1
}
set x [Spam_bar $f]
if {$x != "bar:Foo *"} {
puts stderr "Spam::bar(Foo *) test failed"
exit 1
}
set x [Spam_bar $b]
if {$x != "bar:Bar *"} {
puts stderr "Spam::bar(Bar *) test failed"
exit 1
}
set x [Spam_bar $v]
if {$x != "bar:void *"} {
puts stderr "Spam::bar(void *) test failed"
exit 1
}
Spam s
set x [s cget -type]
if {$x != "none"} {
puts stderr "Spam() test failed"
}
Spam s 3
set x [s cget -type]
if {$x != "int"} {
puts stderr "Spam(int) test failed"
}
Spam s 3.4
set x [s cget -type]
if {$x != "double"} {
puts stderr "Spam(double) test failed"
}
Spam s hello
set x [s cget -type]
if {$x != "char *"} {
puts stderr "Spam(char *) test failed"
}
Spam s $f
set x [s cget -type]
if {$x != "Foo *"} {
puts stderr "Spam(Foo *) test failed"
}
Spam s $b
set x [s cget -type]
if {$x != "Bar *"} {
puts stderr "Spam(Bar *) test failed"
}
Spam s $v
set x [s cget -type]
if {$x != "void *"} {
puts stderr "Spam(void *) test failed"
}
free_void $v

View File

@@ -0,0 +1,19 @@
# Primitive ref testcase. Tests to make sure references to
# primitive types are passed by value
if [ catch { load ./primitive_ref[info sharedlibextension] primitive_ref} err_msg ] {
puts stderr "Could not load shared object:\n$err_msg"
}
if { [ref_int 3] != 3 } { puts stderr "ref_int failed" }
if { [ref_uint 3] != 3 } { puts stderr "ref_uint failed" }
if { [ref_short 3] != 3 } { puts stderr "ref_short failed" }
if { [ref_ushort 3] != 3 } { puts stderr "ref_ushort failed" }
if { [ref_long 3] != 3 } { puts stderr "ref_long failed" }
if { [ref_ulong 3] != 3 } { puts stderr "ref_ulong failed" }
if { [ref_schar 3] != 3 } { puts stderr "ref_schar failed" }
if { [ref_uchar 3] != 3 } { puts stderr "ref_uchar failed" }
if { [ref_float 3.5] != 3.5 } { puts stderr "ref_float failed" }
if { [ref_double 3.5] != 3.5 } { puts stderr "ref_double failed" }
if { [ref_char x] != "x" } { puts stderr "ref_char failed" }

View File

@@ -0,0 +1,33 @@
if [ catch { load ./primitive_types[info sharedlibextension] primitive_types} err_msg ] {
puts stderr "Could not load shared object:\n$err_msg"
}
if {[val_int 10] != 10 } { error "bad int map" }
if {[val_schar 10] != 10 } { error "bad char map" }
if {[val_short 10] != 10 } { error "bad schar map" }
if [catch { val_schar 10000 } ] {} else { error "bad schar map" }
if [catch { val_uint -100 } ] {} else { error "bad uint map" }
if [catch { val_uchar -100 } ] {} else { error "bad uchar map" }
if {[val_uint 10] != 10 } { error "bad uint map" }
if {[val_uchar 10] != 10 } { error "bad uchar map" }
if {[val_ushort 10] != 10 } { error "bad ushort map" }
if {[val_double 10] != 10 } { error "bad double map" }
if {[val_float 10] != 10 } { error "bad double map" }
if [catch { val_float hello } ] {} else { error "bad double map" }
if {[val_char c] != "c" } { error "bad char map" }
if {[val_char "c"] != "c" } { error "bad char map" }
if {[val_char 101] != "e" } { error "bad char map" }

View File

@@ -0,0 +1,8 @@
catch { load ./profiletest[info sharedlibextension] profiletest}
set a [new_A]
set b [new_B]
for {set i 0} {$i < 1000000} {incr i 1} {
set a [B_fn $b $a]
}

View File

@@ -0,0 +1,108 @@
if [ catch { load ./reference_global_vars[info sharedlibextension] reference_global_vars} err_msg ] {
puts stderr "Could not load shared object:\n$err_msg"
}
# const class reference variable
if {[ [getconstTC ] cget -num] != 33 } {
puts stderr "test 1 failed"
exit 1
}
# primitive reference variables
set var_bool [createref_bool 0]
if {[value_bool $var_bool] != 0} {
puts stderr "test 2 failed"
exit 1
}
set var_bool [createref_bool 1]
if {[value_bool $var_bool] != 1} {
puts stderr "test 3 failed"
exit 1
}
set var_char [createref_char "w"]
if {[value_char $var_char] != "w"} {
puts stderr "test 4 failed"
exit 1
}
set var_unsigned_char [createref_unsigned_char 10]
if {[value_unsigned_char $var_unsigned_char] != 10} {
puts stderr "test 5 failed"
exit 1
}
set var_signed_char [createref_signed_char 10]
if {[value_signed_char $var_signed_char] != 10} {
puts stderr "test 6 failed"
exit 1
}
set var_short [createref_short 10]
if {[value_short $var_short] != 10} {
puts stderr "test 7 failed"
exit 1
}
set var_unsigned_short [createref_unsigned_short 10]
if {[value_unsigned_short $var_unsigned_short] != 10} {
puts stderr "test 8 failed"
exit 1
}
set var_int [createref_int 10]
if {[value_int $var_int] != 10} {
puts stderr "test 9 failed"
exit 1
}
set var_unsigned_int [createref_unsigned_int 10]
if {[value_unsigned_int $var_unsigned_int] != 10} {
puts stderr "test 10 failed"
exit 1
}
set var_long [createref_long 10]
if {[value_long $var_long] != 10} {
puts stderr "test 11 failed"
exit 1
}
set var_unsigned_long [createref_unsigned_long 10]
if {[value_unsigned_long $var_unsigned_long] != 10} {
puts stderr "test 12 failed"
exit 1
}
set var_long_long [createref_long_long 10]
if {[value_long_long $var_long_long] != 10} {
puts stderr "test 13 failed"
exit 1
}
set var_unsigned_long_long [createref_unsigned_long_long 10]
if {[value_unsigned_long_long $var_unsigned_long_long] != 10} {
puts stderr "test 14 failed"
exit 1
}
set var_float [createref_float 10.5]
if {[value_float $var_float] != 10.5} {
puts stderr "test 15 failed"
exit 1
}
set var_double [createref_double 10.5]
if {[value_double $var_double] != 10.5} {
puts stderr "test 16 failed"
exit 1
}
# class reference variable
set var_TestClass [createref_TestClass [TestClass tc 20] ]
if {[ [value_TestClass $var_TestClass] cget -num] != 20} {
puts stderr "test 17 failed"
exit 1
}

View File

@@ -0,0 +1,36 @@
if [ catch { load ./union_parameter[info sharedlibextension] union_parameter} err_msg ] {
puts stderr "Could not load shared object:\n$err_msg"
}
set event [SDL_Event]
for { set i 0 } { $i < 2 } { incr i } {
# puts -nonewline "Loop $i: "
set evAvailable [SDL_PollEvent $event]
set evType [$event cget -type]
# puts "evType = $evType"
if { $evType == 1 } {
set specEvent [$event cget -active]
# puts "specEvent = $specEvent"
set type [$specEvent cget -type]
if { $type != $evType } {
error "Type $type should be $evType"
}
set gain [$specEvent cget -gain]
set state [$specEvent cget -state]
# puts "gain=$gain state=$state"
}
if { $evType == 2 } {
set specEvent [$event cget -key]
# puts "specEvent = $specEvent"
set type [$specEvent cget -type]
if { $type != $evType } {
error "Type $type should be $evType"
}
set which [$specEvent cget -which]
set state [$specEvent cget -state]
# puts "which=$which state=$state"
}
# puts ""
}

View File

@@ -0,0 +1,63 @@
# This is the union runtime testcase. It ensures that values within a
# union embedded within a struct can be set and read correctly.
if [ catch { load ./unions[info sharedlibextension] unions} err_msg ] {
puts stderr "Could not load shared object:\n$err_msg"
}
# Create new instances of SmallStruct and BigStruct for later use
SmallStruct small
small configure -jill 200
BigStruct big
big configure -smallstruct [small cget -this]
big configure -jack 300
# Use SmallStruct then BigStruct to setup EmbeddedUnionTest.
# Ensure values in EmbeddedUnionTest are set correctly for each.
EmbeddedUnionTest eut
# First check the SmallStruct in EmbeddedUnionTest
eut configure -number 1
#eut.uni.small = small
EmbeddedUnionTest_uni_small_set [EmbeddedUnionTest_uni_get [eut cget -this] ] [small cget -this]
#Jill1 = eut.uni.small.jill
set Jill1 [SmallStruct_jill_get [EmbeddedUnionTest_uni_small_get [EmbeddedUnionTest_uni_get [eut cget -this] ] ] ]
if {$Jill1 != 200} {
puts stderr "Runtime test1 failed. eut.uni.small.jill=$Jill1"
exit 1
}
set Num1 [eut cget -number]
if {$Num1 != 1} {
puts stderr "Runtime test2 failed. eut.number=$Num1"
exit 1
}
# Secondly check the BigStruct in EmbeddedUnionTest
eut configure -number 2
#eut.uni.big = big
EmbeddedUnionTest_uni_big_set [EmbeddedUnionTest_uni_get [eut cget -this] ] [big cget -this]
#Jack1 = eut.uni.big.jack
set Jack1 [BigStruct_jack_get [EmbeddedUnionTest_uni_big_get [EmbeddedUnionTest_uni_get [eut cget -this] ] ] ]
if {$Jack1 != 300} {
puts stderr "Runtime test3 failed. eut.uni.big.jack=$Jack1"
exit 1
}
#Jill2 = eut.uni.big.smallstruct.jill
set Jill2 [SmallStruct_jill_get [BigStruct_smallstruct_get [EmbeddedUnionTest_uni_big_get [EmbeddedUnionTest_uni_get [eut cget -this] ] ] ] ]
if {$Jill2 != 200} {
puts stderr "Runtime test4 failed. eut.uni.big.smallstruct.jill=$Jill2"
exit 1
}
set Num2 [eut cget -number]
if {$Num2 != 2} {
puts stderr "Runtime test5 failed. eut.number=$Num2"
exit 1
}