diff --git a/src/ChangeLog b/src/ChangeLog index 9cf1a53961883fca793b72fd09c690c96f849be5..cf42953b92626991962b53363550d79f322a31de 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +Tue Feb 24 09:03:37 1998 Fredrik Hubinette <hubbe@cytocin.hubbe.net> + + * `<, `>, `<=, `>=, `==, `!=, `/, `-, min and max now take + more than two parameters + * better error messages implemented + Thu Feb 19 14:40:54 1998 Fredrik Hubinette <hubbe@cytocin.hubbe.net> * opcodes.c (o_cast): recursive casting implemented diff --git a/src/language.yacc b/src/language.yacc index 732c8de4c0ec5ce85c8929085474fda86c821493..2ef3d02d0178a6486b54e53f1bf4b94178e5b6e6 100644 --- a/src/language.yacc +++ b/src/language.yacc @@ -162,7 +162,7 @@ /* This is the grammar definition of Pike. */ #include "global.h" -RCSID("$Id: language.yacc,v 1.59 1998/02/01 04:01:33 hubbe Exp $"); +RCSID("$Id: language.yacc,v 1.60 1998/02/24 23:01:28 hubbe Exp $"); #ifdef HAVE_MEMORY_H #include <memory.h> #endif @@ -1337,20 +1337,14 @@ low_idents: F_IDENTIFIER } | F_IDENTIFIER F_COLON_COLON F_IDENTIFIER { - int f; - struct reference *idp; - - f=reference_inherited_identifier($1->u.sval.u.string, + $$=reference_inherited_identifier($1->u.sval.u.string, $3->u.sval.u.string); - idp=new_program->identifier_references+f; - if (f<0) + if (!$$) { my_yyerror("Undefined identifier %s::%s", $1->u.sval.u.string->str, $3->u.sval.u.string->str); $$=mkintnode(0); - } else { - $$=mkidentifiernode(f); } free_node($1); @@ -1364,7 +1358,7 @@ low_idents: F_IDENTIFIER for(e=1;e<(int)new_program->num_inherits;e++) { if(new_program->inherits[e].inherit_level!=1) continue; - i=low_reference_inherited_identifier(e,$2->u.sval.u.string); + i=low_reference_inherited_identifier(0,e,$2->u.sval.u.string); if(i==-1) continue; if($$) { diff --git a/src/las.c b/src/las.c index 41d9d2dc2ee84727c41f700fe14dcfea4d647ca1..d3596454d8dd5f41309cc80cb20b5f2bbe240d34 100644 --- a/src/las.c +++ b/src/las.c @@ -4,7 +4,7 @@ ||| See the files COPYING and DISCLAIMER for more information. \*/ #include "global.h" -RCSID("$Id: las.c,v 1.51 1998/02/23 23:24:02 hubbe Exp $"); +RCSID("$Id: las.c,v 1.52 1998/02/24 23:01:29 hubbe Exp $"); #include "language.h" #include "interpret.h" @@ -1434,12 +1434,12 @@ void fix_type_field(node *n) f=CAR(n)->type?CAR(n)->type:mixed_type_string; n->type=check_call(s,f); args=count_arguments(s); - max_args=get_max_args(f); + max_args=count_arguments(f); + if(max_args<0) max_args=0x7fffffff; if(!n->type) { char *name; - int args; switch(CAR(n)->token) { case F_IDENTIFIER: @@ -1479,7 +1479,7 @@ void fix_type_field(node *n) if(max_args < args) { - my_yyerror("To many arguments to %s.\n",name); + my_yyerror("Too many arguments to %s. (%d %d)\n",name,max_args,args); } else if(max_correct_args == args) { diff --git a/src/operators.c b/src/operators.c index 9bd585357e955927c7affd5d0711fdab7e9cdf64..4d67918b90a67d3b80971903bb1742efab792a1b 100644 --- a/src/operators.c +++ b/src/operators.c @@ -5,7 +5,7 @@ \*/ #include <math.h> #include "global.h" -RCSID("$Id: operators.c,v 1.25 1998/02/23 23:24:03 hubbe Exp $"); +RCSID("$Id: operators.c,v 1.26 1998/02/24 23:01:30 hubbe Exp $"); #include "interpret.h" #include "svalue.h" #include "multiset.h" @@ -1102,11 +1102,13 @@ void o_divide(void) if(!len) error("Division by zero.\n"); - size=sp[-2].u.string->len / len; if(len<0) { len=-len; - pos+=size % len; + size=sp[-2].u.string->len / len; + pos+=sp[-2].u.string->len % len; + }else{ + size=sp[-2].u.string->len / len; } a=allocate_array(size); for(e=0;e<size;e++) @@ -1137,39 +1139,43 @@ void o_divide(void) size=(INT32)ceil( ((double)sp[-2].u.string->len) / len); a=allocate_array(size); - for(last=sp[-2].u.string->len,e=0;e<size;e++) + for(last=sp[-2].u.string->len,e=0;e<size-1;e++) { pos=sp[-2].u.string->len - (INT32)((e+1)*len); - a->item[e].u.string=make_shared_binary_string( + a->item[size-1-e].u.string=make_shared_binary_string( sp[-2].u.string->str + pos, last-pos); + a->item[size-1-e].type=T_STRING; last=pos; } pos=0; - a->item[e].u.string=make_shared_binary_string( + a->item[0].u.string=make_shared_binary_string( sp[-2].u.string->str + pos, last-pos); + a->item[0].type=T_STRING; }else{ size=(INT32)ceil( ((double)sp[-2].u.string->len) / len); a=allocate_array(size); - for(last=0,e=0;e<size;e++) + for(last=0,e=0;e<size-1;e++) { pos=(INT32)((e+1)*len); a->item[e].u.string=make_shared_binary_string( sp[-2].u.string->str + last, pos-last); + a->item[e].type=T_STRING; last=pos; } - pos=sp[2].u.string->len; + pos=sp[-2].u.string->len; a->item[e].u.string=make_shared_binary_string( sp[-2].u.string->str + last, pos-last); + a->item[e].type=T_STRING; } a->type_field=BIT_STRING; pop_n_elems(2); push_array(a); - break; + return; } @@ -1182,11 +1188,13 @@ void o_divide(void) if(!len) error("Division by zero.\n"); - size=sp[-2].u.array->size / len; if(len<0) { len=-len; - pos+=size % len; + size=sp[-2].u.array->size / len; + pos+=sp[-2].u.array->size % len; + }else{ + size=sp[-2].u.array->size / len; } a=allocate_array(size); for(e=0;e<size;e++) @@ -1219,37 +1227,41 @@ void o_divide(void) size=(INT32)ceil( ((double)sp[-2].u.array->size) / len); a=allocate_array(size); - for(last=sp[-2].u.array->size,e=0;e<size;e++) + for(last=sp[-2].u.array->size,e=0;e<size-1;e++) { pos=sp[-2].u.array->size - (INT32)((e+1)*len); - a->item[e].u.array=friendly_slice_array(sp[-2].u.array, + a->item[size-1-e].u.array=friendly_slice_array(sp[-2].u.array, pos, last); + a->item[size-1-e].type=T_ARRAY; last=pos; } - a->item[e].u.array=slice_array(sp[-2].u.array, + a->item[0].u.array=slice_array(sp[-2].u.array, 0, last); + a->item[0].type=T_ARRAY; }else{ size=(INT32)ceil( ((double)sp[-2].u.array->size) / len); a=allocate_array(size); - for(last=0,e=0;e<size;e++) + for(last=0,e=0;e<size-1;e++) { pos=(INT32)((e+1)*len); a->item[e].u.array=friendly_slice_array(sp[-2].u.array, last, pos); + a->item[e].type=T_ARRAY; last=pos; } a->item[e].u.array=slice_array(sp[-2].u.array, last, - sp[2].u.array->size); + sp[-2].u.array->size); + a->item[e].type=T_ARRAY; } a->type_field=BIT_ARRAY; pop_n_elems(2); push_array(a); - break; + return; } } @@ -1361,8 +1373,15 @@ void o_mod(void) if(!sp[-1].u.integer) error("Modulo by zero.\n"); - tmp=s->len % sp[-1].u.integer; - base=s->len<0 ? 0 : s->len - tmp; + tmp=sp[-1].u.integer; + if(tmp<0) + { + tmp=s->len % -tmp; + base=0; + }else{ + tmp=s->len % tmp; + base=s->len - tmp; + } s=make_shared_binary_string(s->str + base, tmp); pop_n_elems(2); push_string(s); @@ -1377,8 +1396,16 @@ void o_mod(void) if(!sp[-1].u.integer) error("Modulo by zero.\n"); - tmp=a->size % sp[-1].u.integer; - base=a->size<0 ? 0 : a->size - tmp; + tmp=sp[-1].u.integer; + if(tmp<0) + { + tmp=a->size % -tmp; + base=0; + }else{ + tmp=a->size % tmp; + base=a->size - tmp; + } + a=slice_array(a,base,base+tmp); pop_n_elems(2); push_array(a); @@ -1757,7 +1784,14 @@ void init_operators(void) "function(string,string|int|float...:array(string))", OPT_TRY_OPTIMIZE,0,generate_divide); - add_efun2("`%",f_mod,"function(mixed,object:mixed)|function(object,mixed:mixed)|function(int,int:int)|!function(int,int:mixed)&function(int|float,int|float:float)",OPT_TRY_OPTIMIZE,0,generate_mod); + add_efun2("`%",f_mod, + "function(mixed,object:mixed)|" + "function(object,mixed:mixed)|" + "function(int,int:int)|" + "function(string,int:string)|" + "function(array,int:array)|" + "!function(int,int:mixed)&function(int|float,int|float:float)" + ,OPT_TRY_OPTIMIZE,0,generate_mod); add_efun2("`~",f_compl,"function(object:mixed)|function(int:int)|function(float:float)|function(string:string)",OPT_TRY_OPTIMIZE,0,generate_compl); add_efun2("sizeof", f_sizeof, "function(string|multiset|array|mapping|object:int)",0,0,generate_sizeof); diff --git a/src/peep.in b/src/peep.in index b594bd99ef8c6d3d50eb0b8571b9ce341bfd5c5a..31da2710d2ef42f6fef92cc33e7d215fc764beb9 100644 --- a/src/peep.in +++ b/src/peep.in @@ -32,13 +32,13 @@ CONST0 ASSIGN_LOCAL_AND_POP : CLEAR_LOCAL($2a) CLEAR_LOCAL NUMBER(0) ASSIGN_LOCAL_AND_POP ($1a) : CLEAR_LOCAL($1a) CLEAR_LOCAL NUMBER(0) ASSIGN_LOCAL_AND_POP ($1a+1) : CLEAR_2_LOCAL($1a) -CONST_1 MULTIPLY : NEGATE +#CONST_1 MULTIPLY : NEGATE #CONST0 MULTIPLY : POP_VALUE CONST0 -CONST1 MULTIPLY : +#CONST1 MULTIPLY : #NUMBER MULTIPLY [count_bits($1a)==1]: NUMBER(my_log2($1a)) LSH -CONST_1 DIVIDE : NEGATE -CONST1 DIVIDE : +#CONST_1 DIVIDE : NEGATE +#CONST1 DIVIDE : #NUMBER DIVIDE [count_bits($1a)==1]: NUMBER(my_log2($1a)) RSH CONST0 SUBTRACT: diff --git a/src/pike_types.c b/src/pike_types.c index b1b12a420b9e37feb1d3a6c0a86ef67501bcaa7f..a76cc29f1beb00b48fe03cf196ac3e05c41de47e 100644 --- a/src/pike_types.c +++ b/src/pike_types.c @@ -4,7 +4,7 @@ ||| See the files COPYING and DISCLAIMER for more information. \*/ #include "global.h" -RCSID("$Id: pike_types.c,v 1.32 1998/02/23 23:24:04 hubbe Exp $"); +RCSID("$Id: pike_types.c,v 1.33 1998/02/24 23:01:31 hubbe Exp $"); #include <ctype.h> #include "svalue.h" #include "pike_types.h" @@ -1094,7 +1094,7 @@ int check_indexing(struct pike_string *type, static int low_count_arguments(char *q) { int num,num2; - + switch(EXTRACT_UCHAR(q++)) { case T_OR: @@ -1113,7 +1113,7 @@ static int low_count_arguments(char *q) if(num2<0 && num<0) return ~num<~num2?num:num2; return num<num2?num:num2; - default: return MAX_LOCAL; + default: return 0x7fffffff; case T_FUNCTION: num=0; diff --git a/src/program.c b/src/program.c index 6db5bd294430ea18fcd4f472402457c21e0b26f1..a1647e69c327ea26e1b25bc8bbe8d24577f276c8 100644 --- a/src/program.c +++ b/src/program.c @@ -4,7 +4,7 @@ ||| See the files COPYING and DISCLAIMER for more information. \*/ #include "global.h" -RCSID("$Id: program.c,v 1.62 1998/01/30 16:49:30 grubba Exp $"); +RCSID("$Id: program.c,v 1.63 1998/02/24 23:01:32 hubbe Exp $"); #include "program.h" #include "object.h" #include "dynamic_buffer.h" @@ -118,23 +118,44 @@ dynamic_buffer used_modules; #endif #define FOO(NUMTYPE,TYPE,NAME) \ -void PIKE_CONCAT(add_to_,NAME) (TYPE ARG) { \ +void PIKE_CONCAT(add_to_,NAME) (TYPE ARG) { \ CHECK_FOO(NUMTYPE,TYPE,NAME); \ - if(malloc_size_program->PIKE_CONCAT(num_,NAME) == new_program->PIKE_CONCAT(num_,NAME)) { \ + if(malloc_size_program->PIKE_CONCAT(num_,NAME) == \ + new_program->PIKE_CONCAT(num_,NAME)) { \ void *tmp; \ - malloc_size_program->PIKE_CONCAT(num_,NAME) *= 2; \ - malloc_size_program->PIKE_CONCAT(num_,NAME)++; \ + malloc_size_program->PIKE_CONCAT(num_,NAME) *= 2; \ + malloc_size_program->PIKE_CONCAT(num_,NAME)++; \ tmp=realloc((char *)new_program->NAME, \ sizeof(TYPE) * \ - malloc_size_program->PIKE_CONCAT(num_,NAME)); \ + malloc_size_program->PIKE_CONCAT(num_,NAME)); \ if(!tmp) fatal("Out of memory.\n"); \ new_program->NAME=tmp; \ } \ - new_program->NAME[new_program->PIKE_CONCAT(num_,NAME)++]=(ARG); \ + new_program->NAME[new_program->PIKE_CONCAT(num_,NAME)++]=(ARG); \ } #include "program_areas.h" +#define FOO(NUMTYPE,TYPE,NAME) \ +void PIKE_CONCAT(low_add_to_,NAME) (struct program_state *state, \ + TYPE ARG) { \ + if(state->malloc_size_program->PIKE_CONCAT(num_,NAME) == \ + state->new_program->PIKE_CONCAT(num_,NAME)) { \ + void *tmp; \ + state->malloc_size_program->PIKE_CONCAT(num_,NAME) *= 2; \ + state->malloc_size_program->PIKE_CONCAT(num_,NAME)++; \ + tmp=realloc((char *)state->new_program->NAME, \ + sizeof(TYPE) * \ + state->malloc_size_program->PIKE_CONCAT(num_,NAME)); \ + if(!tmp) fatal("Out of memory.\n"); \ + state->new_program->NAME=tmp; \ + } \ + state->new_program->NAME[state->new_program->PIKE_CONCAT(num_,NAME)++]=(ARG); \ +} + +#include "program_areas.h" + + void ins_int(INT32 i, void (*func)(char tmp)) { int e; @@ -752,7 +773,7 @@ struct program *end_first_pass(int finish) { int id; if(new_program->inherits[e].inherit_level!=1) continue; - id=low_reference_inherited_identifier(e, s); + id=low_reference_inherited_identifier(0, e, s); if(id!=-1) { init_node=mknode(F_ARG_LIST, @@ -868,14 +889,16 @@ void set_gc_mark_callback(void (*m)(struct object *)) new_program->gc_marked=m; } -int low_reference_inherited_identifier(int e, +int low_reference_inherited_identifier(struct program_state *q, + int e, struct pike_string *name) { + struct program *np=q?q->new_program:new_program; struct reference funp; struct program *p; int i,d; - p=new_program->inherits[e].prog; + p=np->inherits[e].prog; i=find_shared_string_identifier(name,p); if(i==-1) return i; @@ -886,44 +909,72 @@ int low_reference_inherited_identifier(int e, funp.inherit_offset+=e; funp.id_flags|=ID_HIDDEN; - for(d=0;d<(int)new_program->num_identifier_references;d++) + for(d=0;d<(int)np->num_identifier_references;d++) { struct reference *fp; - fp=new_program->identifier_references+d; + fp=np->identifier_references+d; if(!MEMCMP((char *)fp,(char *)&funp,sizeof funp)) return d; } - add_to_identifier_references(funp); - return new_program->num_identifier_references -1; + if(q) + low_add_to_identifier_references(q,funp); + else + add_to_identifier_references(funp); + return np->num_identifier_references -1; } -int reference_inherited_identifier(struct pike_string *super_name, - struct pike_string *function_name) +static int middle_reference_inherited_identifier( + struct program_state *state, + struct pike_string *super_name, + struct pike_string *function_name) { int e,i; + struct program *p=state?state->new_program:new_program; #ifdef DEBUG if(function_name!=debug_findstring(function_name)) fatal("reference_inherited_function on nonshared string.\n"); #endif - - for(e=new_program->num_inherits-1;e>0;e--) + + for(e=p->num_inherits-1;e>0;e--) { - if(new_program->inherits[e].inherit_level!=1) continue; - if(!new_program->inherits[e].name) continue; + if(p->inherits[e].inherit_level!=1) continue; + if(!p->inherits[e].name) continue; if(super_name) - if(super_name != new_program->inherits[e].name) + if(super_name != p->inherits[e].name) continue; - i=low_reference_inherited_identifier(e,function_name); + i=low_reference_inherited_identifier(state,e,function_name); if(i==-1) continue; return i; } return -1; } +node *reference_inherited_identifier(struct pike_string *super_name, + struct pike_string *function_name) +{ + int i,n; + struct program_state *p=previous_program_state; + + i=middle_reference_inherited_identifier(0, + super_name, + function_name); + if(i!=-1) return mkidentifiernode(i); + + for(n=0;n<compilation_depth;n++,p=p->previous) + { + i=middle_reference_inherited_identifier(p,super_name, + function_name); + if(i!=-1) + return mkexternalnode(n,i,ID_FROM_INT(p->new_program, i)); + } + + return 0; +} + void rename_last_inherit(struct pike_string *n) { if(new_program->inherits[new_program->num_inherits].name) diff --git a/src/program.h b/src/program.h index 4d7c64cdc2df59925bb1b8530abd546203f49ee1..8582ceddcd72b73c70a962b1d0375ee26701da3a 100644 --- a/src/program.h +++ b/src/program.h @@ -69,6 +69,8 @@ struct node_s; struct object; #endif +struct program_state; + /* I need: * a) one type that can point to a callable function. * (C function, or object->fun) @@ -245,9 +247,10 @@ SIZE_T add_storage(SIZE_T size); void set_init_callback(void (*init)(struct object *)); void set_exit_callback(void (*exit)(struct object *)); void set_gc_mark_callback(void (*m)(struct object *)); -int low_reference_inherited_identifier(int e, +int low_reference_inherited_identifier(struct program_state *q, + int e, struct pike_string *name); -int reference_inherited_identifier(struct pike_string *super_name, +node *reference_inherited_identifier(struct pike_string *super_name, struct pike_string *function_name); void rename_last_inherit(struct pike_string *n); void low_inherit(struct program *p, diff --git a/src/signal_handler.c b/src/signal_handler.c index 0f7ac6b0af253c0d570cc01b9a29c811cd01c02c..7e7261aee79b6433d2f20f1aa0e0a053036d0e31 100644 --- a/src/signal_handler.c +++ b/src/signal_handler.c @@ -923,7 +923,6 @@ void f_create_process(INT32 args) #ifdef HAVE_GETPWNAM case T_STRING: - printf("poof\n"); pw=getpwnam(tmp->u.string->str); if(!pw) exit(77); wanted_uid=pw->pw_uid; @@ -1060,7 +1059,6 @@ void f_create_process(INT32 args) /* Left to do: cleanup? */ } - printf("foo\n"); #ifdef HAVE_SETGID #ifdef HAVE_GETGID if(wanted_gid != getgid()) @@ -1075,7 +1073,6 @@ void f_create_process(INT32 args) } #endif - printf("bar\n"); #ifdef HAVE_SETUID #ifdef HAVE_GETUID @@ -1089,7 +1086,7 @@ void f_create_process(INT32 args) if(!pw) pw=getpwuid(wanted_uid); if(!pw) exit(77); initgroupgid=pw->pw_gid; - printf("uid=%d euid=%d initgroups(%s,%d)\n",getuid(),geteuid(),pw->pw_name, initgroupgid); +/* printf("uid=%d euid=%d initgroups(%s,%d)\n",getuid(),geteuid(),pw->pw_name, initgroupgid); */ if(initgroups(pw->pw_name, initgroupgid)) #ifdef _HPUX_SOURCE /* Kluge for HP-(S)UX */ @@ -1107,7 +1104,7 @@ void f_create_process(INT32 args) } } #endif /* INITGROUPS */ - printf("uid=%d gid=%d euid=%d egid=%d setuid(%d)\n",getuid(),getgid(),geteuid(),getegid(),wanted_uid); +/* printf("uid=%d gid=%d euid=%d egid=%d setuid(%d)\n",getuid(),getgid(),geteuid(),getegid(),wanted_uid); */ if(setuid(wanted_uid)) { perror("setuid"); @@ -1116,8 +1113,6 @@ void f_create_process(INT32 args) } #endif /* SETUID */ - printf("gazonk\n"); - #ifdef HAVE_SETEUID seteuid(wanted_uid); #endif diff --git a/src/testsuite.in b/src/testsuite.in index 1db054fc3260b3c4c34a235b2c2491621439c34f..5af4a8105636c0264e8a4fb64ce94b55211b5e71 100644 --- a/src/testsuite.in +++ b/src/testsuite.in @@ -1,4 +1,4 @@ -test_true([["$Id: testsuite.in,v 1.73 1998/02/24 17:30:54 grubba Exp $"]]) +test_true([["$Id: testsuite.in,v 1.74 1998/02/24 23:01:35 hubbe Exp $"]]) test_eq(1e1,10.0) test_eq(1E1,10.0) test_eq(1e+1,10.0) @@ -6,6 +6,10 @@ test_eq(1.1e1,11.0) test_eq(1e-1,0.1) test_eq('\x20',32) test_eq("\x20","\040") +test_any([[class G { mapping t=([]); + class tO { void init(string name) { t[name]=this_object(); }} + class W { inherit tO; void create() { init("foo"); }} +}; object x=G(); x->W(); return objectp(x->t->foo)]],1) test_eq([[cpp("#define FOO(X,Y) (X) (Y)\nFOO( (A),(B) )")]],"# 1 \"-\"\n\n( (A) ) ( (B) )") test_eq([[cpp("#define F 'F'\nF")]],"# 1 \"-\"\n\n'F'") test_eq([[cpp("#define MAX(X,Y) ((X)>(Y)?(X):(Y))\n#define MAX3(X,Y,Z) MAX(MAX(X,Y),Z)\nMAX3(1,2,3)")]],"# 1 \"-\"\n\n\n(( (( 1 )>( 2 )?( 1 ):( 2 )) )>( 3 )?( (( 1 )>( 2 )?( 1 ):( 2 )) ):( 3 ))") @@ -15,6 +19,20 @@ test_program([[class foo { program x() { return class {}; }}; class bar { inheri // Testing the 'inline' keyword test_program([[class foo { inline int c() { return time(); } int d() { return c(); } }; class bar { inherit foo; int c() { return 0; } } int a() { return bar()->d(); }]],0) +test_compile([[class inherit_top { inherit top:top; constant top_the_class=top::the_class; class the_other_class { inherit top_the_class; } } ]]) +test_any([[ +class X { + static string f() { return "p"; } + static class gazonk { void create() { f(); }}; + static class g { object e() { return gazonk(); }}; + void create() { g()->e(); }}; return objectp(X()); ]],1) +test_any([[class A { protected int x=1; }; class B { inherit A; int foo() { return A::x; }}; return A()->x==B()->x && B()->foo()==A()->x;]],1) +test_any([[class C { int q() { return p(); } int p() { return 17; }}; return C()->q();]],17) +test_any([[class C1 { + class D { string id() { return "foo"; } }; + class Y { program YinD() { return D; }} }; + class C2 { inherit C1; class D { string id() { return "bar"; } } }; + return C2()->Y()->YinD()()->id()]],"bar") test_any([[object o=class foo{int c;class bar{void create(){c++;};}}(); o->bar(); return o->c;]],1) test_do([[add_constant("GURKA2",class foo { int c; class bar{void create() {c+=17;}}}()); ]]) test_any([[class x { inherit GURKA2.bar; }(); return GURKA2->c;]],17) @@ -556,12 +574,12 @@ test_true(!(1==2)) test_true(!(""!="")) test_true(""!="foo") -test_cmp(1,2) -test_cmp(1.0,2.0) -test_cmp(1,2.0) -test_cmp(1.0,2) -test_cmp("a","b") -test_cmp("","b") +test_cmp3(1,2,3) +test_cmp3(1.0,2.0,3.0) +test_cmp3(1,2.0,3.6) +test_cmp3(1.0,2,4) +test_cmp3("a","b","c") +test_cmp3("","b","cc") // hex construction test_eq(0,0x0) @@ -647,6 +665,8 @@ test_eq(4.0*3,12.0) test_eq(2.0*2*2.0*2*2.0,32.0) test_eq(({"foo","bar","gazonk"})*"-","foo-bar-gazonk") test_equal( ({ ({1}), ({2}), ({3}) })*({8}), ({1,8,2,8,3})) +test_equal( ({ 1 })*3, ({1,1,1}) ) +test_equal( "foo"*3, "foofoofoo" ) // testing / test_eq(12/3,4) @@ -675,6 +695,27 @@ test_equal(({1,0,1,2,1,2,2,2,1,1,1})/({2}),({ ({1,0,1}), ({1}), ({}), ({}), ({1, test_equal(({1,2,3,4})/({}),({ ({1}), ({2}), ({3}), ({4}) })) test_equal(({1,0,1,2,1,2,2,2,1,1,1})/({2,1}),({ ({1,0,1}), ({2,2}), ({1,1}) })) test_equal( ({1,2,3})/({2,3}), ({ ({1}), ({}) }) ) +test_eq([[`/(20,2,2)]],5) +test_eq([[`/(13,2,3)]],2) +test_equal("foobargazonk"/1,"foobargazonk"/"") +test_equal("foobargazonk"/2,({"fo","ob","ar","ga","zo","nk"})) +test_equal("foobargazonk"/3,({"foo","bar","gaz","onk"})) +test_equal("foobargazonk"/4,({"foob","arga","zonk"})) +test_equal("foobargazonk"/5,({"fooba","rgazo"})) +test_equal("foobargazonk"/-6,({"foobar","gazonk"})) +test_equal("foobargazonk"/-7,({"rgazonk"})) + +test_equal("foobargazonk"/5.0,({"fooba","rgazo","nk"})) +test_equal("foobargazonk"/-5.0,({"fo","obarg","azonk"})) +test_equal("foobargazonk"/2.5,({"fo","oba","rg","azo","nk"})) + +test_equal(({1,2,3})/1,({ ({1}), ({2}), ({3}) })) +test_equal(({1,2,3})/2,({ ({1,2}) })) +test_equal(({1,2,3})/-2,({ ({2,3}) })) + +test_equal(({1,2,3})/2.0,({ ({1,2}), ({3}) })) +test_equal(({1,2,3})/-2.0,({ ({1}), ({2,3}) })) +test_equal(({1,2,3})/1.5,({ ({1}), ({2,3}) })) // testing % test_eq(12%3,0) @@ -702,6 +743,12 @@ test_eq(14.0 % 3,2.0) test_eq(14.5 % 3,2.5) test_eval_error(return 15.0 % 0.0) +test_eq("foobargazonk"%5,"nk") +test_eq("foobargazonk"%-5,"fo") +test_equal(({1,2,3})%2,({3})) +test_equal(({1,2,3})%-2,({1})) + + // testing && test_eq(0 && 1,0) test_eq(1 && 0,0) @@ -842,6 +889,19 @@ test_equal(({1,2,3})[-100..100],({1,2,3})) test_equal(({1,2,3})[1..0],({})) test_equal(({1,2,3})[0..-100],({})) +// casting +test_eq([[(int)1]],[[1]]) +test_eq([[(int)1.0]],[[1]]) +test_eq([[(int)"1"]],[[1]]) +test_eq([[(float)"1"]],[[1.0]]) +test_eq([[(float)"1.0"]],[[1.0]]) +test_eq([[(float)1.0]],[[1.0]]) +test_eq([[(float)1]],[[1.0]]) +test_eq([[(string)1]],[["1"]]) +test_equal([[(array)(["1":1])]],[[ ({ ({"1", 1}) }) ]]) +test_equal([[(array(int)) ({"1","4711",2.0,4})]],[[({1,4711,2,4})]]) + + // testing @ test_equal(({1,2,3}),lambda(mixed ... x) { return x; }(@a())) test_equal("foo"/"",lambda(mixed ... x) { return x; }(@a())) diff --git a/src/version.c b/src/version.c index 448fa29737c11b163a24316dfd269ab85fb4a4a2..d623477d6f97b0a64c4aba71bc3ea35afed72627 100644 --- a/src/version.c +++ b/src/version.c @@ -12,5 +12,5 @@ void f_version(INT32 args) { pop_n_elems(args); - push_text("Pike v0.6 release 0"); + push_text("Pike v0.6 release 1"); }