From 79c1e2702726cadac99f6ca664a91ea75f3d9464 Mon Sep 17 00:00:00 2001 From: ValKmjolnir Date: Fri, 3 Feb 2023 19:01:00 +0800 Subject: [PATCH] :bug: fix bug in test/calc.nas --- makefile | 1 + nasal_codegen.h | 8 +------- test/calc.nas | 8 ++++---- test/coroutine.nas | 3 ++- test/datalog.nas | 8 ++++---- test/{auto-push.nas => push.nas} | 2 ++ 6 files changed, 14 insertions(+), 16 deletions(-) rename test/{auto-push.nas => push.nas} (64%) diff --git a/makefile b/makefile index 5ae0a11..74f998e 100644 --- a/makefile +++ b/makefile @@ -67,6 +67,7 @@ test:nasal @ ./nasal -t -d test/pi.nas @ ./nasal -c test/ppmgen.nas @ ./nasal -t -d test/prime.nas + @ ./nasal -c test/push.nas @ ./nasal -e test/qrcode.nas @ ./nasal -t -d test/quick_sort.nas @ ./nasal -e test/scalar.nas hello world diff --git a/nasal_codegen.h b/nasal_codegen.h index b6cc46a..4cf5a9e 100644 --- a/nasal_codegen.h +++ b/nasal_codegen.h @@ -115,13 +115,7 @@ struct opcode { u32 line;// line of source code opcode(u8 o=op_exit,u16 f=0,u32 n=0,u32 l=0): op(o),fidx(f),num(n),line(l) {} - opcode& operator=(const opcode& tmp) { - op=tmp.op; - fidx=tmp.fidx; - num=tmp.num; - line=tmp.line; - return *this; - } + opcode& operator=(const opcode& tmp) = default; }; class codestream { diff --git a/test/calc.nas b/test/calc.nas index 32a113d..07dc3f1 100644 --- a/test/calc.nas +++ b/test/calc.nas @@ -35,7 +35,7 @@ var blank=func(s){ flag=1; } } - if(flag){ + if(!flag){ return 0; } } @@ -63,7 +63,7 @@ var calc=func(codetype,files,path=""){ println(rightpad(files[i],padding_length),'|', column(line_cnt),' line |', column(semi_cnt),' semi |', - leftpad(str(int(size(s)/1024)),3),' kb | ', + leftpad(str(int(size(s)/1024)),4),' kb | ', md5(s),' |'); bytes+=size(s); ctx~=s; @@ -73,7 +73,7 @@ var calc=func(codetype,files,path=""){ println(rightpad("total:",padding_length),'|', column(line),' line |', column(semi),' semi |', - leftpad(str(int(bytes/1024)),3),' kb | ', + leftpad(str(int(bytes/1024)),4),' kb | ', md5(ctx),' |\n'); return int(bytes/1024); } @@ -82,4 +82,4 @@ var all=calc("source code:",source) +calc("lib:",lib,"stl/") +calc("test file:",testfile,"test/") +calc("module:",module,"module/"); -println(rightpad("total:",padding_length),'| ',rightpad(str(all),6),'kb'); \ No newline at end of file +println(rightpad("total:",padding_length),'|',leftpad(str(all),6),' kb |'); \ No newline at end of file diff --git a/test/coroutine.nas b/test/coroutine.nas index 5022534..be9b14a 100644 --- a/test/coroutine.nas +++ b/test/coroutine.nas @@ -1,6 +1,7 @@ # coroutine.nas by ValKmjolnir # 2022/5/19 import.stl.process_bar; +import.stl.padding; if(os.platform()=="windows"){ system("chcp 65001"); @@ -105,7 +106,7 @@ for(var t=0;t<10;t+=1){ coroutine.resume(co); if(counter-int(counter/1000)*1000==0){ var rate=counter/4e5; - print(" ",bar.bar(rate)," ",int(rate*100),"% | ",str(1e3*int(counter/tm.elapsedMSec()))," tasks/s \r"); + print(" ",bar.bar(rate)," ",leftpad(str(int(rate*100)),3),"% | ",str(1e3*int(counter/tm.elapsedMSec()))," tasks/s \r"); } } diff --git a/test/datalog.nas b/test/datalog.nas index 2d7ef38..8404d7d 100644 --- a/test/datalog.nas +++ b/test/datalog.nas @@ -27,10 +27,10 @@ var project=func(n) { # generate process bar, every 0.2% if((i-last_step)/n>1/500) { last_step=i; - print(" ",bar.bar((i+1)/n)~" \r"); + print(" ",bar.bar((i+1)/n)," ",leftpad(str(int((i+1)/n*100)),3),"% | \r"); } } - print(" ",bar.bar(1)~" ",rightpad(str(ts.elapsedMSec()/1000),5)," s | "); + print(" ",bar.bar(1)~" 100% | ",rightpad(str(ts.elapsedMSec()/1000),5)," s | "); mess(color); @@ -63,10 +63,10 @@ var select=func(n) { # generate process bar, every 0.2% if((i-last_step)/n>1/500) { last_step=i; - print(" ",bar.bar((i+1)/n)~" \r"); + print(" ",bar.bar((i+1)/n)," ",leftpad(str(int((i+1)/n*100)),3),"% | \r"); } } - print(" ",bar.bar(1)~" ",rightpad(str(ts.elapsedMSec()/1000),5)," s | "); + print(" ",bar.bar(1)~" 100% | ",rightpad(str(ts.elapsedMSec()/1000),5)," s | "); mess(color); mess(message); diff --git a/test/auto-push.nas b/test/push.nas similarity index 64% rename from test/auto-push.nas rename to test/push.nas index 1feb1da..13918d8 100644 --- a/test/auto-push.nas +++ b/test/push.nas @@ -1,4 +1,6 @@ +println("[",os.time(),"] auto push, please wait..."); + while(system("git push")!=0) { println("[",os.time(),"] failed to push, retrying..."); unix.sleep(0.5);