mirror of
https://github.com/polserver/polserver
synced 2026-08-13 08:23:08 -04:00
* Format escript testsuite
* Manual formatting for escript testsuite
- Add format-off to places where formatter does what it should, but we don't like the results
- Manually change places where formatter outputs weird things _without_ format-off, so next format-all would show changes if not fixed
* Update .err files; add update_err.py helper script
Use the format `:line:col: message` for all .err file checks. This
allows us to change the file names without needing to edit the .err
contents.
Note that `in/inc0{1,2}.err` need have error messages between POSIX and
Windows, so their messages are a bit more "generic" than the other errs.
* Format pol testsuite
* Manual formatting for pol testsuite
* Format pol-core modules
* Manual formatting for pol-core modules
* Additional format pol-core modules
Use FormatterLineWidth=10000 since module functions must be on one line
because of the parse_modules target
* Address Discord comments
- Support multi-line module function declarations in parse_modules
* Format on df07831
207 lines
4.4 KiB
Text
207 lines
4.4 KiB
Text
// 2018-04-16 Bodom, ultimate string testing, unicode version
|
||
// Trying to include all string-related stuff in this script.
|
||
|
||
use uo;
|
||
use os;
|
||
|
||
var t := "Нè└└☺";
|
||
var sep := "―――――――――――――――――――――――――――――――――――――――――――――";
|
||
|
||
// pack/unpack
|
||
var p := Pack( t );
|
||
print( p );
|
||
var u := Unpack( p );
|
||
print( u );
|
||
print( u == t );
|
||
print( p != u );
|
||
print( sep );
|
||
|
||
var optests := array{ "1234",
|
||
"Нè└└☺",
|
||
"b",
|
||
"ab",
|
||
"a",
|
||
"caterpillar", array{ "α", "β", "γ", 19 },
|
||
dictionary{ "ⅠⅡⅢⅣ" -> "𐄜𐄝𐄞", "eeee" -> 0 } };
|
||
|
||
// Binary operators
|
||
foreach ot in optests
|
||
var tmp;
|
||
|
||
// comparison
|
||
print( "t == " + ot );
|
||
print( t == ot );
|
||
print( CStr( ot ) + " == t " );
|
||
print( ot == t );
|
||
print( "t != " + ot );
|
||
print( t != ot );
|
||
print( "t < " + ot );
|
||
print( t < ot );
|
||
print( "t <= " + ot );
|
||
print( t <= ot );
|
||
print( "t > " + ot );
|
||
print( t > ot );
|
||
print( "t >= " + ot );
|
||
print( t >= ot );
|
||
|
||
// arithmetic
|
||
print( "t + " + ot );
|
||
print( t + ot );
|
||
print( CStr( ot ) + " + t" );
|
||
print( ot + t );
|
||
print( "t - " + ot );
|
||
print( t - ot );
|
||
print( CStr( ot ) + " - t" );
|
||
print( ot - t );
|
||
print( "t * " + ot );
|
||
print( t * ot );
|
||
print( CStr( ot ) + " * t" );
|
||
print( ot * t );
|
||
print( "t / " + ot );
|
||
print( t / ot );
|
||
print( CStr( ot ) + " / t" );
|
||
print( ot / t );
|
||
print( "t % " + ot );
|
||
print( t % ot );
|
||
print( CStr( ot ) + " % t" );
|
||
print( ot % t );
|
||
|
||
// arithmetic with assignment
|
||
tmp := t;
|
||
print( "tmp += " + ot );
|
||
tmp += ot;
|
||
print( tmp );
|
||
tmp := t;
|
||
print( "tmp -= " + ot );
|
||
tmp -= ot;
|
||
print( tmp );
|
||
tmp := t;
|
||
print( "tmp *= " + ot );
|
||
tmp *= ot;
|
||
print( tmp );
|
||
tmp := t;
|
||
print( "tmp /= " + ot );
|
||
tmp /= ot;
|
||
print( tmp );
|
||
tmp := t;
|
||
print( "tmp %= " + ot );
|
||
tmp %= ot;
|
||
print( tmp );
|
||
|
||
// bitwise
|
||
print( "t & " + ot );
|
||
print( t & ot );
|
||
print( CStr( ot ) + " & t" );
|
||
print( ot & t );
|
||
print( "t | " + ot );
|
||
print( t | ot );
|
||
print( CStr( ot ) + " | t" );
|
||
print( ot | t );
|
||
print( "t ^ " + ot );
|
||
print( t ^ ot );
|
||
print( CStr( ot ) + " ^ t" );
|
||
print( ot ^ t );
|
||
print( "t << " + ot );
|
||
print( t << ot );
|
||
print( CStr( ot ) + " << t" );
|
||
print( ot << t );
|
||
print( "t >> " + ot );
|
||
print( t >> ot );
|
||
print( CStr( ot ) + " >> t" );
|
||
print( ot >> t );
|
||
|
||
// member
|
||
tmp := t;
|
||
print( "tmp .+ " + ot );
|
||
tmp.+ot;
|
||
print( tmp );
|
||
tmp := t;
|
||
print( "tmp .- " + ot );
|
||
tmp.-ot;
|
||
print( tmp );
|
||
tmp := t;
|
||
|
||
// subscript
|
||
print( "t[" + ot + "]" );
|
||
print( t[ot] );
|
||
|
||
print( sep );
|
||
endforeach
|
||
|
||
// Unary operators
|
||
print( "~ t" );
|
||
print( ~t );
|
||
print( sep );
|
||
|
||
// Cast
|
||
print( CAsc( t ) );
|
||
print( CAscZ( t ) );
|
||
print( CChr( t ) );
|
||
print( CChrZ( t ) );
|
||
print( CDbl( t ) );
|
||
print( CInt( t ) );
|
||
print( CStr( t ) );
|
||
print( sep );
|
||
|
||
// substring
|
||
print( t[0, 1] );
|
||
print( t[1, 99] );
|
||
print( t[1, 0] );
|
||
print( t[1, 10] );
|
||
print( t[2, 2] );
|
||
print( t["└└"] );
|
||
var tmp := t;
|
||
tmp["└└"] := "__";
|
||
print( tmp );
|
||
print( sep );
|
||
|
||
// is true
|
||
if ( t )
|
||
print( "t is true" );
|
||
else
|
||
print( "t is false" );
|
||
endif
|
||
if ( "" )
|
||
print( "\"\" is true" );
|
||
else
|
||
print( "\"\" is false" );
|
||
endif
|
||
if ( "0" )
|
||
print( "0 is true" );
|
||
else
|
||
print( "0 is false" );
|
||
endif
|
||
print( sep );
|
||
|
||
// manipulation functions
|
||
print( Compare( t, "bè└└☺", 2, 3, 2, 3 ) );
|
||
print( Find( t, "└└", 1 ) );
|
||
print( Len( t ) );
|
||
print( Lower( "Здраво!" ) );
|
||
print( SplitWords( "ⅠⅡⅢ 456 789", " ", 1 ) );
|
||
print( StrReplace( t, "└└", "__" ) );
|
||
print( SubStr( t, 2, 2 ) );
|
||
print( SubStrReplace( t, "XXXXXX", 2, 3 ) );
|
||
print( Trim( " Ћао " ) );
|
||
print( Upper( "Здраво!" ) );
|
||
print( sep );
|
||
|
||
// methods
|
||
print( t.length() );
|
||
print( t );
|
||
print( t.find( "è" ) );
|
||
print( t.upper() );
|
||
print( t.lower() );
|
||
print( "{:x}".format( 10 ) );
|
||
print( "{:#x}".format( 10 ) );
|
||
print( "You hàve {} ☉ coins".format( 120 ) );
|
||
print( "{} hits {} for {} of ☠".format( "John", "Bob", 120 ) );
|
||
print( "You hit {2} for {1} ☠".format( 120, "John Doe" ) );
|
||
print( "⚗ {1.spell_name} requires reagents: {1.reagents}".format( struct{ spell_name := "Firè Wrath",
|
||
reagents := "Ba, Bm, Ga" }
|
||
) );
|
||
print( "{name} you ⚔ level {level}".format( struct{ name := "Jane Doe", level := 4 } ) );
|
||
print( sep );
|
||
|
||
// check that t is unaltered
|
||
print( t );
|