polserver/testsuite/escript/classes/classinst-function-member.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

51 lines
869 B
Text

// Tests the 'is' operator with class instances
class A()
function A( this )
print( $"A::A this={this}" );
endfunction
endclass
class B()
function B( this, args ... )
print( $"B::B this={this} args={args}" );
endfunction
endclass
var a := A();
var b := B( "args" );
print( a.function );
print( b.function );
print( "----" );
var aa := ( a.function ).new();
var bb := b.function.new( "foo", "bar" );
print( aa );
print( bb );
print( "----" );
// Equality checks
print( aa == aa );
print( aa == bb );
print( "----" );
// Cannot assign 'function' member to classinst
a.function := uninit;
print( a.function );
print( "----" );
// Checking that old functionality doesn't break
var obj := struct{};
obj["function"] := "function string";
print( obj["function"] );
// Old implementation would have a compiler error here:
print( obj.function );