Example #1
0
<?php

require "tests.php";
require "argout.php";
check::functions(array(incp, incr, inctr, new_intp, copy_intp, delete_intp, intp_assign, intp_value, voidhandle, handle));
$ip = copy_intp(42);
check::equal(42, incp($ip), "42==incp({$ip})");
check::equal(43, intp_value($ip), "43={$ip}");
$p = copy_intp(2);
check::equal(2, incp($p), "2==incp({$p})");
check::equal(3, intp_value($p), "3=={$p}");
$r = copy_intp(7);
check::equal(7, incr($r), "7==incr({$r})");
check::equal(8, intp_value($r), "8=={$r}");
$tr = copy_intp(4);
check::equal(4, inctr($tr), "4==incr({$tr})");
check::equal(5, intp_value($tr), "5=={$tr}");
# Check the voidhandle call, first with null
unset($handle);
# FIXME: Call-time pass-by-reference has been deprecated for ages, and was
# removed in PHP 5.4.  We need to rework
#voidhandle(&$handle);
#check::resource($handle,"_p_void",'$handle is not _p_void');
#$handledata=handle($handle);
#check::equal($handledata,"Here it is","\$handledata != \"Here it is\"");
unset($handle);
voidhandle($handle);
check::isnull($handle, '$handle not null');
check::done();
<?php

require "tests.php";
require "arrays_global_twodim.php";
check::functions(array(fn_taking_arrays, get_2d_array, new_simplestruct, new_material));
check::classes(array(arrays_global_twodim, SimpleStruct, Material));
check::globals(array(array_c, array_sc, array_uc, array_s, array_us, array_i, array_ui, array_l, array_ul, array_ll, array_f, array_d, array_struct, array_structpointers, array_ipointers, array_enum, array_enumpointers, array_const_i, chitmat, hitmat_val, hitmat, simplestruct_double_field));
$a1 = array(10, 11, 12, 13);
$a2 = array(14, 15, 16, 17);
$a = array($a1, $a2);
$_a = check::get(array_const_i);
for ($x = 0; $x < count($a1); $x++) {
    for ($y = 0; $y < 2; $y++) {
        check::equal($a[$y][$x], get_2d_array($_a, $y, $x), "check array {$x},{$y}");
    }
}
check::done();
<?php

require "tests.php";
require "enum_scope_template.php";
check::classes(array("enum_scope_template", "TreeInt"));
check::functions("chops");
check::equal(0, TreeInt_Oak, "0==TreeInt_Oak");
check::equal(1, TreeInt_Fir, "1==TreeInt_Fir");
check::equal(2, TreeInt_Cedar, "2==TreeInt_Cedar");
check::equal(TreeInt_Oak, chops(TreeInt_Oak), "TreeInt_Oak==chops(TreeInt_Oak)");
check::equal(TreeInt_Fir, chops(TreeInt_Fir), "TreeInt_Fir==chops(TreeInt_Fir)");
check::equal(TreeInt_Cedar, chops(TreeInt_Cedar), "TreeInt_Cedar==chops(TreeInt_Cedar)");
check::done();
Example #4
0
<?php

