polserver/testsuite/escript/classes/scopes-03.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

50 lines
1.3 KiB
Text

// Various shadowing of the name 'variable' and accessing variables via
// 'Animal::variable' and 'variable';
var variable := "global var";
function StaticFunc( variable )
print( $"::StaticFunc variable={variable}" );
endfunction
function TestFuncCall()
print( $"::TestFuncCall called" );
endfunction
class Animal()
var variable := "class var";
function StaticFunc( variable )
print( $"StaticFunc variable={variable}" );
print( $"StaticFunc ::variable={::variable}" );
print( $"StaticFunc Animal::variable={Animal::variable}" );
if ( "1" )
var variable := "local var";
print( $"StaticFunc.local variable={variable}" );
print( $"StaticFunc.local Animal::variable={Animal::variable}" );
endif
endfunction
function TestFor()
for variable := 1 to 2
print( $"TestFor variable={variable} to 2" );
endfor
endfunction
function TestFuncCall()
print( $"Animal::TestFuncCall called" );
::TestFuncCall();
endfunction
endclass
print( $"global variable={variable}" );
print( $"global ::variable={::variable}" );
print( $"global Animal::variable={Animal::variable}" );
Animal::StaticFunc( "func param" );
::StaticFunc( "func param" );
print( "---" );
Animal::TestFor();
print( "---" );
Animal::TestFuncCall();