Răsfoiți Sursa

refactor & feat: 优化run_code代码

SongZihuan 3 ani în urmă
părinte
comite
8dc07f8301
3 a modificat fișierele cu 24 adăugiri și 2 ștergeri
  1. 3 0
      include/tool/tool-stdio.h
  2. 15 0
      include/tool/tool-stdio.inline.h
  3. 6 2
      test/src/run-code.cpp

+ 3 - 0
include/tool/tool-stdio.h

@@ -80,6 +80,9 @@ namespace aFuntool {
         inline OutStream &operator<<(uint16_t a);
         inline OutStream &operator<<(uint32_t a);
         inline OutStream &operator<<(uint64_t a);
+        inline OutStream &operator<<(float a);
+        inline OutStream &operator<<(double a);
+        inline OutStream &operator<<(long double a);
         inline OutStream &operator<<(const char *a);
         inline OutStream &operator<<(const std::string &a);
         inline OutStream &operator<<(const void *a);

+ 15 - 0
include/tool/tool-stdio.inline.h

@@ -155,6 +155,21 @@ namespace aFuntool {
         func(0, "%p", a);
         return *this;
     }
+
+    inline OutStream &OutStream::operator<<(float a) {
+        func(0, "%f", a);
+        return *this;
+    }
+
+    inline OutStream &OutStream::operator<<(double a) {
+        func(0, "%f", a);
+        return *this;
+    }
+
+    inline OutStream &OutStream::operator<<(long double a) {
+        func(0, "%lf", a);
+        return *this;
+    }
 }
 
 #endif //AFUN_STDIO_INLINE_H

+ 6 - 2
test/src/run-code.cpp

@@ -60,7 +60,6 @@ public:
                                                        new Code::ByteCode(code, "test-var", 1), 0));
         gc_inter.runCode(code);
         printInterEvent(gc_inter);
-        fputs_stdout("\n");
     };
 };
 
@@ -171,7 +170,12 @@ int Main() {
     tmp->delReference();
 
     aFuntool::cout << "Checking gc ...\n";
-    aFuntool::safeSleep(3);
+    for (int i = 0; i <= 12; i++) {
+        aFuntool::cout << "Wait " << (i * 0.25) << "\n";
+        aFuntool::safeSleep(0.25);
+    }
+    aFuntool::cout << "Check gc finished.\n\n";
+
 
     {
         fputs_stdout("Test-1: block-p & get test-var\n");