require "tests.php";
require "pointer_reference.php";
$s = pointer_reference::get();
check::equal($s->value, 10, "pointer_reference::get() failed");
$ss = new Struct(20);
pointer_reference::set($ss);
$i = Struct::instance();
check::equal($i->value, 20, "pointer_reference::set() failed");
check::equal(pointer_reference::overloading(1), 111, "overload test 1 failed");
check::equal(pointer_reference::overloading($ss), 222, "overload test 2 failed");
check::done();
    function cheer()
    {
        return "FooBar3::cheer();";
    }
}
$b = new Bar();
$f = $b->create();
$fb = new FooBar();
$fb2 = new FooBar2();
$fb3 = new FooBar3();
check::equal($fb->used(), "Foo::pang();Bar::pong();Foo::pong();FooBar::ping();", "bad FooBar::used");
check::equal($fb2->used(), "FooBar2::pang();Bar::pong();Foo::pong();FooBar2::ping();", "bad FooBar2::used");
check::equal($b->pong(), "Bar::pong();Foo::pong();Bar::ping();", "bad Bar::pong");
check::equal($f->pong(), "Bar::pong();Foo::pong();Bar::ping();", "bad Foo::pong");
check::equal($fb->pong(), "Bar::pong();Foo::pong();FooBar::ping();", "bad FooBar::pong");
$method = new ReflectionMethod('Bar', 'ping');
check::equal($method->isProtected(), true, "Foo::ping should be protected");
$method = new ReflectionMethod('Foo', 'ping');
check::equal($method->isProtected(), true, "Foo::ping should be protected");
$method = new ReflectionMethod('FooBar', 'pang');
check::equal($method->isProtected(), true, "FooBar::pang should be protected");
$method = new ReflectionMethod('Bar', 'cheer');
check::equal($method->isProtected(), true, "Bar::cheer should be protected");
$method = new ReflectionMethod('Foo', 'cheer');
check::equal($method->isProtected(), true, "Foo::cheer should be protected");
check::equal($fb3->cheer(), "FooBar3::cheer();", "bad fb3::pong");
check::equal($fb2->callping(), "FooBar2::ping();", "bad fb2::callping");
check::equal($fb2->callcheer(), "FooBar2::pang();Bar::pong();Foo::pong();FooBar2::ping();", "bad fb2::callcheer");
check::equal($fb3->callping(), "Bar::ping();", "bad fb3::callping");
check::equal($fb3->callcheer(), "FooBar3::cheer();", "bad fb3::callcheer");
check::done();
Example #6
0
<?php

require "tests.php";
require "grouping.php";
check::functions(array("test1", "test2", "do_unary", "negate"));
check::equal(5, test1(5), "5==test1(5)");
check::resource(test2(7), "_p_int", "_p_int==test2(7)");
check::globals(array(test3));
//check::equal(37,test3_get(),'37==test3_get()');
check::equal(37, check::get("test3"), '37==get(test3)');
//test3_set(38);
check::set(test3, 38);
//check::equal(38,test3_get(),'38==test3_get() after test3_set(37)');
check::equal(38, check::get(test3), '38==get(test3) after set(test)');
check::equal(-5, negate(5), "-5==negate(5)");
check::equal(7, do_unary(-7, NEGATE), "7=do_unary(-7,NEGATE)");
check::done();
Example #7
0
require "tests.php";
require "char_strings.php";
$CPLUSPLUS_MSG = "A message from the deep dark world of C++, where anything is possible.";
$OTHERLAND_MSG_10 = "Little message from the safe world.10";
check::equal(GetCharHeapString(), $CPLUSPLUS_MSG, "failed GetCharHeapString");
check::equal(GetConstCharProgramCodeString(), $CPLUSPLUS_MSG, "failed GetConstCharProgramCodeString");
check::equal(GetCharStaticString(), $CPLUSPLUS_MSG, "failed GetCharStaticString");
check::equal(GetCharStaticStringFixed(), $CPLUSPLUS_MSG, "failed GetCharStaticStringFixed");
check::equal(GetConstCharStaticStringFixed(), $CPLUSPLUS_MSG, "failed GetConstCharStaticStringFixed");
check::equal(SetCharHeapString($OTHERLAND_MSG_10, 10), true, "failed GetConstCharStaticStringFixed");
check::equal(SetCharStaticString($OTHERLAND_MSG_10, 10), true, "failed SetCharStaticString");
check::equal(SetCharArrayStaticString($OTHERLAND_MSG_10, 10), true, "failed SetCharArrayStaticString");
check::equal(SetConstCharHeapString($OTHERLAND_MSG_10, 10), true, "failed SetConstCharHeapString");
check::equal(SetConstCharStaticString($OTHERLAND_MSG_10, 10), true, "failed SetConstCharStaticString");
check::equal(SetConstCharArrayStaticString($OTHERLAND_MSG_10, 10), true, "failed SetConstCharArrayStaticString");
check::equal(CharPingPong($OTHERLAND_MSG_10), $OTHERLAND_MSG_10, "failed CharPingPong");
Global_char_set($OTHERLAND_MSG_10);
check::equal(Global_char_get(), $OTHERLAND_MSG_10, "failed Global_char_get");
Global_char_array1_set($OTHERLAND_MSG_10);
check::equal(Global_char_array1_get(), $OTHERLAND_MSG_10, "failed Global_char_array1_get");
Global_char_array2_set($OTHERLAND_MSG_10);
check::equal(Global_char_array2_get(), $OTHERLAND_MSG_10, "failed Global_char_array2_get");
check::equal(Global_const_char_get(), $CPLUSPLUS_MSG, "failed Global_const_char");
check::equal(Global_const_char_array1_get(), $CPLUSPLUS_MSG, "failed Global_const_char_array1");
check::equal(Global_const_char_array2_get(), $CPLUSPLUS_MSG, "failed Global_const_char_array2");
check::equal(GetCharPointerRef(), $CPLUSPLUS_MSG, "failed GetCharPointerRef");
check::equal(SetCharPointerRef($OTHERLAND_MSG_10, 10), true, "failed SetCharPointerRef");
check::equal(GetConstCharPointerRef(), $CPLUSPLUS_MSG, "failed GetConstCharPointerRef");
check::equal(SetConstCharPointerRef($OTHERLAND_MSG_10, 10), true, "failed SetConstCharPointerRef");
check::done();
Example #8
0
<?php

