polserver/testsuite/pol/testpkgs/funcref/test_class.src
Kevin Eady 0fa1b893a0 Update core-changes, break-changes for classes support (#719)
* Format testsuite escript

* Format testsuite pol

* Update docs
Switch "attributes" to "members" to better align with Escript terms.

* Add core-changes, breaking-changes
2024-10-10 18:06:04 +02:00

39 lines
1.1 KiB
Text

use os;
include "testutil";
include "class-def";
program setup()
return 1;
endprogram
exported function test_class_is()
var objs := { A(), B(), C(), D(), E() };
var res := {};
var expected := { { 1, 0, 0, 0, 0 },
{ 1, 1, 0, 0, 0 },
{ 1, 0, 1, 0, 0 },
{ 1, 1, 1, 1, 0 },
{ 1, 1, 1, 0, 1 } };
foreach obj in objs
res.append( run_script_to_completion( ":testfuncref:check-class-is", obj ) );
endforeach
return ret_error_not_equal( res, expected, $"Unexpected aggegate, expected {expected} got {res}" );
endfunction
exported function test_set_class_members()
var obj := A();
obj.set_from_test := 1;
var res := run_script_to_completion( ":testfuncref:set-class-member", obj );
if ( obj.set_from_script != 1 )
return ret_error( $"Unexpected obj.set_from_script: expected 1, got {obj.set_from_script}" );
elseif ( obj.set_from_test != 1 )
return ret_error( $"Unexpected obj.set_from_test: expected 1, got {obj.set_from_test}" );
endif
return 1;
endfunction