mirror of
https://github.com/polserver/polserver
synced 2026-08-13 08:23:08 -04:00
* Support default args in funcref calls - Simplify BFunctionRef by using funcref index - Emit default args when visiting function reference * Move default args gen to second-pass visit * Better error message on param count errors * Check for constructor in MTH_NEW * Address self-review comments - Update code comments * Introduce ResourceManager to pol testsuite - Create a new class-based resource manager for deleting resources (item NPCs, multis) after each test. - Migrate house_set_multiid test to use new ResourceManager. * Move resource cleanup
47 lines
1.4 KiB
Text
47 lines
1.4 KiB
Text
// Test method calls with default args and variadic args
|
|
|
|
class Foo()
|
|
function Foo( this )
|
|
endfunction
|
|
|
|
function MethodA( this, arg0 )
|
|
return $"Foo::MethodA this={this} arg0={arg0}";
|
|
endfunction
|
|
|
|
function MethodB( this, arg0, arg1 := "default.a1" )
|
|
return $"Foo::MethodB this={this} arg0={arg0} arg1={arg1}";
|
|
endfunction
|
|
|
|
function MethodC( this, arg0, arg1 := "default.a1", arg2 := "default.a2" )
|
|
return $"Foo::MethodC this={this} arg0={arg0} arg1={arg1} arg2={arg2}";
|
|
endfunction
|
|
|
|
function MethodD( this, arg0, arg1 := "default.a1", arg2 := "default.a2", args ... )
|
|
return $"Foo::MethodD this={this} arg0={arg0} arg1={arg1} arg2={arg2} args={args}";
|
|
endfunction
|
|
endclass
|
|
|
|
var obj := Foo();
|
|
|
|
print( obj.MethodA() );
|
|
print( obj.MethodA( "a0" ) );
|
|
print( obj.MethodA( "a0", "a1" ) );
|
|
print( "-" );
|
|
print( obj.MethodB() );
|
|
print( obj.MethodB( "a0" ) );
|
|
print( obj.MethodB( "a0", "a1" ) );
|
|
print( obj.MethodB( "a0", "a1", "a2" ) );
|
|
print( "-" );
|
|
print( obj.MethodC() );
|
|
print( obj.MethodC( "a0" ) );
|
|
print( obj.MethodC( "a0", "a1" ) );
|
|
print( obj.MethodC( "a0", "a1", "a2" ) );
|
|
print( obj.MethodC( "a0", "a1", "a2", "a3" ) );
|
|
print( "-" );
|
|
print( obj.MethodD() );
|
|
print( obj.MethodD( "a0" ) );
|
|
print( obj.MethodD( "a0", "a1" ) );
|
|
print( obj.MethodD( "a0", "a1", "a2" ) );
|
|
print( obj.MethodD( "a0", "a1", "a2", "a3" ) );
|
|
print( obj.MethodD( "a0", "a1", "a2", "a3", "a4" ) );
|
|
print( obj.MethodD( "a0", "a1", "a2", "a3", "a4", "a5" ) );
|