require "tests.php";
require "evil_diamond_prop.php";
check::classes(array("evil_diamond_prop", "foo", "bar", "baz", "spam"));
check::functions("test");
check::is_a("bar", "foo");
check::is_a("baz", "foo");
check::is_a("spam", "foo");
check::is_a("spam", "bar");
//No multiple inheritance introspection yet
//check::is_a("spam","baz");
$foo = new foo();
check::is_a($foo, "foo");
check::equal(1, $foo->_foo, "1==foo->_foo");
$bar = new bar();
check::is_a($bar, "bar");
check::equal(1, $bar->_foo, "1==bar->_foo");
check::equal(2, $bar->_bar, "2==bar->_bar");
$baz = new baz();
check::is_a($baz, "baz");
check::equal(1, $baz->_foo, "1==baz->_foo");
check::equal(3, $baz->_baz, "3==baz->_baz");
$spam = new spam();
check::is_a($spam, "spam");
check::equal(1, $spam->_foo, "1==spam->_foo");
check::equal(2, $spam->_bar, "2==spam->_bar");
// multiple inheritance not supported in PHP
check::equal(null, $spam->_baz, "null==spam->_baz");
check::equal(4, $spam->_spam, "4==spam->_spam");
check::done();
Example #9
0
 function isnull($a, $message)
 {
     $value = trim(check::var_dump($a));
     return check::equal($value, "NULL", $message);
 }
