diff options
Diffstat (limited to 'debian/uncrustify-trinity/uncrustify-trinity-0.75.0/tests/input/pawn')
15 files changed, 445 insertions, 0 deletions
diff --git a/debian/uncrustify-trinity/uncrustify-trinity-0.75.0/tests/input/pawn/Issue_2586.pawn b/debian/uncrustify-trinity/uncrustify-trinity-0.75.0/tests/input/pawn/Issue_2586.pawn new file mode 100644 index 00000000..89558691 --- /dev/null +++ b/debian/uncrustify-trinity/uncrustify-trinity-0.75.0/tests/input/pawn/Issue_2586.pawn @@ -0,0 +1,5 @@ +static stock const data[][] = +{ + {0b00000011001111000010011100000000, 0b00000011001111000010011100000000}, + {0b00000011001111000010011100000000, 0b00000011001111000010011100000000} +}; diff --git a/debian/uncrustify-trinity/uncrustify-trinity-0.75.0/tests/input/pawn/Issue_2665.pawn b/debian/uncrustify-trinity/uncrustify-trinity-0.75.0/tests/input/pawn/Issue_2665.pawn new file mode 100644 index 00000000..ddcb045a --- /dev/null +++ b/debian/uncrustify-trinity/uncrustify-trinity-0.75.0/tests/input/pawn/Issue_2665.pawn @@ -0,0 +1,3 @@ +static Entrypoint() +{ +} diff --git a/debian/uncrustify-trinity/uncrustify-trinity-0.75.0/tests/input/pawn/comment.p b/debian/uncrustify-trinity/uncrustify-trinity-0.75.0/tests/input/pawn/comment.p new file mode 100644 index 00000000..785521ac --- /dev/null +++ b/debian/uncrustify-trinity/uncrustify-trinity-0.75.0/tests/input/pawn/comment.p @@ -0,0 +1,38 @@ +/* parse C comments interactively, using events and a state machine */ +main() + state plain +@keypressed(key) <plain> + { + state (key == '/') slash + if (key != '/') + echo key + } +@keypressed(key) <slash> + { + state (key != '/') plain + state (key == '*') comment + echo '/' /* print '/' held back from previous state */ + if (key != '/') + echo key + } +@keypressed(key) <comment> + { + echo key + state (key == '*') star + } +@keypressed(key) <star> + { + echo key + state (key != '*') comment + state (key == '/') plain + } +echo(key) <plain, slash> + printchar key, yellow +echo(key) <comment, star> + printchar key, green +printchar(ch, colour) + { + setattr .foreground = colour + printf "%c", ch + } + diff --git a/debian/uncrustify-trinity/uncrustify-trinity-0.75.0/tests/input/pawn/crusty_ex-1.sma b/debian/uncrustify-trinity/uncrustify-trinity-0.75.0/tests/input/pawn/crusty_ex-1.sma new file mode 100644 index 00000000..35ee0515 --- /dev/null +++ b/debian/uncrustify-trinity/uncrustify-trinity-0.75.0/tests/input/pawn/crusty_ex-1.sma @@ -0,0 +1,26 @@ +public hudtext16(textblock[],colr,colg,colb,posx,posy,screen,time,id) +{ + new y + if(contain(textblock,"^n") == -1) { // if there is no linebreak in the text, we can just show it as it is + set_hudmessage(colr, colg, colb, float(posx)/1000.0, float(posy)/1000.0, 0, 6.0, float(time), 0.2, 0.2, screen) + show_hudmessage(id,textblock) + } + else { // more than one line + new out[128],rowcounter=0,tmp[512],textremain=true;y=screen + + new i = contain(textblock,"^n") + + do + { + } + while(textremain > 0); + + copy(out,i,textblock) // we need to get the first line of text before the loop + + do + { + } + while(textremain) + } + return screen-y // we will return how many screens of text we printed +} diff --git a/debian/uncrustify-trinity/uncrustify-trinity-0.75.0/tests/input/pawn/enum.pawn b/debian/uncrustify-trinity/uncrustify-trinity-0.75.0/tests/input/pawn/enum.pawn new file mode 100644 index 00000000..588efc35 --- /dev/null +++ b/debian/uncrustify-trinity/uncrustify-trinity-0.75.0/tests/input/pawn/enum.pawn @@ -0,0 +1,82 @@ + +enum rect { left, top , right, bottom } + +enum boot (<<= 1) { a=1, b, c, d } + +enum booty (<<= 1) +{ +a=1, b, c, d +} + +forward addvector(a[], const b[], size) + +enum message { + text[40 char], + priority +} + +enum token + { + t_type, + Rational: t_value, + t_word[20], + } + +new bool:flag = true + +increment(&value, incr=1) value += incr + +new msg[message] = { !"My Text", 1 } +main() { + new my_rect[rect] + + my_rect[left] = 10 + my_rect[right] = 100 + my_rect[top] = 10 + my_rect[bottom] = 100 + + for (new i = 0; rect:i < rect; i++) + my_rect[rect:i] *= 2 + + new vect[3] = { 1, 2, 3 } + addvector(vect, {5, 5, 5}, 3) + + new Float:xpos + new Float:ypos + + new a = 5 + increment(a) + increment(a, _) + increment(a, 1) +} + +sum(a, b) + return a + b + +power(x, y) + { + /* returns x raised to the power of y */ + assert y >= 0 + new r = 1 + for (new i = 0; i < y; i++) + r *= x + return r + } + +addvector(a[], const b[], size) + { + for (new i = 0; i < size; i++) + a[i] += b[i] + } + +stock remove_filepath(szFilePath[], szFile[], pMax) +{ + new len = strlen(szFilePath); + + while ((--len >= 0) && (szFilePath[len] != '/') && +(szFilePath[len] != '\'')) { } + + copy(szFile, pMax, szFilePath[len + 1]); + + return; +} diff --git a/debian/uncrustify-trinity/uncrustify-trinity-0.75.0/tests/input/pawn/functions.pawn b/debian/uncrustify-trinity/uncrustify-trinity-0.75.0/tests/input/pawn/functions.pawn new file mode 100644 index 00000000..cdda5e05 --- /dev/null +++ b/debian/uncrustify-trinity/uncrustify-trinity-0.75.0/tests/input/pawn/functions.pawn @@ -0,0 +1,23 @@ + +// prototypes +forward bar() +native baz() +foo(); + +enum rect { left, top , right, bottom } +native intersect[rect](src1[rect], src2[rect]) + +native getparam(a[], b[], size) = host_getparam + +// function w/o brace +main() +printf("hello\n") +foo() bar() + +stock ts_is_waiting(id) return(ts_get_message(id) == TSMSG_WAITING) + +// regular old functions +baz() { + do_something() +} + diff --git a/debian/uncrustify-trinity/uncrustify-trinity-0.75.0/tests/input/pawn/gh419.pawn b/debian/uncrustify-trinity/uncrustify-trinity-0.75.0/tests/input/pawn/gh419.pawn new file mode 100644 index 00000000..9db7b08f --- /dev/null +++ b/debian/uncrustify-trinity/uncrustify-trinity-0.75.0/tests/input/pawn/gh419.pawn @@ -0,0 +1,8 @@ +#if AMXX_VERSION_NUM < 183 +public client_disconnect( player_id ) +#else +public client_disconnected( player_id ) +#endif +{ + +} diff --git a/debian/uncrustify-trinity/uncrustify-trinity-0.75.0/tests/input/pawn/preproc.pawn b/debian/uncrustify-trinity/uncrustify-trinity-0.75.0/tests/input/pawn/preproc.pawn new file mode 100644 index 00000000..e15d360e --- /dev/null +++ b/debian/uncrustify-trinity/uncrustify-trinity-0.75.0/tests/input/pawn/preproc.pawn @@ -0,0 +1,7 @@ +#define SetTeleType(%1,%2) set_pev( %1, pev_iuser1, %2 ) +#define SetTeleMate(%1,%2) set_pev( %1, pev_iuser2, %2*7) + +#define x(%0,%1)\ + y(%1,%0) + +#emit CONST.pri 1911 diff --git a/debian/uncrustify-trinity/uncrustify-trinity-0.75.0/tests/input/pawn/rpn_calc.pawn b/debian/uncrustify-trinity/uncrustify-trinity-0.75.0/tests/input/pawn/rpn_calc.pawn new file mode 100644 index 00000000..2965d9c7 --- /dev/null +++ b/debian/uncrustify-trinity/uncrustify-trinity-0.75.0/tests/input/pawn/rpn_calc.pawn @@ -0,0 +1,71 @@ +/* main rpn parser and lexical analysis, part of the RPN calculator */ +#include <rational> +#include <string> +enum token + { + t_type, /* operator or token type */ + Rational: t_value, /* value, if t_type is "Number" */ + t_word[20], /* raw string */ + } + +const Number = '0' +const EndOfExpr = '#' + +rpncalc(const string[]) + { + new index + new field[token] + for ( ;; ) + { + field = gettoken(string, index) + switch (field[t_type]) + { + case Number: + push field[t_value] + case '+': + push pop() + pop() + case '-': + push - pop() + pop() + case '*': + push pop() * pop() + case '/', ':': + push 1.0 / pop() * pop() + case EndOfExpr: + break /* exit "for" loop */ + default: + printf "Unknown operator '%s'\n", field[t_word] + } + } + + printf "Result = %r\n", pop() + + if (clearstack()) + print "Stack not empty\n", red + } + +gettoken(const string[], &index) + { + /* first get the next "word" from the string */ + new word[20] + word = strtok(string, index) + /* then parse it */ + new field[token] + field[t_word] = word + if (strlen(word) == 0) + { + field[t_type] = EndOfExpr /* special "stop" symbol */ + field[t_value] = 0 + } + else if ('0' <= word[0] <= '9') + { + field[t_type] = Number + field[t_value] = rationalstr(word) + } + else + { + field[t_type] = word[0] + field[t_value] = 0 + } + return field + } + diff --git a/debian/uncrustify-trinity/uncrustify-trinity-0.75.0/tests/input/pawn/str-escape.p b/debian/uncrustify-trinity/uncrustify-trinity-0.75.0/tests/input/pawn/str-escape.p new file mode 100644 index 00000000..5600eae3 --- /dev/null +++ b/debian/uncrustify-trinity/uncrustify-trinity-0.75.0/tests/input/pawn/str-escape.p @@ -0,0 +1,6 @@ +main() +{ + printf "This is a testof the ^" alternate escape char, value 0x5e" + printf "If ^" it doesn't work, there ^"should be some errors" +} + diff --git a/debian/uncrustify-trinity/uncrustify-trinity-0.75.0/tests/input/pawn/switch-vsemi.sma b/debian/uncrustify-trinity/uncrustify-trinity-0.75.0/tests/input/pawn/switch-vsemi.sma new file mode 100644 index 00000000..c2efacfb --- /dev/null +++ b/debian/uncrustify-trinity/uncrustify-trinity-0.75.0/tests/input/pawn/switch-vsemi.sma @@ -0,0 +1,16 @@ +public plugin_init()
+{
+ new i=5
+
+ switch(i){
+ case 3: return false
+ case 5:
+ {
+ i = 6
+ return true
+ }
+ default: {
+ return true
+ }
+ }
+}
\ No newline at end of file diff --git a/debian/uncrustify-trinity/uncrustify-trinity-0.75.0/tests/input/pawn/tags.pawn b/debian/uncrustify-trinity/uncrustify-trinity-0.75.0/tests/input/pawn/tags.pawn new file mode 100644 index 00000000..56bdd2b9 --- /dev/null +++ b/debian/uncrustify-trinity/uncrustify-trinity-0.75.0/tests/input/pawn/tags.pawn @@ -0,0 +1,63 @@ + +enum token + { + t_type, + Rational: t_value, + t_word[20], + } + + +new bool:flag = true /* "flag" can only hold "true" or "false" */ +const error:success = 0 +const error:fatal= 1 +const error:nonfatal = 2 +error:errno = fatal + +native printf(const format[], {Float, _}: ...); + + new Float:chance_to_avoid = (p_resists[id][RESISTIDX_FIRE] >= RESIST_MAX_VALUE) ? + 1.00 : (float( p_resists[id][RESISTIDX_FIRE] ) / float( RESIST_MAX_VALUE )) + + xplevel_lev[j] = XP_PER_LEVEL_BASE_LT + ( (j - 10) * XP_PER_LEVEL_LT) + + floatround( float( j / 20 ) * XP_PER_LEVEL_LT ); + + +main() { + new Float:xpos + new Float:ypos + + new apple:elstar /* variable "elstar" with tag "apple" */ + new orange:valencia /* variable "valencia" with tag "orange" */ + new x /* untagged variable "x" */ + elstar = valencia /* tag mismatch */ + elstar = x /* tag mismatch */ + x = valencia /* ok */ + + new Float:chance_to_avoid = (p_resists[id][RESISTIDX_FIRE] >= RESIST_MAX_VALUE) ? + 1.00 : (float( p_resists[id][RESISTIDX_FIRE] ) / float( RESIST_MAX_VALUE )) + + xplevel_lev[j] = XP_PER_LEVEL_BASE_LT + ( (j - 10) * XP_PER_LEVEL_LT) + + floatround( float( j / 20 ) * XP_PER_LEVEL_LT ); + + if (apple:valencia < elstar) + valencia = orange:elstar + +some_label: // target for a goto + #pragma rational Float + + new Float:limit = -5.0 + new Float:value = -1.0 + if (value < limit) + printf("Value %f below limit %f\n", _:value, _:limit) + else + printf("Value above limit\n") + goto some_label +} + +foo() + if (ape) + dofunc(1) + else if (monkey) + dofunc(2) + else + dofunc(3) diff --git a/debian/uncrustify-trinity/uncrustify-trinity-0.75.0/tests/input/pawn/test1.pawn b/debian/uncrustify-trinity/uncrustify-trinity-0.75.0/tests/input/pawn/test1.pawn new file mode 100644 index 00000000..ecefe6e0 --- /dev/null +++ b/debian/uncrustify-trinity/uncrustify-trinity-0.75.0/tests/input/pawn/test1.pawn @@ -0,0 +1,59 @@ + +#define SCROLLMSG_SIZE 512 + +#define SCROLLMSG_SIZE 512 + +#define MIN(%1,%2) ((%1) < (%2) ? (%1) : (%2)) +#define MAX(%1,%2) ((%1)>(%2)?(%1):(%2)) + + +//Why doesn't it make them all one space? + +#define ADMIN_NORMAL (1<<1) +#define ADMIN_STEAM (1<<2) + + +#define ADMIN_NORMAL (1<<1) +#define ADMIN_STEAM (1<<2) + +//Why space before and after colon? + +new Float:g_xPos +new Float : g_xPos + +// col1 + // col2 + // col3 + // col4 + // col5 + +//Why so many tabs? +main() { + remove_task(123) /* remove current messaging */ + + remove_user_flags(0, read_flags("z")) // Remove 'user' flag from server rights + + new idtype = ADMIN_STEAM | ADMIN_LOOKUP // trail 1 + new idtype = ADMIN_STEAM|ADMIN_LOOKUP // trail 2 + // trail 3 + // trail 4 + + if (idtype & ADMIN_STEAM) + { + a++ + } + else if (equali(t_arg, "ip")) + { + b++ + } + + for (new _i=0; _i<_num; _i++) + { + c++ + } + + for (new _i = 0; _i < _num; _i++) + { + d++ + } +} diff --git a/debian/uncrustify-trinity/uncrustify-trinity-0.75.0/tests/input/pawn/traffic.p b/debian/uncrustify-trinity/uncrustify-trinity-0.75.0/tests/input/pawn/traffic.p new file mode 100644 index 00000000..f5cf0f7f --- /dev/null +++ b/debian/uncrustify-trinity/uncrustify-trinity-0.75.0/tests/input/pawn/traffic.p @@ -0,0 +1,28 @@ +/* traffic light synchronizer, using states in an event-driven model */ +#include <time> +main() state green_wait +@keypressed(key) <green_wait> state yellow_wait +@keypressed(key) <red_walk, red_wait> state red_walk +@keypressed(key) <> {} /* fallback */ +@timer() <yellow_wait> state red_walk +@timer() <red_walk> state red_wait +@timer() <red_wait> state green_wait +@timer() <> {} /* fallback */ +entry() <green_wait> + print "Green / Don't walk\n" +entry() <yellow_wait> + { + print "Yellow / Don't walk\n" + settimer 2000 + } +entry() <red_walk> + { + print "Red / Walk\n" + settimer 5000 + } +entry() <red_wait> + { + print "Red / Don't walk\n" + settimer 2000 + } + diff --git a/debian/uncrustify-trinity/uncrustify-trinity-0.75.0/tests/input/pawn/unbraced.p b/debian/uncrustify-trinity/uncrustify-trinity-0.75.0/tests/input/pawn/unbraced.p new file mode 100644 index 00000000..10c41663 --- /dev/null +++ b/debian/uncrustify-trinity/uncrustify-trinity-0.75.0/tests/input/pawn/unbraced.p @@ -0,0 +1,10 @@ + +public eBombPickUp(id) + if (BombPickUp) + announceEvent(id, "PICKED_BOMB") + +stock Float:operator-(Float:oper) + return oper^Float:((-1)^((-1)/2)); /* IEEE values are sign/magnitude */ + +native Float: floatadd( Float:dividend, Float:divisor ); +native Result: dbi_query( Sql:_sql, _query[], { Float, _ }: ... ); |