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

56 lines
1 KiB
Text

// Tests the 'is' operator with class instances
class A()
function A( this )
endfunction
endclass
class B( A )
function B( this )
super();
endfunction
endclass
class C( A )
function C( this )
super();
endfunction
endclass
class D( B, C )
function D( this )
super();
endfunction
endclass
class E( B, C )
function E( this )
super();
endfunction
endclass
var d := D(), e := E();
print( d is @A );
print( d is @B );
print( d is @C );
print( d is @D ); // true
print( d is @E ); // false
print( "--" );
print( e is @A );
print( e is @B );
print( e is @C );
print( e is @D ); // false
print( e is @E ); // true
print( "----" );
foreach ctor in ( struct{ A := @A, B := @B, C := @C, D := @D, E := @E } )
print( $"d is {_ctor_iter} = {( d is ctor ? "1" : "0" )} ; e is {_ctor_iter} = {( e is ctor ? "1" :
"0" )}" );
endforeach
print( "----" );
// Some other `is` tests..
print( d is "hello" );
print( "hello" is "hello" );