Example #10
0
    {
        return "PhpFoo::ping()";
    }
}
$a = new PhpFoo();
check::equal($a->ping(), "PhpFoo::ping()", "ping failed");
check::equal($a->pong(), "Foo::pong();PhpFoo::ping()", "pong failed");
$b = new Foo();
check::equal($b->ping(), "Foo::ping()", "ping failed");
check::equal($b->pong(), "Foo::pong();Foo::ping()", "pong failed");
$a = new A1(1);
check::equal($a->rg(2), 2, "rg failed");
class PhpClass extends MyClass
{
    function vmethod($b)
    {
        $b->x = $b->x + 31;
        return $b;
    }
}
$b = new Bar(3);
$d = new MyClass();
$c = new PhpClass();
$cc = MyClass::get_self($c);
$dd = MyClass::get_self($d);
$bc = $cc->cmethod($b);
$bd = $dd->cmethod($b);
$cc->method($b);
check::equal($bc->x, 34, "bc failed");
check::equal($bd->x, 16, "bd failed");
check::done();
Example #11
0
}
$b = new B();
check::equal($b->step(), "Bar::step;Foo::advance;B::do_advance;B::do_step;", "Bad B virtual resolution");
class C extends FooBar_int
{
    function do_advance()
    {
        return "C::do_advance;" . parent::do_advance();
    }
    function do_step()
    {
        return "C::do_step;";
    }
    function get_value()
    {
        return 2;
    }
    function get_name()
    {
        return parent::get_name() . " hello";
    }
}
$cc = new C();
# TODO: Currently we do not track the dynamic type of returned
# objects, so we skip the get_self() call.
#$c = Foobar_int::get_self($cc);
$c = $cc;
$c->advance();
check::equal($c->get_name(), "FooBar::get_name hello", "get_name failed");
check::equal($c->name(), "FooBar::get_name hello", "name failed");
check::done();
    {
        return "FooBar::ping();";
    }
}
class FooBar2 extends Bar
{
    function ping()
    {
        return "FooBar2::ping();";
    }
    function pang()
    {
        return "FooBar2::pang();";
    }
}
$b = new Bar();
$f = $b->create();
$fb = new FooBar();
$fb2 = new FooBar2();
check::equal($fb->used(), "Foo::pang();Bar::pong();Foo::pong();FooBar::ping();", "bad FooBar::used");
check::equal($fb2->used(), "FooBar2::pang();Bar::pong();Foo::pong();FooBar2::ping();", "bad FooBar2::used");
check::equal($b->pong(), "Bar::pong();Foo::pong();Bar::ping();", "bad Bar::pong");
check::equal($f->pong(), "Bar::pong();Foo::pong();Bar::ping();", "bad Foo::pong");
check::equal($fb->pong(), "Bar::pong();Foo::pong();FooBar::ping();", "bad FooBar::pong");
$method = new ReflectionMethod('Bar', 'ping');
check::equal($method->isProtected(), true, "Boo::ping should be protected");
$method = new ReflectionMethod('Foo', 'ping');
check::equal($method->isProtected(), true, "Foo::ping should be protected");
$method = new ReflectionMethod('FooBar', 'pang');
check::equal($method->isProtected(), true, "FooBar::pang should be protected");
check::done();
<?php

require "tests.php";
require "pointer_reference.php";
$s = pointer_reference::get();
check::equal($s->value, 10, "pointer_reference::get() failed");
$ss = new Struct(20);
pointer_reference::set($ss);
$i = Struct::instance();
check::equal($i->value, 20, "pointer_reference::set() failed");
check::done();
Example #14
0
<?php

require "tests.php";
require "director_frob.php";
// No new functions
check::functions(array(alpha_abs_method, bravo_abs_method, charlie_abs_method, ops_opint, ops_opintstarstarconst, ops_opintamp, ops_opintstar, ops_opconstintintstar, prims_ull, prims_callull, corecallbacks_on3dengineredrawn, corecallbacks_on3dengineredrawn2));
// No new classes
check::classes(array(Alpha, Bravo, Charlie, Delta, Ops, Prims, corePoint3d, coreCallbacks_On3dEngineRedrawnData, coreCallbacksOn3dEngineRedrawnData, coreCallbacks));
// now new vars
check::globals(array(corecallbacks_on3dengineredrawndata__eye, corecallbacks_on3dengineredrawndata__at, corecallbackson3dengineredrawndata__eye, corecallbackson3dengineredrawndata__at));
$foo = new Bravo();
$s = $foo->abs_method();
check::equal($s, "Bravo::abs_method()", "s failed");
check::done();
<?php

require "tests.php";
require "abstract_inherit_ok.php";
check::classes(array(Foo, Spam));
$spam = new Spam();
check::equal(0, $spam->blah(), "spam object method");
check::done();
Example #16
0
<?php

require "tests.php";
require "sym.php";
// No new functions
check::functions(array());
// No new classes
check::classes(array(flim, flam));
// now new vars
check::globals(array());
$flim = new flim();
$flam = new flam();
check::equal($flim->hulahoops(), "flim-jam", "flim()->hulahoops==flim-jam");
check::equal($flim->jar(), "flim-jar", "flim()->jar==flim-jar");
check::equal($flam->jam(), "flam-jam", "flam()->jam==flam-jam");
check::equal($flam->jar(), "flam-jar", "flam()->jar==flam-jar");
check::done();
Example #17
0
<?php

