2024-08-26 22:37:22 +02:00
|
|
|
// Tests the 'is' operator with class instances
|
|
|
|
|
|
|
|
|
|
class A()
|
|
|
|
|
function A( this )
|
|
|
|
|
print( $"A::A this={this}" );
|
|
|
|
|
endfunction
|
|
|
|
|
endclass
|
|
|
|
|
|
|
|
|
|
class B()
|
2024-10-08 21:53:30 +02:00
|
|
|
function B( this, args ... )
|
2024-08-26 22:37:22 +02:00
|
|
|
print( $"B::B this={this} args={args}" );
|
|
|
|
|
endfunction
|
|
|
|
|
endclass
|
|
|
|
|
|
|
|
|
|
var a := A();
|
2024-10-08 21:53:30 +02:00
|
|
|
var b := B( "args" );
|
2024-08-26 22:37:22 +02:00
|
|
|
|
|
|
|
|
print( a.function );
|
|
|
|
|
print( b.function );
|
|
|
|
|
|
2024-10-08 21:53:30 +02:00
|
|
|
print( "----" );
|
2024-08-26 22:37:22 +02:00
|
|
|
|
|
|
|
|
var aa := ( a.function ).new();
|
2024-10-08 21:53:30 +02:00
|
|
|
var bb := b.function.new( "foo", "bar" );
|
2024-08-26 22:37:22 +02:00
|
|
|
|
|
|
|
|
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 );
|