Add PHP run test for global_vars

This commit is contained in:
Olly Betts 2021-04-17 06:04:55 +12:00
parent 2629764e3f
commit 14edc26c8d
3 changed files with 37 additions and 0 deletions

View File

@ -33,4 +33,8 @@
b = "string b";
x = 1234;
}
int read_x() { return x; }
std::string read_b() { return b; }
%}

View File

@ -0,0 +1,28 @@
<?php
require "tests.php";
require "global_vars.php";
check::functions(array('init','read_b','read_x'));
check::classes(array('A','global_vars'));
check::globals(array('b','a','ap','cap','ar','x','xp','c_member','vp','h','hp','hr'));
$an = new A();
check::classname('A', $an);
ap_set($an);
check::classname('A', ap_get());
check::equivalent(ap_get(), $an, "global var assignment");
x_set(17);
check::equal(x_get(), 17, "global var assignment");
check::equal(read_x(), 17, "PHP global var change visible in C++");
init();
check::equal(x_get(), 1234, "C++ global var change visible in PHP");
b_set('test');
check::equal(b_get(), 'test', "global var assignment");
check::equal(read_b(), 'test', "PHP global var change visible in C++");
init();
check::equal(b_get(), 'string b', "C++ global var change visible in PHP");
check::done();

View File

@ -208,6 +208,11 @@ class check {
return TRUE;
}
static function equivalent($a,$b,$message) {
if (! ($a==$b)) return check::fail($message . ": '$a'!='$b'");
return TRUE;
}
static function resource($a,$b,$message) {
return check::equal(get_resource_type($a), $b, $message);
}