require "tests.php";
require "director_string.php";
// No new functions
check::functions(array(a_get_first, a_call_get_first, a_string_length, a_process_text, a_call_process_func, stringvector_size, stringvector_is_empty, stringvector_clear, stringvector_push, stringvector_pop, stringvector_capacity, stringvector_reserve));
// No new classes
check::classes(array(A, StringVector));
// now new vars
check::globals(array(a, a_call, a_m_strings, stringvector));
class B extends A
{
    function get_first()
    {
        return parent::get_first() . " world!";
    }
    function process_text($string)
    {
        parent::process_text($string);
        $this->smem = "hello";
    }
}
$b = new B("hello");
$b->get(0);
check::equal($b->get_first(), "hello world!", "get_first failed");
$b->call_process_func();
check::equal($b->smem, "hello", "smem failed");
check::done();
Example #18
0
<?php

require "tests.php";
require "arrays.php";
check::functions(array(fn_taking_arrays, newintpointer, setintfrompointer, getintfrompointer, array_pointer_func));
check::classes(array(arrays, SimpleStruct, ArrayStruct, CartPoseData_t));
check::globals(array(simplestruct_double_field, arraystruct_array_c, arraystruct_array_sc, arraystruct_array_uc, arraystruct_array_s, arraystruct_array_us, arraystruct_array_i, arraystruct_array_ui, arraystruct_array_l, arraystruct_array_ul, arraystruct_array_ll, arraystruct_array_f, arraystruct_array_d, arraystruct_array_struct, arraystruct_array_structpointers, arraystruct_array_ipointers, arraystruct_array_enum, arraystruct_array_enumpointers, arraystruct_array_const_i, cartposedata_t_p));
$ss = new simplestruct();
check::classname(simplestruct, $ss);
$as = new arraystruct();
$as->array_c = "abc";
check::equal($as->array_c, "a", '$as->array_c=="a"');
check::equal(isset($as->array_const_i), TRUE, 'isset($as->array_const_i)');
check::done();
Example #19
0
    {
        $this->orStatus(2);
        if (method_exists(parent, "__destruct")) {
            parent::__destruct();
        }
    }
}
resetStatus();
$a = new MyFoo();
unset($a);
check::equal(getStatus(), 3, "getStatus() failed #1");
resetStatus();
$a = new MyFoo();
launder($a);
check::equal(getStatus(), 0, "getStatus() failed #2");
unset($a);
check::equal(getStatus(), 3, "getStatus() failed #3");
resetStatus();
$a = new MyFoo();
$a->thisown = 0;
deleteFoo($a);
unset($a);
check::equal(getStatus(), 3, "getStatus() failed #4");
resetStatus();
$a = new MyFoo();
$a->thisown = 0;
deleteFoo(launder($a));
unset($a);
check::equal(getStatus(), 3, "getStatus() failed #5");
resetStatus();
check::done();
Example #20
0
<?php

require "tests.php";
require "primitive_ref.php";
# A large long long number is too big, so PHP makes treats it as a double, but SWIG opts to return it as a string.
# The conversion to double can lose precision so this isn't an exact comparison.
function long_long_equal($a, $b, $message)
{
    if (!($a === $b)) {
        if (!((double) $a === $b)) {
            return check::fail($message . ": '{$a}'!=='{$b}'");
        }
    }
    return TRUE;
}
check::equal(ref_over(3), 3, "ref_over failed");
check::equal(ref_int(3), 3, "ref_int failed");
check::equal(ref_uint(3), 3, "ref_uint failed");
check::equal(ref_short(3), 3, "ref_short failed");
check::equal(ref_ushort(3), 3, "ref_ushort failed");
check::equal(ref_long(3), 3, "ref_long failed");
check::equal(ref_ulong(3), 3, "ref_ulong failed");
check::equal(ref_schar(3), 3, "ref_schar failed");
check::equal(ref_uchar(3), 3, "ref_uchar failed");
check::equal(ref_bool(true), true, "ref_bool failed");
check::equal(ref_float(3.5), 3.5, "ref_float failed");
check::equal(ref_double(3.5), 3.5, "ref_double failed");
check::equal(ref_char('x'), 'x', "ref_char failed");
long_long_equal(ref_longlong(0x123456789abcdef0), 0x123456789abcdef0, "ref_longlong failed");
long_long_equal(ref_ulonglong(0.0), 0.0, "ref_ulonglong failed");
check::done();
Example #21
0
<?php

