polserver/testsuite/escript/classes/super-multiple-02.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

34 lines
1,022 B
Text

class BaseClass1()
function BaseClass1( this, arg0, arg1 )
print( $"BaseClass1 arg0={arg0} arg1={arg1}" );
this.base1 := { this.base1 ?: {} ..., { arg0, arg1 } };
endfunction
endclass
class BaseClass2()
function BaseClass2( this, arg0 )
print( $"BaseClass2 arg0={arg0}" );
// this.base2 := arg0;
this.base2 := { this.base2 ?: {} ..., { arg0 } };
endfunction
endclass
class Foo( BaseClass1, BaseClass2 )
function Foo( this, arg0 )
@BaseClass1::BaseClass1( this, "unscoped-arg0", "unscoped-arg1" );
@BaseClass2::BaseClass2( this, "unscoped-arg2" );
print( "---" );
@BaseClass1::BaseClass1( this, "unscoped-arg0", "unscoped-arg1" );
@BaseClass2::BaseClass2( this, "unscoped-arg2" );
print( "---" );
this.child := arg0;
endfunction
endclass
var obj := Foo( "foo" );
// We'll see that obj.base1 always contains a value of unscoped-arg0/1, and obj.base2
// will have "unscoped-arg2"
foreach key in obj
print( $"{_key_iter}={PackJSON( key, true )}" );
endforeach