require "tests.php";
require "extend_template.php";
check::classes(array("Foo_0"));
$foo = new Foo_0();
check::equal(2, $foo->test1(2), "test1");
check::equal(3, $foo->test2(3), "test2");
check::done();
<?php

require "tests.php";
require "overload_return_type.php";
$b = new B();
check::equal($b->foo(1), 0, "");
check::classname("A", $b->foo("test"));
check::equal(overload_return_type::foo(), 1, "overload_return_type::foo() should be 1");
check::equal(overload_return_type::bar(), 1, "overload_return_type::bar() should be 1");
function enumCheck($actual, $expected)
{
    check::equal($actual, $expected, "Enum value mismatch");
    return $expected + 1;
}
Example #24
0
function mycheck($person, $expected)
{
    $debug = 0;
    # Normal target language polymorphic call
    $ret = $person->id();
    if ($debug) {
        print $ret . "\n";
    }
    check::equal($ret, $expected, "#1 failed");
    # Polymorphic call from C++
    $caller = new Caller();
    $caller->setCallback($person);
    $ret = $caller->call();
    if ($debug) {
        print $ret . "\n";
    }
    check::equal($ret, $expected, "#2 failed");
    # Polymorphic call of object created in target language and passed to
    # C++ and back again
    $baseclass = $caller->baseClass();
    $ret = $baseclass->id();
    if ($debug) {
        print $ret . "\n";
    }
    # TODO: Currently we do not track the dynamic type of returned
    # objects, so in case it's possible that the dynamic type is not equal
    # to the static type, we skip this check.
    if (get_parent_class($person) === false) {
        check::equal($ret, $expected, "#3 failed");
    }
    $caller->resetCallback();
    if ($debug) {
        print "----------------------------------------\n";
    }
}
Example #25
0
<?php

require "tests.php";
require "php_iterator.php";
check::functions(array(myiterator_rewind, myiterator_key, myiterator_current, myiterator_next, myiterator_valid));
check::classes(array(MyIterator));
// No new global variables.
check::globals(array());
$s = '';
foreach (new MyIterator(1, 6) as $i) {
    $s .= $i;
}
check::equal($s, '12345', 'Simple iteration failed');
$s = '';
foreach (new MyIterator(2, 5) as $k => $v) {
    $s .= "({$k}=>{$v})";
}
check::equal($s, '(0=>2)(1=>3)(2=>4)', 'Simple iteration failed');
check::done();
Example #26
0
try {
    $bad->call_int();
    check::fail("Exception wasn't propagated from Bad::return_int()");
} catch (Exception $e) {
    check::equal($e->getMessage(), "bad int", "propagated exception incorrect");
}
try {
    $bad->call_double();
    check::fail("Exception wasn't propagated from Bad::return_double()");
} catch (Exception $e) {
    check::equal($e->getMessage(), "bad double", "propagated exception incorrect");
}
try {
    $bad->call_const_char_star();
    check::fail("Exception wasn't propagated from Bad::return_const_char_star()");
} catch (Exception $e) {
    check::equal($e->getMessage(), "bad const_char_star", "propagated exception incorrect");
}
try {
    $bad->call_std_string();
    check::fail("Exception wasn't propagated from Bad::return_std_string()");
} catch (Exception $e) {
    check::equal($e->getMessage(), "bad std_string", "propagated exception incorrect");
}
try {
    $bad->call_Bar();
    check::fail("Exception wasn't propagated from Bad::return_Bar()");
} catch (Exception $e) {
    check::equal($e->getMessage(), "bad Bar", "propagated exception incorrect");
}
check::done();
require "tests.php";
require "exception_order.php";
check::functions(array(a_foo, a_bar, a_foobar, a_barfoo));
check::classes(array(A, E1, E2, E3, exception_order, ET_i, ET_d));
check::globals(array(efoovar, foovar, cfoovar, a_sfoovar, a_foovar, a_efoovar));
$a = new A();
try {
    $a->foo();
} catch (Exception $e) {
    check::equal($e->getMessage(), 'C++ E1 exception thrown', '');
}
try {
    $a->bar();
} catch (Exception $e) {
    check::equal($e->getMessage(), 'C++ E2 exception thrown', '');
}
try {
    $a->foobar();
} catch (Exception $e) {
    check::equal($e->getMessage(), 'postcatch unknown', '');
}
try {
    $a->barfoo(1);
} catch (Exception $e) {
    check::equal($e->getMessage(), 'C++ E1 exception thrown', '');
}
try {
    $a->barfoo(2);
} catch (Exception $e) {
    check::equal($e->getMessage(), 'C++ E2 * exception thrown', '');
}
Example #28
0
<?php

require "tests.php";
require "arrays.php";
check::functions(array(fn_taking_arrays, newintpointer, setintfrompointer, getintfrompointer, array_pointer_func));
check::classes(array(arrays, SimpleStruct, ArrayStruct, CartPoseData_t));
check::globals(array(simplestruct_double_field, arraystruct_array_c, arraystruct_array_sc, arraystruct_array_uc, arraystruct_array_s, arraystruct_array_us, arraystruct_array_i, arraystruct_array_ui, arraystruct_array_l, arraystruct_array_ul, arraystruct_array_ll, arraystruct_array_f, arraystruct_array_d, arraystruct_array_struct, arraystruct_array_structpointers, arraystruct_array_ipointers, arraystruct_array_enum, arraystruct_array_enumpointers, arraystruct_array_const_i, cartposedata_t_p));
$ss = new simplestruct();
check::classname(simplestruct, $ss);
$as = new arraystruct();
$as->array_c = "abc";
check::equal($as->array_c, "a", '$as->array_c=="a"');
check::done();
Example #29
0
<?php

require "tests.php";
require "li_carrays.php";
// Check functions.
check::functions(array(new_intarray, delete_intarray, intarray_getitem, intarray_setitem));
// Check classes.
// NB An "li_carrays" class is created as a mock namespace.
check::classes(array(li_carrays, doubleArray, AB, XY, XYArray));
// No new global variables.
check::globals(array());
$d = new doubleArray(10);
$d->setitem(0, 7);
$d->setitem(5, $d->getitem(0) + 3);
check::equal($d->getitem(0) + $d->getitem(5), 17.0, "7+10==17");
check::done();
<?php

require "tests.php";
require "ignore_parameter.php";
// No new functions
check::functions(array(jaguar, lotus, tvr, ferrari));
// No new classes
check::classes(array(sportscars, minicooper, morrisminor, fordanglia, austinallegro));
// now new vars
check::globals(array());
check::equal(jaguar(2, 3.4), "hello", 'jaguar(2,3.4)=="hello"');
check::equal(lotus("eek", 3.4), 101, 'lotus("eek",3.4)==101');
check::equal(tvr("eek", 2), 8.800000000000001, 'tvr("eek",2)==8.8');
check::equal(ferrari(), 101, 'ferrari(2)==101');
$sc = new sportscars();
check::classname("sportscars", $sc);
check::equal($sc->daimler(2, 3.4), "hello", '$sc->daimler(2,3.4)=="hello"');
check::equal($sc->astonmartin("eek", 3.4), 101, '$sc->mastonmartin("eek",3.4)==101');
check::equal($sc->bugatti("eek", 2), 8.800000000000001, '$sc->bugatti("eek",2)==8.8');
check::equal($sc->lamborghini(), 101, '$sc->lamborghini(2)==101');
$mc = new minicooper(2, 3.4);
check::classname("minicooper", $mc);
$mm = new morrisminor("eek", 3.4);
check::classname("morrisminor", $mm);
$fa = new fordanglia("eek", 2);
check::classname("fordanglia", $fa);
$aa = new austinallegro();
check::classname("austinallegro", $aa);
check::done();